Skip to content

Commit f3bb231

Browse files
committed
Auto merge of rust-lang#53865 - zilbuz:issue-52768, r=pnkfelix
Remove 'not reporting regions error due to nll' warning Fix rust-lang#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

Lines changed: 10 additions & 33 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 12 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 12 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 1 addition & 2 deletions
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
}

0 commit comments

Comments
 (0)