Skip to content

Commit f7eb7fb

Browse files
committed
Auto merge of #55134 - davidtwco:issue-55118, r=pnkfelix
NLL: change compare-mode=nll to use borrowck=migrate Fixes #55118. This PR is split into two parts: The first commit is a minor change that fixes a flaw in the existing `borrowck=migrate` implementation whereby a lint that was promoted to an error in the AST borrow checker would result in the same lint from the NLL borrow checker being downgraded to a warning in migrate mode. This PR fixes this by ensuring lints are exempt from buffering in the NLL borrow checker. The second commit updates `compiletest` to make the NLL compare mode use `-Z borrowck=migrate` rather than `-Z borrowck=mir`. The third commit shows all the test output changes that result from this. r? @pnkfelix
2 parents 1dceadd + 539404b commit f7eb7fb

File tree

206 files changed

+928
-2966
lines changed

Some content is hidden

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

206 files changed

+928
-2966
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,20 +320,20 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
320320
continue;
321321
}
322322

323-
let mut err = tcx.struct_span_lint_node(
323+
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
324+
tcx.struct_span_lint_node(
324325
UNUSED_MUT,
325326
vsi[local_decl.source_info.scope].lint_root,
326327
span,
327328
"variable does not need to be mutable",
328-
);
329-
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
330-
err.span_suggestion_short_with_applicability(
329+
)
330+
.span_suggestion_short_with_applicability(
331331
mut_span,
332332
"remove this `mut`",
333333
String::new(),
334-
Applicability::MachineApplicable);
335-
336-
err.buffer(&mut mbcx.errors_buffer);
334+
Applicability::MachineApplicable,
335+
)
336+
.emit();
337337
}
338338
}
339339

src/test/ui/access-mode-in-closures.nll.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ note: move occurs because `v` has type `std::vec::Vec<isize>`, which does not im
1313
LL | match *s { sty(v) => v } //~ ERROR cannot move out
1414
| ^
1515

16-
error: aborting due to previous error
16+
error[E0507]: cannot move out of `s.0` which is behind a `&` reference
17+
--> $DIR/access-mode-in-closures.rs:19:24
18+
|
19+
LL | let _foo = unpack(|s| {
20+
| - help: consider changing this to be a mutable reference: `&mut sty`
21+
LL | // Test that `s` is moved here.
22+
LL | match *s { sty(v) => v } //~ ERROR cannot move out
23+
| ^
24+
| |
25+
| cannot move out of `s.0` which is behind a `&` reference
26+
| `s` is a `&` reference, so the data it refers to cannot be moved
27+
28+
error: aborting due to 2 previous errors
1729

1830
For more information about this error, try `rustc --explain E0507`.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 20 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/test/ui/binop/binop-move-semantics.nll.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ error[E0507]: cannot move out of borrowed content
3232
LL | *n; //~ ERROR: cannot move out of borrowed content
3333
| ^^ cannot move out of borrowed content
3434

35+
error[E0507]: cannot move out of `*n` which is behind a `&` reference
36+
--> $DIR/binop-move-semantics.rs:42:5
37+
|
38+
LL | let n = &y;
39+
| -- help: consider changing this to be a mutable reference: `&mut y`
40+
...
41+
LL | *n; //~ ERROR: cannot move out of borrowed content
42+
| ^^
43+
| |
44+
| cannot move out of `*n` which is behind a `&` reference
45+
| `n` is a `&` reference, so the data it refers to cannot be moved
46+
3547
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
3648
--> $DIR/binop-move-semantics.rs:64:5
3749
|
@@ -62,7 +74,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b
6274
| | immutable borrow later used here
6375
| mutable borrow occurs here
6476

65-
error: aborting due to 6 previous errors
77+
error: aborting due to 7 previous errors
6678

6779
Some errors occurred: E0382, E0502, E0507.
6880
For more information about an error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)