Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cf24b6bc
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cf24b6bc
编写于
12月 31, 2019
作者:
D
Dylan DPC
提交者:
GitHub
12月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #67723 - ldm0:E0477, r=Dylan-DPC
Add error code explanation for E0477 Part of #61137
上级
b223f5b0
b4e1fbcf
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
54 addition
and
3 deletion
+54
-3
src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes.rs
+1
-1
src/librustc_error_codes/error_codes/E0477.md
src/librustc_error_codes/error_codes/E0477.md
+45
-0
src/test/ui/issues/issue-26217.stderr
src/test/ui/issues/issue-26217.stderr
+1
-0
src/test/ui/issues/issue-54943.stderr
src/test/ui/issues/issue-54943.stderr
+1
-0
src/test/ui/kindck/kindck-impl-type-params.stderr
src/test/ui/kindck/kindck-impl-type-params.stderr
+2
-1
src/test/ui/kindck/kindck-send-object1.stderr
src/test/ui/kindck/kindck-send-object1.stderr
+2
-1
src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr
.../regions/regions-bounded-by-trait-requiring-static.stderr
+1
-0
src/test/ui/regions/regions-bounded-method-type-parameters.stderr
.../ui/regions/regions-bounded-method-type-parameters.stderr
+1
-0
未找到文件。
src/librustc_error_codes/error_codes.rs
浏览文件 @
cf24b6bc
...
...
@@ -238,6 +238,7 @@
E0466
:
include_str!
(
"./error_codes/E0466.md"
),
E0468
:
include_str!
(
"./error_codes/E0468.md"
),
E0469
:
include_str!
(
"./error_codes/E0469.md"
),
E0477
:
include_str!
(
"./error_codes/E0477.md"
),
E0478
:
include_str!
(
"./error_codes/E0478.md"
),
E0491
:
include_str!
(
"./error_codes/E0491.md"
),
E0492
:
include_str!
(
"./error_codes/E0492.md"
),
...
...
@@ -531,7 +532,6 @@
E0474
,
// captured variable `..` does not outlive the enclosing closure
E0475
,
// index of slice outside its lifetime
E0476
,
// lifetime of the source pointer does not outlive lifetime bound...
E0477
,
// the type `..` does not fulfill the required lifetime...
E0479
,
// the type `..` (provided as the value of a type parameter) is...
E0480
,
// lifetime of method receiver does not outlive the method call
E0481
,
// lifetime of function argument does not outlive the function call
...
...
src/librustc_error_codes/error_codes/E0477.md
0 → 100644
浏览文件 @
cf24b6bc
The type does not fulfill the required lifetime.
Erroneous code example:
```
compile_fail,E0477
use std::sync::Mutex;
struct MyString<'a> {
data: &'a str,
}
fn i_want_static_closure<F>(a: F)
where F: Fn() + 'static {}
fn print_string<'a>(s: Mutex<MyString<'a>>) {
i_want_static_closure(move || { // error: this closure has lifetime 'a
// rather than 'static
println!("{}", s.lock().unwrap().data);
});
}
```
In this example, the closure does not satisfy the
`'static`
lifetime constraint.
To fix this error, you need to double check the lifetime of the type. Here, we
can fix this problem by giving
`s`
a static lifetime:
```
use std::sync::Mutex;
struct MyString<'a> {
data: &'a str,
}
fn i_want_static_closure<F>(a: F)
where F: Fn() + 'static {}
fn print_string(s: Mutex<MyString<'static>>) {
i_want_static_closure(move || { // error: this closure has lifetime 'a
// rather than 'static
println!("{}", s.lock().unwrap().data);
});
}
```
src/test/ui/issues/issue-26217.stderr
浏览文件 @
cf24b6bc
...
...
@@ -8,3 +8,4 @@ LL | foo::<&'a i32>();
error: aborting due to previous error
For more information about this error, try `rustc --explain E0477`.
src/test/ui/issues/issue-54943.stderr
浏览文件 @
cf24b6bc
...
...
@@ -8,3 +8,4 @@ LL | let x = foo::<&'a u32>();
error: aborting due to previous error
For more information about this error, try `rustc --explain E0477`.
src/test/ui/kindck/kindck-impl-type-params.stderr
浏览文件 @
cf24b6bc
...
...
@@ -76,4 +76,5 @@ LL | let a: Box<dyn Gettable<Foo>> = t;
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0277`.
Some errors have detailed explanations: E0277, E0477.
For more information about an error, try `rustc --explain E0277`.
src/test/ui/kindck/kindck-send-object1.stderr
浏览文件 @
cf24b6bc
...
...
@@ -33,4 +33,5 @@ LL | assert_send::<Box<dyn Dummy + 'a>>();
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
Some errors have detailed explanations: E0277, E0477.
For more information about an error, try `rustc --explain E0277`.
src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr
浏览文件 @
cf24b6bc
...
...
@@ -48,3 +48,4 @@ LL | assert_send::<*mut &'a isize>();
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0477`.
src/test/ui/regions/regions-bounded-method-type-parameters.stderr
浏览文件 @
cf24b6bc
...
...
@@ -8,3 +8,4 @@ LL | Foo.some_method::<&'a isize>();
error: aborting due to previous error
For more information about this error, try `rustc --explain E0477`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录