Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0b2db1e6
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,发现更多精彩内容 >>
提交
0b2db1e6
编写于
12月 19, 2017
作者:
S
Santiago Pastorino
提交者:
Niko Matsakis
12月 20, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add nll feature and make nll imply nll_dump_cause
上级
95b6148e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
51 addition
and
10 deletion
+51
-10
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/error_reporting/mod.rs
+1
-1
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+3
-0
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mod.rs
+3
-3
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+9
-0
src/test/ui/feature-gate-nll.rs
src/test/ui/feature-gate-nll.rs
+18
-0
src/test/ui/feature-gate-nll.stderr
src/test/ui/feature-gate-nll.stderr
+10
-0
src/test/ui/nll/capture-ref-in-struct.rs
src/test/ui/nll/capture-ref-in-struct.rs
+2
-1
src/test/ui/nll/capture-ref-in-struct.stderr
src/test/ui/nll/capture-ref-in-struct.stderr
+5
-5
未找到文件。
src/librustc/infer/error_reporting/mod.rs
浏览文件 @
0b2db1e6
...
...
@@ -261,7 +261,7 @@ pub fn report_region_errors(&self,
errors
:
&
Vec
<
RegionResolutionError
<
'tcx
>>
)
{
debug!
(
"report_region_errors(): {} errors to start"
,
errors
.len
());
if
self
.tcx.sess.
opts.debugging_opts.nll
{
if
self
.tcx.sess
.
nll
()
{
for
error
in
errors
{
match
*
error
{
RegionResolutionError
::
ConcreteFailure
(
ref
origin
,
..
)
|
...
...
src/librustc/session/mod.rs
浏览文件 @
0b2db1e6
...
...
@@ -437,6 +437,9 @@ pub fn borrowck_stats(&self) -> bool { self.opts.debugging_opts.borrowck_stats }
pub
fn
print_llvm_passes
(
&
self
)
->
bool
{
self
.opts.debugging_opts.print_llvm_passes
}
pub
fn
nll
(
&
self
)
->
bool
{
self
.features
.borrow
()
.nll
||
self
.opts.debugging_opts.nll
}
pub
fn
nll_dump_cause
(
&
self
)
->
bool
{
self
.opts.debugging_opts.nll_dump_cause
}
...
...
src/librustc_mir/borrow_check/mod.rs
浏览文件 @
0b2db1e6
...
...
@@ -74,7 +74,7 @@ fn mir_borrowck<'a, 'tcx>(
if
{
!
tcx
.has_attr
(
def_id
,
"rustc_mir_borrowck"
)
&&
!
tcx
.sess.opts.borrowck_mode
.use_mir
()
&&
!
tcx
.sess.
opts.debugging_opts.nll
&&
!
tcx
.sess
.
nll
()
}
{
return
None
;
}
...
...
@@ -104,7 +104,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
// contain non-lexical lifetimes. It will have a lifetime tied
// to the inference context.
let
mut
mir
:
Mir
<
'tcx
>
=
input_mir
.clone
();
let
free_regions
=
if
!
tcx
.sess.
opts.debugging_opts.nll
{
let
free_regions
=
if
!
tcx
.sess
.
nll
()
{
None
}
else
{
let
mir
=
&
mut
mir
;
...
...
@@ -207,7 +207,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
);
(
Some
(
Rc
::
new
(
regioncx
)),
opt_closure_req
)
}
else
{
assert
!
(
!
tcx
.sess.
opts.debugging_opts.nll
);
assert
!
(
!
tcx
.sess
.
nll
()
);
(
None
,
None
)
};
let
flow_inits
=
flow_inits
;
// remove mut
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
0b2db1e6
...
...
@@ -186,6 +186,9 @@ pub fn new() -> Features {
// Allows the use of rustc_* attributes; RFC 572
(
active
,
rustc_attrs
,
"1.0.0"
,
Some
(
29642
)),
// Allows the use of non lexical lifetimes; RFC 2094
(
active
,
nll
,
"1.0.0"
,
Some
(
44928
)),
// Allows the use of #[allow_internal_unstable]. This is an
// attribute on macro_rules! and can't use the attribute handling
// below (it has to be checked before expansion possibly makes
...
...
@@ -798,6 +801,12 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
libcore functions that are inlined
\
across crates and will never be stable"
,
cfg_fn!
(
rustc_attrs
))),
// RFC #2094
(
"nll"
,
Whitelisted
,
Gated
(
Stability
::
Unstable
,
"nll"
,
"Non lexical lifetimes"
,
cfg_fn!
(
nll
))),
(
"compiler_builtins"
,
Whitelisted
,
Gated
(
Stability
::
Unstable
,
"compiler_builtins"
,
"the `#[compiler_builtins]` attribute is used to
\
...
...
src/test/ui/feature-gate-nll.rs
0 → 100644
浏览文件 @
0b2db1e6
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
fn
main
()
{
let
mut
x
=
33
;
let
p
=
&
x
;
x
=
22
;
//~ ERROR cannot assign to `x` because it is borrowed [E0506]
}
src/test/ui/feature-gate-nll.stderr
0 → 100644
浏览文件 @
0b2db1e6
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/feature-gate-nll.rs:17:5
|
16 | let p = &x;
| - borrow of `x` occurs here
17 | x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
| ^^^^^^ assignment to borrowed `x` occurs here
error: aborting due to previous error
src/test/ui/nll/capture-ref-in-struct.rs
浏览文件 @
0b2db1e6
...
...
@@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:-Z
nll -Z
borrowck=mir -Znll-dump-cause
// compile-flags:-Zborrowck=mir -Znll-dump-cause
// Test that a structure which tries to store a pointer to `y` into
// `p` (indirectly) fails to compile.
#![feature(rustc_attrs)]
#![feature(nll)]
struct
SomeStruct
<
'a
,
'b
:
'a
>
{
p
:
&
'a
mut
&
'b
i32
,
...
...
src/test/ui/nll/capture-ref-in-struct.stderr
浏览文件 @
0b2db1e6
error[E0597]: `y` does not live long enough
--> $DIR/capture-ref-in-struct.rs:3
2
:16
--> $DIR/capture-ref-in-struct.rs:3
3
:16
|
3
2
| y: &y,
3
3
| y: &y,
| ^^ borrowed value does not live long enough
...
3
7
| }
3
8
| }
| - borrowed value only lives until here
3
8
|
39
| deref(p);
3
9
|
40
| deref(p);
| - borrow later used here
|
= note: borrowed value must be valid for lifetime '_#5r...
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录