Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
df37678b
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,发现更多精彩内容 >>
提交
df37678b
编写于
9月 10, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add FIXME related to `ref x` bindings
上级
2b6f9664
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
14 deletion
+16
-14
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/mod.rs
+14
-1
src/test/ui/nll/user-annotations/patterns.rs
src/test/ui/nll/user-annotations/patterns.rs
+1
-1
src/test/ui/nll/user-annotations/patterns.stderr
src/test/ui/nll/user-annotations/patterns.stderr
+1
-12
未找到文件。
src/librustc_mir/build/matches/mod.rs
浏览文件 @
df37678b
...
...
@@ -475,7 +475,7 @@ pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span, for_guard:
pub
fn
visit_bindings
(
&
mut
self
,
pattern
:
&
Pattern
<
'tcx
>
,
pattern_user_ty
:
Option
<
CanonicalTy
<
'tcx
>>
,
mut
pattern_user_ty
:
Option
<
CanonicalTy
<
'tcx
>>
,
f
:
&
mut
impl
FnMut
(
&
mut
Self
,
Mutability
,
...
...
@@ -497,6 +497,19 @@ pub fn visit_bindings(
ref
subpattern
,
..
}
=>
{
match
mode
{
BindingMode
::
ByValue
=>
{
}
BindingMode
::
ByRef
(
..
)
=>
{
// If this is a `ref` binding (e.g., `let ref
// x: T = ..`), then the type of `x` is not
// `T` but rather `&T`, so ignore
// `pattern_user_ty` for now.
//
// FIXME(#47184): extract or handle `pattern_user_ty` somehow
pattern_user_ty
=
None
;
}
}
f
(
self
,
mutability
,
name
,
mode
,
var
,
pattern
.span
,
ty
,
pattern_user_ty
);
if
let
Some
(
subpattern
)
=
subpattern
.as_ref
()
{
self
.visit_bindings
(
subpattern
,
pattern_user_ty
,
f
);
...
...
src/test/ui/nll/user-annotations/patterns.rs
浏览文件 @
df37678b
...
...
@@ -20,7 +20,7 @@ fn ref_with_ascribed_static_type() -> u32 {
// Check the behavior in some wacky cases.
let
x
=
22
;
let
y
=
&
x
;
//~ ERROR
let
ref
z
:
&
'static
u32
=
y
;
//~ ERROR
let
ref
z
:
&
'static
u32
=
y
;
**
z
}
...
...
src/test/ui/nll/user-annotations/patterns.stderr
浏览文件 @
df37678b
...
...
@@ -19,17 +19,6 @@ LL | }
|
= note: borrowed value must be valid for the static lifetime...
error[E0597]: `y` does not live long enough
--> $DIR/patterns.rs:23:9
|
LL | let ref z: &'static u32 = y; //~ ERROR
| ^^^^^ borrowed value does not live long enough
LL | **z
LL | }
| - `y` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...
error[E0597]: `x` does not live long enough
--> $DIR/patterns.rs:46:27
|
...
...
@@ -149,6 +138,6 @@ LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 {
LL | let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR
| ^^^^^^^ requires that `'a` must outlive `'static`
error: aborting due to 1
5
previous errors
error: aborting due to 1
4
previous errors
For more information about this error, try `rustc --explain E0597`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录