Add nll feature and make nll imply nll_dump_cause
This commit is contained in:
parent
95b6148e31
commit
0b2db1e616
@ -261,7 +261,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
errors: &Vec<RegionResolutionError<'tcx>>) {
|
errors: &Vec<RegionResolutionError<'tcx>>) {
|
||||||
debug!("report_region_errors(): {} errors to start", errors.len());
|
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 {
|
for error in errors {
|
||||||
match *error {
|
match *error {
|
||||||
RegionResolutionError::ConcreteFailure(ref origin, ..) |
|
RegionResolutionError::ConcreteFailure(ref origin, ..) |
|
||||||
|
@ -437,6 +437,9 @@ impl Session {
|
|||||||
pub fn print_llvm_passes(&self) -> bool {
|
pub fn print_llvm_passes(&self) -> bool {
|
||||||
self.opts.debugging_opts.print_llvm_passes
|
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 {
|
pub fn nll_dump_cause(&self) -> bool {
|
||||||
self.opts.debugging_opts.nll_dump_cause
|
self.opts.debugging_opts.nll_dump_cause
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ fn mir_borrowck<'a, 'tcx>(
|
|||||||
|
|
||||||
if {
|
if {
|
||||||
!tcx.has_attr(def_id, "rustc_mir_borrowck") && !tcx.sess.opts.borrowck_mode.use_mir()
|
!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;
|
return None;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||||||
// contain non-lexical lifetimes. It will have a lifetime tied
|
// contain non-lexical lifetimes. It will have a lifetime tied
|
||||||
// to the inference context.
|
// to the inference context.
|
||||||
let mut mir: Mir<'tcx> = input_mir.clone();
|
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
|
None
|
||||||
} else {
|
} else {
|
||||||
let mir = &mut mir;
|
let mir = &mut mir;
|
||||||
@ -207,7 +207,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||||||
);
|
);
|
||||||
(Some(Rc::new(regioncx)), opt_closure_req)
|
(Some(Rc::new(regioncx)), opt_closure_req)
|
||||||
} else {
|
} else {
|
||||||
assert!(!tcx.sess.opts.debugging_opts.nll);
|
assert!(!tcx.sess.nll());
|
||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
let flow_inits = flow_inits; // remove mut
|
let flow_inits = flow_inits; // remove mut
|
||||||
|
@ -186,6 +186,9 @@ declare_features! (
|
|||||||
// Allows the use of rustc_* attributes; RFC 572
|
// Allows the use of rustc_* attributes; RFC 572
|
||||||
(active, rustc_attrs, "1.0.0", Some(29642)),
|
(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
|
// Allows the use of #[allow_internal_unstable]. This is an
|
||||||
// attribute on macro_rules! and can't use the attribute handling
|
// attribute on macro_rules! and can't use the attribute handling
|
||||||
// below (it has to be checked before expansion possibly makes
|
// below (it has to be checked before expansion possibly makes
|
||||||
@ -798,6 +801,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
|
|||||||
libcore functions that are inlined \
|
libcore functions that are inlined \
|
||||||
across crates and will never be stable",
|
across crates and will never be stable",
|
||||||
cfg_fn!(rustc_attrs))),
|
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", Whitelisted, Gated(Stability::Unstable,
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"the `#[compiler_builtins]` attribute is used to \
|
"the `#[compiler_builtins]` attribute is used to \
|
||||||
|
18
src/test/ui/feature-gate-nll.rs
Normal file
18
src/test/ui/feature-gate-nll.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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]
|
||||||
|
}
|
10
src/test/ui/feature-gate-nll.stderr
Normal file
10
src/test/ui/feature-gate-nll.stderr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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
|
||||||
|
|
@ -8,12 +8,13 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags:-Znll -Zborrowck=mir -Znll-dump-cause
|
// compile-flags:-Zborrowck=mir -Znll-dump-cause
|
||||||
|
|
||||||
// Test that a structure which tries to store a pointer to `y` into
|
// Test that a structure which tries to store a pointer to `y` into
|
||||||
// `p` (indirectly) fails to compile.
|
// `p` (indirectly) fails to compile.
|
||||||
|
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
#![feature(nll)]
|
||||||
|
|
||||||
struct SomeStruct<'a, 'b: 'a> {
|
struct SomeStruct<'a, 'b: 'a> {
|
||||||
p: &'a mut &'b i32,
|
p: &'a mut &'b i32,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
error[E0597]: `y` does not live long enough
|
error[E0597]: `y` does not live long enough
|
||||||
--> $DIR/capture-ref-in-struct.rs:32:16
|
--> $DIR/capture-ref-in-struct.rs:33:16
|
||||||
|
|
|
|
||||||
32 | y: &y,
|
33 | y: &y,
|
||||||
| ^^ borrowed value does not live long enough
|
| ^^ borrowed value does not live long enough
|
||||||
...
|
...
|
||||||
37 | }
|
38 | }
|
||||||
| - borrowed value only lives until here
|
| - borrowed value only lives until here
|
||||||
38 |
|
39 |
|
||||||
39 | deref(p);
|
40 | deref(p);
|
||||||
| - borrow later used here
|
| - borrow later used here
|
||||||
|
|
|
|
||||||
= note: borrowed value must be valid for lifetime '_#5r...
|
= note: borrowed value must be valid for lifetime '_#5r...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user