Skip to content

Commit 22b2bd8

Browse files
committed
Update migrate warning wording.
This commit modifies the wording of the warning for backwards-incompatible changes in migrate mode. The warning messages are changed to be lowercase and not include line-breaks in order to be consistent with other compiler diagnostics.
1 parent 6d34ec1 commit 22b2bd8

16 files changed

+52
-61
lines changed

src/librustc_mir/borrow_check/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,14 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
373373
for err in &mut mbcx.errors_buffer {
374374
if err.is_error() {
375375
err.level = Level::Warning;
376-
err.warn("This error has been downgraded to a warning \
377-
for backwards compatibility with previous releases.\n\
378-
It represents potential unsoundness in your code.\n\
379-
This warning will become a hard error in the future.");
376+
err.warn(
377+
"this error has been downgraded to a warning for backwards \
378+
compatibility with previous releases",
379+
);
380+
err.warn(
381+
"this represents potential undefined behavior in your code and \
382+
this warning will become a hard error in the future",
383+
);
380384
}
381385
}
382386
}

src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ LL | Foo::Y(_, ref mut b) => b,
1010
LL | *a += 1;
1111
| ------- borrow later used here
1212
|
13-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
14-
It represents potential unsoundness in your code.
15-
This warning will become a hard error in the future.
13+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
14+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1615

1716
error[E0503]: cannot use `y` because it was mutably borrowed
1817
--> $DIR/borrowck-anon-fields-variant.rs:44:7

src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,8 @@ LL | let p: &'a u8 = &*block.current;
350350
LL | drop(x);
351351
| - mutable borrow later used here
352352
|
353-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
354-
It represents potential unsoundness in your code.
355-
This warning will become a hard error in the future.
353+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
354+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
356355

357356
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
358357
--> $DIR/borrowck-describe-lvalue.rs:260:33
@@ -365,9 +364,8 @@ LL | let p : *const u8 = &*(*block).current;
365364
LL | drop(x);
366365
| - mutable borrow later used here
367366
|
368-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
369-
It represents potential unsoundness in your code.
370-
This warning will become a hard error in the future.
367+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
368+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
371369

372370
error[E0382]: use of moved value: `x`
373371
--> $DIR/borrowck-describe-lvalue.rs:318:22

src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ warning[E0507]: cannot move out of borrowed content
44
LL | (|| { let bar = foo; bar.take() })();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
66
|
7-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
8-
It represents potential unsoundness in your code.
9-
This warning will become a hard error in the future.
7+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
8+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
109

src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ warning[E0507]: cannot move out of borrowed content
44
LL | (|| { let bar = foo; bar.take() })();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
66
|
7-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
8-
It represents potential unsoundness in your code.
9-
This warning will become a hard error in the future.
7+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
8+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
109

src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
199199
| |temporary value created here
200200
| returns a reference to data owned by the current function
201201
|
202-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
203-
It represents potential unsoundness in your code.
204-
This warning will become a hard error in the future.
202+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
203+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
205204

206205
error: trait bounds other than `Sized` on const fn parameters are unstable
207206
--> $DIR/min_const_fn.rs:147:41

src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
1919
| |creates a temporary which is freed while still in use
2020
| cast requires that borrow lasts for `'static`
2121
|
22-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
23-
It represents potential unsoundness in your code.
24-
This warning will become a hard error in the future.
22+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
23+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
2524

2625
error: aborting due to 2 previous errors
2726

src/test/ui/issues/issue-40510-1.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ LL | &mut x
88
|
99
= note: `FnMut` closures only have access to their captured variables while they are executing...
1010
= note: ...therefore, they cannot allow references to captured variables to escape
11-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
12-
It represents potential unsoundness in your code.
13-
This warning will become a hard error in the future.
11+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
12+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1413

src/test/ui/issues/issue-40510-3.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ LL | | }
1010
|
1111
= note: `FnMut` closures only have access to their captured variables while they are executing...
1212
= note: ...therefore, they cannot allow references to captured variables to escape
13-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
14-
It represents potential unsoundness in your code.
15-
This warning will become a hard error in the future.
13+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
14+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1615

src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: compilation successful
2-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:89:1
2+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:92:1
33
|
44
LL | / fn main() { //[ast]~ ERROR compilation successful
55
LL | | //[migrate]~^ ERROR compilation successful

src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr

+9-12
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ LL | &mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor run
99
LL | }
1010
| - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
1111
|
12-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
13-
It represents potential unsoundness in your code.
14-
This warning will become a hard error in the future.
12+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
13+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1514

