Skip to content

Remove 'not reporting regions error due to nll' warning #53865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 10 additions & 33 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use middle::region;
use traits::{ObligationCause, ObligationCauseCode};
use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TyKind};
use ty::error::TypeError;
use session::config::BorrowckMode;
use syntax::ast::DUMMY_NODE_ID;
use syntax_pos::{Pos, Span};
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
Expand Down Expand Up @@ -303,40 +304,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
) {
debug!("report_region_errors(): {} errors to start", errors.len());

if will_later_be_reported_by_nll &&
// FIXME: `use_mir_borrowck` seems wrong here...
self.tcx.use_mir_borrowck() &&
// ... this is a band-aid; may be better to explicitly
// match on every borrowck_mode variant to guide decision
// here.
!self.tcx.migrate_borrowck() {

// With `#![feature(nll)]`, we want to present a nice user
// experience, so don't even mention the errors from the
// AST checker.
if self.tcx.features().nll {
return;
// If the errors will later be reported by NLL, choose wether to display them or not based
// on the borrowck mode
if will_later_be_reported_by_nll {
match self.tcx.borrowck_mode() {
// If we're on AST or Migrate mode, report AST region errors
BorrowckMode::Ast | BorrowckMode::Migrate => {},
// If we're on MIR or Compare mode, don't report AST region errors as they should
// be reported by NLL
BorrowckMode::Compare | BorrowckMode::Mir => return,
}

// But with nll, it's nice to have some note for later.
for error in errors {
match *error {
RegionResolutionError::ConcreteFailure(ref origin, ..)
| RegionResolutionError::GenericBoundFailure(ref origin, ..) => {
self.tcx
.sess
.span_warn(origin.span(), "not reporting region error due to nll");
}

RegionResolutionError::SubSupConflict(ref rvo, ..) => {
self.tcx
.sess
.span_warn(rvo.span(), "not reporting region error due to nll");
}
}
}

return;
}

// try to pre-process the errors, which will group some of them
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:12
|
LL | let z: I::A = if cond { x } else { y };
| ^^^^

error: unsatisfied lifetime constraints
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:29
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/project-fn-ret-contravariant.rs:53:16
|
LL | let a = bar(foo, y);
| ^^^

warning: not reporting region error due to nll
--> $DIR/project-fn-ret-contravariant.rs:54:16
|
LL | let b = bar(foo, x);
| ^^^

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-contravariant.rs:53:12
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/project-fn-ret-contravariant.rs:48:8
|
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-contravariant.rs:48:4
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/project-fn-ret-invariant.rs:63:16
|
LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623
| ^^^

warning: not reporting region error due to nll
--> $DIR/project-fn-ret-invariant.rs:64:16
|
LL | let b = bar(foo, x);
| ^^^

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-invariant.rs:63:12
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/project-fn-ret-invariant.rs:47:12
|
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
| ^^^

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-invariant.rs:48:12
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/project-fn-ret-invariant.rs:58:8
|
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-invariant.rs:58:4
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:18
|
LL | S { pointer: &mut *p.pointer }
| ^^^^^^^^^^^^^^^

error: unsatisfied lifetime constraints
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5
|
Expand Down
6 changes: 0 additions & 6 deletions src/test/ui/borrowck/issue-45983.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/issue-45983.rs:36:27
|
LL | give_any(|y| x = Some(y));
| ^

error: borrowed data escapes outside of closure
--> $DIR/issue-45983.rs:36:18
|
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/borrowck/issue-45983.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ fn main() {
give_any(|y| x = Some(y));
//[ast]~^ ERROR borrowed data cannot be stored outside of its closure
//[migrate]~^^ ERROR borrowed data cannot be stored outside of its closure
//[nll]~^^^ WARN not reporting region error due to nll
//[nll]~| ERROR borrowed data escapes outside of closure
//[nll]~^^^ ERROR borrowed data escapes outside of closure
//[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable
}
6 changes: 0 additions & 6 deletions src/test/ui/borrowck/issue-7573.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/issue-7573.rs:27:31
|
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| ^

error: borrowed data escapes outside of closure
--> $DIR/issue-7573.rs:32:9
|
Expand Down
6 changes: 0 additions & 6 deletions src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/regions-escape-bound-fn-2.rs:18:27
|
LL | with_int(|y| x = Some(y));
| ^

error: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn-2.rs:18:18
|
Expand Down
6 changes: 0 additions & 6 deletions src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/regions-escape-bound-fn.rs:18:22
|
LL | with_int(|y| x = Some(y));
| ^^^^^^^

error: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn.rs:18:18
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/regions-escape-unboxed-closure.rs:16:27
|
LL | with_int(&mut |y| x = Some(y));
| ^^^^^^^

error: borrowed data escapes outside of closure
--> $DIR/regions-escape-unboxed-closure.rs:16:23
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/expect-fn-supply-fn.rs:24:52
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^

error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:40:5
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:9
|
LL | bar(|| {
| _________^
LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621]
LL | | let _ = x;
LL | | })
| |_____^

error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:5
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/expect-region-supply-region.rs:28:13
|
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
| ^^^^^^^

warning: not reporting region error due to nll
--> $DIR/expect-region-supply-region.rs:38:13
|
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
| ^^^^^^^

warning: not reporting region error due to nll
--> $DIR/expect-region-supply-region.rs:47:33
|
LL | closure_expecting_bound(|x: &'x u32| {
| ^^^^^^^

warning: not reporting region error due to nll
--> $DIR/expect-region-supply-region.rs:52:13
|
LL | f = Some(x);
| ^^^^^^^

error: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:28:9
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
|
LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
| ^^^^^^

error: unsatisfied lifetime constraints
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:45
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ LL | let z: i32 = x; //~ ERROR mismatched types
= note: expected type `i32`
found type `WrongGeneric::<&{integer}>`

warning: not reporting region error due to nll
--> $DIR/generic_type_does_not_live_long_enough.rs:19:1
|
LL | existential type WrongGeneric<T>: 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/hr-subtype.rs:43:26
|
LL | gimme::<$t2>(None::<$t1>);
| ^^^^^^^^^^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation

warning: not reporting region error due to nll
--> $DIR/hr-subtype.rs:49:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation

error: unsatisfied lifetime constraints
--> $DIR/hr-subtype.rs:43:13
|
Expand Down
10 changes: 0 additions & 10 deletions src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/hr-subtype.rs:49:26
|
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation

error: unsatisfied lifetime constraints
--> $DIR/hr-subtype.rs:49:13
|
Expand Down
6 changes: 0 additions & 6 deletions src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/dyn-trait.rs:32:16
|
LL | static_val(x); //~ ERROR cannot infer
| ^

error: borrowed data escapes outside of function
--> $DIR/dyn-trait.rs:32:5
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/must_outlive_least_region_or_bound.rs:13:35
|
LL | fn elided(x: &i32) -> impl Copy { x }
| ^

warning: not reporting region error due to nll
--> $DIR/must_outlive_least_region_or_bound.rs:16:44
|
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
| ^

warning: not reporting region error due to nll
--> $DIR/must_outlive_least_region_or_bound.rs:22:69
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
| ^

warning: not reporting region error due to nll
--> $DIR/must_outlive_least_region_or_bound.rs:29:5
|
LL | move |_| println!("{}", y)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: not reporting region error due to nll
--> $DIR/must_outlive_least_region_or_bound.rs:32:51
|
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
| ^^^^^^^^^^^^^^^^^^^^

error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/must_outlive_least_region_or_bound.rs:13:35
|
Expand Down
12 changes: 0 additions & 12 deletions src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/static-return-lifetime-infered.rs:17:16
|
LL | self.x.iter().map(|a| a.0)
| ^^^^

warning: not reporting region error due to nll
--> $DIR/static-return-lifetime-infered.rs:21:16
|
LL | self.x.iter().map(|a| a.0)
| ^^^^

error: unsatisfied lifetime constraints
--> $DIR/static-return-lifetime-infered.rs:17:9
|
Expand Down
6 changes: 0 additions & 6 deletions src/test/ui/impl-trait/type_parameters_captured.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/type_parameters_captured.rs:17:20
|
LL | fn foo<T>(x: T) -> impl Any + 'static {
| ^^^^^^^^^^^^^^^^^^

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/type_parameters_captured.rs:19:5
|
Expand Down
12 changes: 0 additions & 12 deletions src/test/ui/in-band-lifetimes/mismatched.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
warning: not reporting region error due to nll
--> $DIR/mismatched.rs:14:42
|
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
| ^

warning: not reporting region error due to nll
--> $DIR/mismatched.rs:16:46
|
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
| ^

error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/mismatched.rs:14:42
|
Expand Down
Loading