Skip to content

Commit f77c183

Browse files
committed
Report all lints, even if other errors already occurred.
This reduces surprises of the "I fixed all the errors, now I'm getting new ones"-kind
1 parent 4d941cd commit f77c183

File tree

91 files changed

+1122
-375
lines changed

Some content is hidden

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

91 files changed

+1122
-375
lines changed

compiler/rustc_interface/src/passes.rs

-9
Original file line numberDiff line numberDiff line change
@@ -790,15 +790,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
790790

791791
sess.time("layout_testing", || layout_test::test_layout(tcx));
792792

793-
// Avoid overwhelming user with errors if borrow checking failed.
794-
// I'm not sure how helpful this is, to be honest, but it avoids a
795-
// lot of annoying errors in the ui tests (basically,
796-
// lint warnings and so on -- kindck used to do this abort, but
797-
// kindck is gone now). -nmatsakis
798-
if let Some(reported) = sess.has_errors() {
799-
return Err(reported);
800-
}
801-
802793
sess.time("misc_checking_3", || {
803794
parallel!(
804795
{

tests/ui/borrowck/borrowck-access-permissions.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
1-
static static_x : i32 = 1;
2-
static mut static_x_mut : i32 = 1;
1+
static STATIC_X: i32 = 1;
2+
static mut STATIC_X_MUT: i32 = 1;
33

44
fn main() {
55
let x = 1;
66
let mut x_mut = 1;
77

8-
{ // borrow of local
8+
{
9+
// borrow of local
910
let _y1 = &mut x; //~ ERROR [E0596]
1011
let _y2 = &mut x_mut; // No error
1112
}
1213

13-
{ // borrow of static
14-
let _y1 = &mut static_x; //~ ERROR [E0596]
15-
unsafe { let _y2 = &mut static_x_mut; } // No error
14+
{
15+
// borrow of static
16+
let _y1 = &mut STATIC_X; //~ ERROR [E0596]
17+
unsafe {
18+
let _y2 = &mut STATIC_X_MUT;
19+
} // No error
1620
}
1721

18-
{ // borrow of deref to box
22+
{
23+
// borrow of deref to box
1924
let box_x = Box::new(1);
2025
let mut box_x_mut = Box::new(1);
2126

2227
let _y1 = &mut *box_x; //~ ERROR [E0596]
2328
let _y2 = &mut *box_x_mut; // No error
2429
}
2530

26-
{ // borrow of deref to reference
31+
{
32+
// borrow of deref to reference
2733
let ref_x = &x;
2834
let ref_x_mut = &mut x_mut;
2935

3036
let _y1 = &mut *ref_x; //~ ERROR [E0596]
3137
let _y2 = &mut *ref_x_mut; // No error
3238
}
3339

34-
{ // borrow of deref to pointer
35-
let ptr_x : *const _ = &x;
36-
let ptr_mut_x : *mut _ = &mut x_mut;
40+
{
41+
// borrow of deref to pointer
42+
let ptr_x: *const _ = &x;
43+
let ptr_mut_x: *mut _ = &mut x_mut;
3744

3845
unsafe {
3946
let _y1 = &mut *ptr_x; //~ ERROR [E0596]
4047
let _y2 = &mut *ptr_mut_x; // No error
4148
}
4249
}
4350

44-
{ // borrowing mutably through an immutable reference
45-
struct Foo<'a> { f: &'a mut i32, g: &'a i32 };
51+
{
52+
// borrowing mutably through an immutable reference
53+
struct Foo<'a> {
54+
f: &'a mut i32,
55+
g: &'a i32,
56+
};
4657
let mut foo = Foo { f: &mut x_mut, g: &x };
4758
let foo_ref = &foo;
4859
let _y = &mut *foo_ref.f; //~ ERROR [E0596]

tests/ui/borrowck/borrowck-access-permissions.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2-
--> $DIR/borrowck-access-permissions.rs:9:19
2+
--> $DIR/borrowck-access-permissions.rs:10:19
33
|
44
LL | let _y1 = &mut x;
55
| ^^^^^^ cannot borrow as mutable
@@ -9,14 +9,14 @@ help: consider changing this to be mutable
99
LL | let mut x = 1;
1010
| +++
1111

12-
error[E0596]: cannot borrow immutable static item `static_x` as mutable
13-
--> $DIR/borrowck-access-permissions.rs:14:19
12+
error[E0596]: cannot borrow immutable static item `STATIC_X` as mutable
13+
--> $DIR/borrowck-access-permissions.rs:16:19
1414
|
15-
LL | let _y1 = &mut static_x;
15+
LL | let _y1 = &mut STATIC_X;
1616
| ^^^^^^^^^^^^^ cannot borrow as mutable
1717

1818
error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable
19-
--> $DIR/borrowck-access-permissions.rs:22:19
19+
--> $DIR/borrowck-access-permissions.rs:27:19
2020
|
2121
LL | let _y1 = &mut *box_x;
2222
| ^^^^^^^^^^^ cannot borrow as mutable
@@ -27,7 +27,7 @@ LL | let mut box_x = Box::new(1);
2727
| +++
2828

2929
error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference
30-
--> $DIR/borrowck-access-permissions.rs:30:19
30+
--> $DIR/borrowck-access-permissions.rs:36:19
3131
|
3232
LL | let _y1 = &mut *ref_x;
3333
| ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
@@ -38,18 +38,18 @@ LL | let ref_x = &mut x;
3838
| +++
3939

4040
error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
41-
--> $DIR/borrowck-access-permissions.rs:39:23
41+
--> $DIR/borrowck-access-permissions.rs:46:23
4242
|
4343
LL | let _y1 = &mut *ptr_x;
4444
| ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
4545
|
4646
help: consider changing this to be a mutable pointer
4747
|
48-
LL | let ptr_x : *const _ = &mut x;
49-
| +++
48+
LL | let ptr_x: *const _ = &mut x;
49+
| +++
5050

5151
error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
52-
--> $DIR/borrowck-access-permissions.rs:48:18
52+
--> $DIR/borrowck-access-permissions.rs:59:18
5353
|
5454
LL | let _y = &mut *foo_ref.f;
5555
| ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
static foo: isize = 5;
1+
static FOO: isize = 5;
22

33
fn main() {
44
// assigning to various global constants
5-
foo = 6; //~ ERROR cannot assign to immutable static item `foo`
5+
FOO = 6; //~ ERROR cannot assign to immutable static item `FOO`
66
}

tests/ui/borrowck/borrowck-assign-to-constants.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error[E0594]: cannot assign to immutable static item `foo`
1+
error[E0594]: cannot assign to immutable static item `FOO`
22
--> $DIR/borrowck-assign-to-constants.rs:5:5
33
|
4-
LL | foo = 6;
4+
LL | FOO = 6;
55
| ^^^^^^^ cannot assign
66

77
error: aborting due to previous error

tests/ui/borrowck/issue-64453.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
struct Project;
22
struct Value;
33

4-
static settings_dir: String = format!("");
4+
static SETTINGS_DIR: String = format!("");
55
//~^ ERROR cannot call non-const fn
66
//~| ERROR is not yet stable as a const
77

@@ -11,7 +11,7 @@ fn from_string(_: String) -> Value {
1111
fn set_editor(_: Value) {}
1212

1313
fn main() {
14-
let settings_data = from_string(settings_dir);
14+
let settings_data = from_string(SETTINGS_DIR);
1515
//~^ ERROR cannot move out of static item
1616
let args: i32 = 0;
1717

tests/ui/borrowck/issue-64453.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: `Arguments::<'a>::new_const` is not yet stable as a const fn
22
--> $DIR/issue-64453.rs:4:31
33
|
4-
LL | static settings_dir: String = format!("");
4+
LL | static SETTINGS_DIR: String = format!("");
55
| ^^^^^^^^^^^
66
|
77
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
@@ -10,18 +10,18 @@ LL | static settings_dir: String = format!("");
1010
error[E0015]: cannot call non-const fn `format` in statics
1111
--> $DIR/issue-64453.rs:4:31
1212
|
13-
LL | static settings_dir: String = format!("");
13+
LL | static SETTINGS_DIR: String = format!("");
1414
| ^^^^^^^^^^^
1515
|
1616
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
1717
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
1818
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
1919

20-
error[E0507]: cannot move out of static item `settings_dir`
20+
error[E0507]: cannot move out of static item `SETTINGS_DIR`
2121
--> $DIR/issue-64453.rs:14:37
2222
|
23-
LL | let settings_data = from_string(settings_dir);
24-
| ^^^^^^^^^^^^ move occurs because `settings_dir` has type `String`, which does not implement the `Copy` trait
23+
LL | let settings_data = from_string(SETTINGS_DIR);
24+
| ^^^^^^^^^^^^ move occurs because `SETTINGS_DIR` has type `String`, which does not implement the `Copy` trait
2525

2626
error: aborting due to 3 previous errors
2727

tests/ui/cleanup-rvalue-scopes-cf.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ use std::ops::Drop;
55

66
static mut FLAGS: u64 = 0;
77

8-
struct StackBox<T> { f: T }
9-
struct AddFlags { bits: u64 }
8+
struct StackBox<T> {
9+
f: T,
10+
}
11+
struct AddFlags {
12+
bits: u64,
13+
}
1014

11-
fn AddFlags(bits: u64) -> AddFlags {
15+
fn add_flags(bits: u64) -> AddFlags {
1216
AddFlags { bits: bits }
1317
}
1418

@@ -23,13 +27,13 @@ impl AddFlags {
2327
}
2428

2529
pub fn main() {
26-
let x1 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed
27-
let x2 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed
28-
let x3 = &*arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed
29-
let ref x4 = *arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed
30-
let &ref x5 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed
31-
let x6 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed
32-
let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() };
30+
let x1 = arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed
31+
let x2 = add_flags(1).get(); //~ ERROR temporary value dropped while borrowed
32+
let x3 = &*arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed
33+
let ref x4 = *arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed
34+
let &ref x5 = arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed
35+
let x6 = add_flags(1).get(); //~ ERROR temporary value dropped while borrowed
36+
let StackBox { f: x7 } = StackBox { f: add_flags(1).get() };
3337
//~^ ERROR temporary value dropped while borrowed
3438
(x1, x2, x3, x4, x5, x6, x7);
3539
}

tests/ui/cleanup-rvalue-scopes-cf.stderr

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/cleanup-rvalue-scopes-cf.rs:26:19
2+
--> $DIR/cleanup-rvalue-scopes-cf.rs:30:19
33
|
4-
LL | let x1 = arg(&AddFlags(1));
5-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
4+
LL | let x1 = arg(&add_flags(1));
5+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
66
| |
77
| creates a temporary value which is freed while still in use
88
...
@@ -11,15 +11,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
1111
|
1212
help: consider using a `let` binding to create a longer lived value
1313
|
14-
LL ~ let binding = AddFlags(1);
14+
LL ~ let binding = add_flags(1);
1515
LL ~ let x1 = arg(&binding);
1616
|
1717

1818
error[E0716]: temporary value dropped while borrowed
19-
--> $DIR/cleanup-rvalue-scopes-cf.rs:27:14
19+
--> $DIR/cleanup-rvalue-scopes-cf.rs:31:14
2020
|
21-
LL | let x2 = AddFlags(1).get();
22-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
21+
LL | let x2 = add_flags(1).get();
22+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
2323
| |
2424
| creates a temporary value which is freed while still in use
2525
...
@@ -28,15 +28,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
2828
|
2929
help: consider using a `let` binding to create a longer lived value
3030
|
31-
LL ~ let binding = AddFlags(1);
31+
LL ~ let binding = add_flags(1);
3232
LL ~ let x2 = binding.get();
3333
|
3434

3535
error[E0716]: temporary value dropped while borrowed
36-
--> $DIR/cleanup-rvalue-scopes-cf.rs:28:21
36+
--> $DIR/cleanup-rvalue-scopes-cf.rs:32:21
3737
|
38-
LL | let x3 = &*arg(&AddFlags(1));
39-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
38+
LL | let x3 = &*arg(&add_flags(1));
39+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
4040
| |
4141
| creates a temporary value which is freed while still in use
4242
...
@@ -45,15 +45,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
4545
|
4646
help: consider using a `let` binding to create a longer lived value
4747
|
48-
LL ~ let binding = AddFlags(1);
48+
LL ~ let binding = add_flags(1);
4949
LL ~ let x3 = &*arg(&binding);
5050
|
5151

5252
error[E0716]: temporary value dropped while borrowed
53-
--> $DIR/cleanup-rvalue-scopes-cf.rs:29:24
53+
--> $DIR/cleanup-rvalue-scopes-cf.rs:33:24
5454
|
55-
LL | let ref x4 = *arg(&AddFlags(1));
56-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
55+
LL | let ref x4 = *arg(&add_flags(1));
56+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
5757
| |
5858
| creates a temporary value which is freed while still in use
5959
...
@@ -62,15 +62,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
6262
|
6363
help: consider using a `let` binding to create a longer lived value
6464
|
65-
LL ~ let binding = AddFlags(1);
65+
LL ~ let binding = add_flags(1);
6666
LL ~ let ref x4 = *arg(&binding);
6767
|
6868

6969
error[E0716]: temporary value dropped while borrowed
70-
--> $DIR/cleanup-rvalue-scopes-cf.rs:30:24
70+
--> $DIR/cleanup-rvalue-scopes-cf.rs:34:24
7171
|
72-
LL | let &ref x5 = arg(&AddFlags(1));
73-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
72+
LL | let &ref x5 = arg(&add_flags(1));
73+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
7474
| |
7575
| creates a temporary value which is freed while still in use
7676
...
@@ -79,15 +79,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
7979
|
8080
help: consider using a `let` binding to create a longer lived value
8181
|
82-
LL ~ let binding = AddFlags(1);
82+
LL ~ let binding = add_flags(1);
8383
LL ~ let &ref x5 = arg(&binding);
8484
|
8585

8686
error[E0716]: temporary value dropped while borrowed
87-
--> $DIR/cleanup-rvalue-scopes-cf.rs:31:14
87+
--> $DIR/cleanup-rvalue-scopes-cf.rs:35:14
8888
|
89-
LL | let x6 = AddFlags(1).get();
90-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
89+
LL | let x6 = add_flags(1).get();
90+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
9191
| |
9292
| creates a temporary value which is freed while still in use
9393
...
@@ -96,15 +96,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
9696
|
9797
help: consider using a `let` binding to create a longer lived value
9898
|
99-
LL ~ let binding = AddFlags(1);
99+
LL ~ let binding = add_flags(1);
100100
LL ~ let x6 = binding.get();
101101
|
102102

103103
error[E0716]: temporary value dropped while borrowed
104-
--> $DIR/cleanup-rvalue-scopes-cf.rs:32:44
104+
--> $DIR/cleanup-rvalue-scopes-cf.rs:36:44
105105
|
106-
LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() };
107-
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
106+
LL | let StackBox { f: x7 } = StackBox { f: add_flags(1).get() };
107+
| ^^^^^^^^^^^^ - temporary value is freed at the end of this statement
108108
| |
109109
| creates a temporary value which is freed while still in use
110110
LL |
@@ -113,7 +113,7 @@ LL | (x1, x2, x3, x4, x5, x6, x7);
113113
|
114114
help: consider using a `let` binding to create a longer lived value
115115
|
116-
LL ~ let binding = AddFlags(1);
116+
LL ~ let binding = add_flags(1);
117117
LL ~ let StackBox { f: x7 } = StackBox { f: binding.get() };
118118
|
119119

0 commit comments

Comments
 (0)