1615
warning[E0713]: borrow may still be in use when destructor runs
17-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5
16+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:74:5
1817
|
1918
LL | fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
2019
| -- lifetime `'a` defined here
@@ -24,12 +23,11 @@ LL | &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor
2423
LL | }
2524
| - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
2625
|
27-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
28-
It represents potential unsoundness in your code.
29-
This warning will become a hard error in the future.
26+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
27+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
3028

3129
warning[E0713]: borrow may still be in use when destructor runs
32-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:83:5
30+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:85:5
3331
|
3432
LL | fn boxed_boxed_scribbled<'a>(s: Box<Box<Scribble<'a>>>) -> &'a mut u32 {
3533
| -- lifetime `'a` defined here
@@ -39,12 +37,11 @@ LL | &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor
3937
LL | }
4038
| - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
4139
|
42-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
43-
It represents potential unsoundness in your code.
44-
This warning will become a hard error in the future.
40+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
41+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
4542

4643
error: compilation successful
47-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:89:1
44+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:92:1
4845
|
4946
LL | / fn main() { //[ast]~ ERROR compilation successful
5047
LL | | //[migrate]~^ ERROR compilation successful

src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | }
1010
| - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
1111

1212
error[E0713]: borrow may still be in use when destructor runs
13-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5
13+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:74:5
1414
|
1515
LL | fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
1616
| -- lifetime `'a` defined here
@@ -21,7 +21,7 @@ LL | }
2121
| - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait
2222

2323
error[E0713]: borrow may still be in use when destructor runs
24-
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:83:5
24+
--> $DIR/issue-45696-scribble-on-boxed-borrow.rs:85:5
2525
|
2626
LL | fn boxed_boxed_scribbled<'a>(s: Box<Box<Scribble<'a>>>) -> &'a mut u32 {
2727
| -- lifetime `'a` defined here

src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ fn boxed_boxed_borrowed_scribble<'a>(s: Box<Box<&'a mut Scribble>>) -> &'a mut u
6262
fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 {
6363
&mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
6464
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
65-
//[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
65+
//[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
66+
//[migrate]~| WARNING this represents potential undefined behavior in your code
6667
}
6768

6869
// This, by analogy to previous case, is *also* not okay.
@@ -72,7 +73,8 @@ fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 {
7273
fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
7374
&mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
7475
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
75-
//[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
76+
//[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
77+
//[migrate]~| WARNING this represents potential undefined behavior in your code
7678
}
7779

7880
// This, by analogy to previous case, is *also* not okay.
@@ -82,7 +84,8 @@ fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
8284
fn boxed_boxed_scribbled<'a>(s: Box<Box<Scribble<'a>>>) -> &'a mut u32 {
8385
&mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
8486
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
85-
//[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
87+
//[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
88+
//[migrate]~| WARNING this represents potential undefined behavior in your code
8689
}
8790

8891
#[rustc_error]

src/test/ui/issues/issue-49824.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ LL | | }
1010
|
1111
= note: `FnMut` closures only have access to their captured variables while they are executing...
1212
= note: ...therefore, they cannot allow references to captured variables to escape
13-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
14-
It represents potential unsoundness in your code.
15-
This warning will become a hard error in the future.
13+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
14+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
1615

1716
error: compilation successful
1817
--> $DIR/issue-49824.rs:18:1

src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ warning[E0507]: cannot move out of borrowed content
44
LL | (|| { let bar = foo; bar.take() })();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
66
|
7-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
8-
It represents potential unsoundness in your code.
9-
This warning will become a hard error in the future.
7+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
8+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
109

1110
error: compilation successful
1211
--> $DIR/match-guards-always-borrow.rs:57:1

src/test/ui/thread-local-in-ctfe.nll.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ LL | static C: &u32 = &A;
1818
| |
1919
| thread-local variables cannot be borrowed beyond the end of the function
2020
|
21-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
22-
It represents potential unsoundness in your code.
23-
This warning will become a hard error in the future.
21+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
22+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
2423

2524
error[E0625]: thread-local statics cannot be accessed at compile-time
2625
--> $DIR/thread-local-in-ctfe.rs:22:16
@@ -42,9 +41,8 @@ LL | const E: &u32 = &A;
4241
| |
4342
| thread-local variables cannot be borrowed beyond the end of the function
4443
|
45-
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
46-
It represents potential unsoundness in your code.
47-
This warning will become a hard error in the future.
44+
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
45+
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
4846

4947
error[E0625]: thread-local statics cannot be accessed at compile-time
5048
--> $DIR/thread-local-in-ctfe.rs:29:5

0 commit comments

Comments
 (0)