Skip to content

Commit f45f525

Browse files
committed
Auto merge of #53196 - davidtwco:compile-fail-to-ui, r=nikomatsakis
Move `compile-fail` tests to `ui` Fixes #46841, #52531, #44844. r? @nikomatsakis
2 parents d67ba90 + 7b02656 commit f45f525

File tree

6,539 files changed

+59549
-77
lines changed

Some content is hidden

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

6,539 files changed

+59549
-77
lines changed

src/librustc/traits/error_reporting.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
435435
}
436436

437437
fn report_similar_impl_candidates(&self,
438-
impl_candidates: Vec<ty::TraitRef<'tcx>>,
438+
mut impl_candidates: Vec<ty::TraitRef<'tcx>>,
439439
err: &mut DiagnosticBuilder)
440440
{
441441
if impl_candidates.is_empty() {
442442
return;
443443
}
444444

445+
let len = impl_candidates.len();
445446
let end = if impl_candidates.len() <= 5 {
446447
impl_candidates.len()
447448
} else {
@@ -459,10 +460,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
459460
}
460461
});
461462

463+
// Sort impl candidates so that ordering is consistent for UI tests.
464+
let normalized_impl_candidates = &mut impl_candidates[0..end]
465+
.iter()
466+
.map(normalize)
467+
.collect::<Vec<String>>();
468+
normalized_impl_candidates.sort();
469+
462470
err.help(&format!("the following implementations were found:{}{}",
463-
&impl_candidates[0..end].iter().map(normalize).collect::<String>(),
464-
if impl_candidates.len() > 5 {
465-
format!("\nand {} others", impl_candidates.len() - 4)
471+
normalized_impl_candidates.join(""),
472+
if len > 5 {
473+
format!("\nand {} others", len - 4)
466474
} else {
467475
"".to_owned()
468476
}

src/test/compile-fail/meta-expected-error-wrong-rev.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-compare-mode-nll
12+
1113
// revisions: a
1214
// should-fail
1315

File renamed without changes.

src/test/ui/E0501.ast.nll.stderr

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
2+
--> $DIR/E0501.rs:28:23
3+
|
4+
LL | let bar = || {
5+
| -- closure construction occurs here
6+
LL | inside_closure(a)
7+
| - first borrow occurs due to use of `a` in closure
8+
LL | };
9+
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
10+
| ^ borrow occurs here
11+
...
12+
LL | drop(bar);
13+
| --- borrow later used here
14+
15+
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
16+
--> $DIR/E0501.rs:31:23
17+
|
18+
LL | let bar = || {
19+
| -- closure construction occurs here
20+
LL | inside_closure(a)
21+
| - first borrow occurs due to use of `a` in closure
22+
...
23+
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
24+
| ^ borrow occurs here
25+
...
26+
LL | drop(bar);
27+
| --- borrow later used here
28+
29+
error: aborting due to 2 previous errors
30+
31+
For more information about this error, try `rustc --explain E0501`.

src/test/ui/E0501.ast.stderr

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
2+
--> $DIR/E0501.rs:28:23
3+
|
4+
LL | let bar = || {
5+
| -- closure construction occurs here
6+
LL | inside_closure(a)
7+
| - previous borrow occurs due to use of `a` in closure
8+
LL | };
9+
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
10+
| ^ borrow occurs here
11+
...
12+
LL | }
13+
| - borrow from closure ends here
14+
15+
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
16+
--> $DIR/E0501.rs:31:23
17+
|
18+
LL | let bar = || {
19+
| -- closure construction occurs here
20+
LL | inside_closure(a)
21+
| - previous borrow occurs due to use of `a` in closure
22+
...
23+
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
24+
| ^ borrow occurs here
25+
...
26+
LL | }
27+
| - borrow from closure ends here
28+
29+
error: aborting due to 2 previous errors
30+
31+
For more information about this error, try `rustc --explain E0501`.

src/test/ui/E0501.mir.stderr

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access
2+
--> $DIR/E0501.rs:28:23
3+
|
4+
LL | let bar = || {
5+
| -- closure construction occurs here
6+
LL | inside_closure(a)
7+
| - first borrow occurs due to use of `a` in closure
8+
LL | };
9+
LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access
10+
| ^ borrow occurs here
11+
...
12+
LL | drop(bar);
13+
| --- borrow later used here
14+
15+
error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access
16+
--> $DIR/E0501.rs:31:23
17+
|
18+
LL | let bar = || {
19+
| -- closure construction occurs here
20+
LL | inside_closure(a)
21+
| - first borrow occurs due to use of `a` in closure
22+
...
23+
LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access
24+
| ^ borrow occurs here
25+
...
26+
LL | drop(bar);
27+
| --- borrow later used here
28+
29+
error: aborting due to 2 previous errors
30+
31+
For more information about this error, try `rustc --explain E0501`.
File renamed without changes.

src/test/ui/E0506.ast.nll.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0506]: cannot assign to `fancy_num` because it is borrowed
2+
--> $DIR/E0506.rs:21:5
3+
|
4+
LL | let fancy_ref = &fancy_num;
5+
| ---------- borrow of `fancy_num` occurs here
6+
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
8+
...
9+
LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
10+
| ------------- borrow later used here
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0506`.

src/test/ui/E0506.ast.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0506]: cannot assign to `fancy_num` because it is borrowed
2+
--> $DIR/E0506.rs:21:5
3+
|
4+
LL | let fancy_ref = &fancy_num;
5+
| --------- borrow of `fancy_num` occurs here
6+
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0506`.

src/test/ui/E0506.mir.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0506]: cannot assign to `fancy_num` because it is borrowed
2+
--> $DIR/E0506.rs:21:5
3+
|
4+
LL | let fancy_ref = &fancy_num;
5+
| ---------- borrow of `fancy_num` occurs here
6+
LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here
8+
...
9+
LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
10+
| ------------- borrow later used here
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0506`.
File renamed without changes.

src/test/ui/E0508-fail.ast.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
2+
--> $DIR/E0508-fail.rs:18:18
3+
|
4+
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
5+
| ^^^^^^^^
6+
| |
7+
| cannot move out of here
8+
| help: consider using a reference instead: `&array[0]`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0508`.

src/test/ui/E0508-fail.mir.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
2+
--> $DIR/E0508-fail.rs:18:18
3+
|
4+
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
5+
| ^^^^^^^^
6+
| |
7+
| cannot move out of here
8+
| help: consider using a reference instead: `&array[0]`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0508`.
File renamed without changes.

src/test/ui/E0508.ast.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
2+
--> $DIR/E0508.rs:18:18
3+
|
4+
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
5+
| ^^^^^^^^
6+
| |
7+
| cannot move out of here
8+
| help: consider using a reference instead: `&array[0]`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0508`.

src/test/ui/E0508.mir.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
2+
--> $DIR/E0508.rs:18:18
3+
|
4+
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
5+
| ^^^^^^^^
6+
| |
7+
| cannot move out of here
8+
| help: consider using a reference instead: `&array[0]`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0508`.
File renamed without changes.

src/test/ui/E0583.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0583]: file not found for module `module_that_doesnt_exist`
2+
--> $DIR/E0583.rs:11:5
3+
|
4+
LL | mod module_that_doesnt_exist; //~ ERROR E0583
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: name the file either module_that_doesnt_exist.rs or module_that_doesnt_exist/mod.rs inside the directory "$DIR"
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0583`.

src/test/ui/E0594.ast.nll.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0594]: cannot assign to immutable static item `NUM`
2+
--> $DIR/E0594.rs:17:5
3+
|
4+
LL | NUM = 20; //[ast]~ ERROR E0594
5+
| ^^^^^^^^ cannot assign
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0594`.

src/test/ui/E0594.ast.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0594]: cannot assign to immutable static item
2+
--> $DIR/E0594.rs:17:5
3+
|
4+
LL | NUM = 20; //[ast]~ ERROR E0594
5+
| ^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0594`.

src/test/ui/E0594.mir.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0594]: cannot assign to immutable static item `NUM`
2+
--> $DIR/E0594.rs:17:5
3+
|
4+
LL | NUM = 20; //[ast]~ ERROR E0594
5+
| ^^^^^^^^ cannot assign
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0594`.
File renamed without changes.

src/test/ui/E0596.ast.nll.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2+
--> $DIR/E0596.rs:16:13
3+
|
4+
LL | let x = 1;
5+
| - help: consider changing this to be mutable: `mut x`
6+
LL | let y = &mut x; //[ast]~ ERROR [E0596]
7+
| ^^^^^^ cannot borrow as mutable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0596`.

