Skip to content

Commit f3bb231

Browse files
committed
Auto merge of #53865 - zilbuz:issue-52768, r=pnkfelix
Remove 'not reporting regions error due to nll' warning Fix #52768
2 parents 2687112 + b01550a commit f3bb231

File tree

218 files changed

+150
-2104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+150
-2104
lines changed

src/librustc/infer/error_reporting/mod.rs

+10-33
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use middle::region;
6868
use traits::{ObligationCause, ObligationCauseCode};
6969
use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TyKind};
7070
use ty::error::TypeError;
71+
use session::config::BorrowckMode;
7172
use syntax::ast::DUMMY_NODE_ID;
7273
use syntax_pos::{Pos, Span};
7374
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
@@ -303,40 +304,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
303304
) {
304305
debug!("report_region_errors(): {} errors to start", errors.len());
305306

306-
if will_later_be_reported_by_nll &&
307-
// FIXME: `use_mir_borrowck` seems wrong here...
308-
self.tcx.use_mir_borrowck() &&
309-
// ... this is a band-aid; may be better to explicitly
310-
// match on every borrowck_mode variant to guide decision
311-
// here.
312-
!self.tcx.migrate_borrowck() {
313-
314-
// With `#![feature(nll)]`, we want to present a nice user
315-
// experience, so don't even mention the errors from the
316-
// AST checker.
317-
if self.tcx.features().nll {
318-
return;
307+
// If the errors will later be reported by NLL, choose wether to display them or not based
308+
// on the borrowck mode
309+
if will_later_be_reported_by_nll {
310+
match self.tcx.borrowck_mode() {
311+
// If we're on AST or Migrate mode, report AST region errors
312+
BorrowckMode::Ast | BorrowckMode::Migrate => {},
313+
// If we're on MIR or Compare mode, don't report AST region errors as they should
314+
// be reported by NLL
315+
BorrowckMode::Compare | BorrowckMode::Mir => return,
319316
}
320-
321-
// But with nll, it's nice to have some note for later.
322-
for error in errors {
323-
match *error {
324-
RegionResolutionError::ConcreteFailure(ref origin, ..)
325-
| RegionResolutionError::GenericBoundFailure(ref origin, ..) => {
326-
self.tcx
327-
.sess
328-
.span_warn(origin.span(), "not reporting region error due to nll");
329-
}
330-
331-
RegionResolutionError::SubSupConflict(ref rvo, ..) => {
332-
self.tcx
333-
.sess
334-
.span_warn(rvo.span(), "not reporting region error due to nll");
335-
}
336-
}
337-
}
338-
339-
return;
340317
}
341318

342319
// try to pre-process the errors, which will group some of them

src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:12
3-
|
4-
LL | let z: I::A = if cond { x } else { y };
5-
| ^^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:29
93
|

src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/project-fn-ret-contravariant.rs:53:16
3-
|
4-
LL | let a = bar(foo, y);
5-
| ^^^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/project-fn-ret-contravariant.rs:54:16
9-
|
10-
LL | let b = bar(foo, x);
11-
| ^^^
12-
131
error: unsatisfied lifetime constraints
142
--> $DIR/project-fn-ret-contravariant.rs:53:12
153
|

src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/project-fn-ret-contravariant.rs:48:8
3-
|
4-
LL | bar(foo, x) //[transmute]~ ERROR E0495
5-
| ^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/project-fn-ret-contravariant.rs:48:4
93
|

src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/project-fn-ret-invariant.rs:63:16
3-
|
4-
LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623
5-
| ^^^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/project-fn-ret-invariant.rs:64:16
9-
|
10-
LL | let b = bar(foo, x);
11-
| ^^^
12-
131
error: unsatisfied lifetime constraints
142
--> $DIR/project-fn-ret-invariant.rs:63:12
153
|

src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/project-fn-ret-invariant.rs:47:12
3-
|
4-
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
5-
| ^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/project-fn-ret-invariant.rs:48:12
93
|

src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/project-fn-ret-invariant.rs:58:8
3-
|
4-
LL | bar(foo, x) //[transmute]~ ERROR E0495
5-
| ^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/project-fn-ret-invariant.rs:58:4
93
|

src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:18
3-
|
4-
LL | S { pointer: &mut *p.pointer }
5-
| ^^^^^^^^^^^^^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5
93
|

src/test/ui/borrowck/issue-45983.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/issue-45983.rs:36:27
3-
|
4-
LL | give_any(|y| x = Some(y));
5-
| ^
6-
71
error: borrowed data escapes outside of closure
82
--> $DIR/issue-45983.rs:36:18
93
|

src/test/ui/borrowck/issue-45983.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn main() {
3636
give_any(|y| x = Some(y));
3737
//[ast]~^ ERROR borrowed data cannot be stored outside of its closure
3838
//[migrate]~^^ ERROR borrowed data cannot be stored outside of its closure
39-
//[nll]~^^^ WARN not reporting region error due to nll
40-
//[nll]~| ERROR borrowed data escapes outside of closure
39+
//[nll]~^^^ ERROR borrowed data escapes outside of closure
4140
//[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable
4241
}

src/test/ui/borrowck/issue-7573.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/issue-7573.rs:27:31
3-
|
4-
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
5-
| ^
6-
71
error: borrowed data escapes outside of closure
82
--> $DIR/issue-7573.rs:32:9
93
|

src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/regions-escape-bound-fn-2.rs:18:27
3-
|
4-
LL | with_int(|y| x = Some(y));
5-
| ^
6-
71
error: borrowed data escapes outside of closure
82
--> $DIR/regions-escape-bound-fn-2.rs:18:18
93
|

src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/regions-escape-bound-fn.rs:18:22
3-
|
4-
LL | with_int(|y| x = Some(y));
5-
| ^^^^^^^
6-
71
error: borrowed data escapes outside of closure
82
--> $DIR/regions-escape-bound-fn.rs:18:18
93
|

src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/regions-escape-unboxed-closure.rs:16:27
3-
|
4-
LL | with_int(&mut |y| x = Some(y));
5-
| ^^^^^^^
6-
71
error: borrowed data escapes outside of closure
82
--> $DIR/regions-escape-unboxed-closure.rs:16:23
93
|

src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/expect-fn-supply-fn.rs:24:52
3-
|
4-
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
5-
| ^^^^^^^^^^^
6-
71
error[E0631]: type mismatch in closure arguments
82
--> $DIR/expect-fn-supply-fn.rs:40:5
93
|

src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr

-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:9
3-
|
4-
LL | bar(|| {
5-
| _________^
6-
LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621]
7-
LL | | let _ = x;
8-
LL | | })
9-
| |_____^
10-
111
error[E0621]: explicit lifetime required in the type of `x`
122
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:5
133
|

src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr

-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/expect-region-supply-region.rs:28:13
3-
|
4-
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
5-
| ^^^^^^^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/expect-region-supply-region.rs:38:13
9-
|
10-
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
11-
| ^^^^^^^
12-
13-
warning: not reporting region error due to nll
14-
--> $DIR/expect-region-supply-region.rs:47:33
15-
|
16-
LL | closure_expecting_bound(|x: &'x u32| {
17-
| ^^^^^^^
18-
19-
warning: not reporting region error due to nll
20-
--> $DIR/expect-region-supply-region.rs:52:13
21-
|
22-
LL | f = Some(x);
23-
| ^^^^^^^
24-
251
error: borrowed data escapes outside of closure
262
--> $DIR/expect-region-supply-region.rs:28:9
273
|

src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
3-
|
4-
LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
5-
| ^^^^^^
6-
71
error: unsatisfied lifetime constraints
82
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:45
93
|

src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ LL | let z: i32 = x; //~ ERROR mismatched types
77
= note: expected type `i32`
88
found type `WrongGeneric::<&{integer}>`
99

10-
warning: not reporting region error due to nll
11-
--> $DIR/generic_type_does_not_live_long_enough.rs:19:1
12-
|
13-
LL | existential type WrongGeneric<T>: 'static;
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
1610
error: aborting due to previous error
1711

1812
For more information about this error, try `rustc --explain E0308`.

src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr

-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/hr-subtype.rs:43:26
3-
|
4-
LL | gimme::<$t2>(None::<$t1>);
5-
| ^^^^^^^^^^^
6-
...
7-
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
8-
LL | | fn(Inv<'y>)) }
9-
| |__________________________________________________- in this macro invocation
10-
11-
warning: not reporting region error due to nll
12-
--> $DIR/hr-subtype.rs:49:26
13-
|
14-
LL | gimme::<$t1>(None::<$t2>);
15-
| ^^^^^^^^^^^
16-
...
17-
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
18-
LL | | fn(Inv<'y>)) }
19-
| |__________________________________________________- in this macro invocation
20-
211
error: unsatisfied lifetime constraints
222
--> $DIR/hr-subtype.rs:43:13
233
|

src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr

-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/hr-subtype.rs:49:26
3-
|
4-
LL | gimme::<$t1>(None::<$t2>);
5-
| ^^^^^^^^^^^
6-
...
7-
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
8-
LL | | fn(&'y u32)) }
9-
| |__________________________________________- in this macro invocation
10-
111
error: unsatisfied lifetime constraints
122
--> $DIR/hr-subtype.rs:49:13
133
|

src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/dyn-trait.rs:32:16
3-
|
4-
LL | static_val(x); //~ ERROR cannot infer
5-
| ^
6-
71
error: borrowed data escapes outside of function
82
--> $DIR/dyn-trait.rs:32:5
93
|

src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr

-30
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/must_outlive_least_region_or_bound.rs:13:35
3-
|
4-
LL | fn elided(x: &i32) -> impl Copy { x }
5-
| ^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/must_outlive_least_region_or_bound.rs:16:44
9-
|
10-
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
11-
| ^
12-
13-
warning: not reporting region error due to nll
14-
--> $DIR/must_outlive_least_region_or_bound.rs:22:69
15-
|
16-
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
17-
| ^
18-
19-
warning: not reporting region error due to nll
20-
--> $DIR/must_outlive_least_region_or_bound.rs:29:5
21-
|
22-
LL | move |_| println!("{}", y)
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
25-
warning: not reporting region error due to nll
26-
--> $DIR/must_outlive_least_region_or_bound.rs:32:51
27-
|
28-
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
29-
| ^^^^^^^^^^^^^^^^^^^^
30-
311
error[E0621]: explicit lifetime required in the type of `x`
322
--> $DIR/must_outlive_least_region_or_bound.rs:13:35
333
|

src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/static-return-lifetime-infered.rs:17:16
3-
|
4-
LL | self.x.iter().map(|a| a.0)
5-
| ^^^^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/static-return-lifetime-infered.rs:21:16
9-
|
10-
LL | self.x.iter().map(|a| a.0)
11-
| ^^^^
12-
131
error: unsatisfied lifetime constraints
142
--> $DIR/static-return-lifetime-infered.rs:17:9
153
|

src/test/ui/impl-trait/type_parameters_captured.nll.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/type_parameters_captured.rs:17:20
3-
|
4-
LL | fn foo<T>(x: T) -> impl Any + 'static {
5-
| ^^^^^^^^^^^^^^^^^^
6-
71
error[E0310]: the parameter type `T` may not live long enough
82
--> $DIR/type_parameters_captured.rs:19:5
93
|

src/test/ui/in-band-lifetimes/mismatched.nll.stderr

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
warning: not reporting region error due to nll
2-
--> $DIR/mismatched.rs:14:42
3-
|
4-
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
5-
| ^
6-
7-
warning: not reporting region error due to nll
8-
--> $DIR/mismatched.rs:16:46
9-
|
10-
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
11-
| ^
12-
131
error[E0621]: explicit lifetime required in the type of `y`
142
--> $DIR/mismatched.rs:14:42
153
|

0 commit comments

Comments
 (0)