src/test/ui/E0596.ast.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0596]: cannot borrow immutable local variable `x` as mutable
2+
--> $DIR/E0596.rs:16:18
3+
|
4+
LL | let x = 1;
5+
| - consider changing this to `mut x`
6+
LL | let y = &mut x; //[ast]~ ERROR [E0596]
7+
| ^ cannot borrow mutably
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0596`.

src/test/ui/E0596.mir.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2+
--> $DIR/E0596.rs:16:13
3+
|
4+
LL | let x = 1;
5+
| - help: consider changing this to be mutable: `mut x`
6+
LL | let y = &mut x; //[ast]~ ERROR [E0596]
7+
| ^^^^^^ cannot borrow as mutable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0596`.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0433]: failed to resolve. crate root in paths can only be used in start position
2+
--> $DIR/absolute-paths-in-nested-use-groups.rs:16:5
3+
|
4+
LL | ::bar, //~ ERROR crate root in paths can only be used in start position
5+
| ^ crate root in paths can only be used in start position
6+
7+
error[E0433]: failed to resolve. `super` in paths can only be used in start position
8+
--> $DIR/absolute-paths-in-nested-use-groups.rs:17:5
9+
|
10+
LL | super::bar, //~ ERROR `super` in paths can only be used in start position
11+
| ^^^^^ `super` in paths can only be used in start position
12+
13+
error[E0433]: failed to resolve. `self` in paths can only be used in start position
14+
--> $DIR/absolute-paths-in-nested-use-groups.rs:18:5
15+
|
16+
LL | self::bar, //~ ERROR `self` in paths can only be used in start position
17+
| ^^^^ `self` in paths can only be used in start position
18+
19+
error: aborting due to 3 previous errors
20+
21+
For more information about this error, try `rustc --explain E0433`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0507]: cannot move out of borrowed content
2+
--> $DIR/access-mode-in-closures.rs:19:15
3+
|
4+
LL | match *s { sty(v) => v } //~ ERROR cannot move out
5+
| ^^ - move occurs because v has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
6+
| |
7+
| cannot move out of borrowed content
8+
| help: consider removing this dereference operator: `s`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0507`.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0507]: cannot move out of borrowed content
2+
--> $DIR/access-mode-in-closures.rs:19:15
3+
|
4+
LL | match *s { sty(v) => v } //~ ERROR cannot move out
5+
| ^^ - hint: to prevent move, use `ref v` or `ref mut v`
6+
| |
7+
| cannot move out of borrowed content
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0507`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: return type should be `!`
2+
--> $DIR/alloc-error-handler-bad-signature-1.rs:22:6
3+
|
4+
LL | ) -> () //~ ERROR return type should be `!`
5+
| ^^
6+
7+
error: argument should be `Layout`
8+
--> $DIR/alloc-error-handler-bad-signature-1.rs:21:11
9+
|
10+
LL | info: &Layout, //~ ERROR argument should be `Layout`
11+
| ^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: return type should be `!`
2+
--> $DIR/alloc-error-handler-bad-signature-2.rs:22:3
3+
|
4+
LL | ) { //~ ERROR return type should be `!`
5+
| ^
6+
7+
error: argument should be `Layout`
8+
--> $DIR/alloc-error-handler-bad-signature-2.rs:21:11
9+
|
10+
LL | info: Layout, //~ ERROR argument should be `Layout`
11+
| ^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)