Auto merge of #87600 - JohnTitor:classify-ui-tests, r=petrochenkov
Move some UI tests to more suitable subdirs The classifui result: https://gist.github.com/JohnTitor/c9e00840990b5e4a8fc562ec3571e427/e06c42226c6038da91e403c33b9947843420cf44 Some notes: - backtrace-debuginfo.rs: previously I skipped this, I'm still not sure what the best dir is. Any ideas? - estr-subtyping.rs: Seems a quite old test so removed, shouldn't? - deref-suggestion.rs: moved to inference as `suggestions` is not an ideal dir. - issue-43023.rs: a bit misclassified, moved to `derives` cc #73494 r? `@petrochenkov`
This commit is contained in:
commit
fa2692990c
10 changed files with 1 additions and 27 deletions
74
src/test/ui/inference/deref-suggestion.rs
Normal file
74
src/test/ui/inference/deref-suggestion.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
macro_rules! borrow {
|
||||
($x:expr) => { &$x } //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn foo(_: String) {}
|
||||
|
||||
fn foo2(s: &String) {
|
||||
foo(s);
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn foo3(_: u32) {}
|
||||
fn foo4(u: &u32) {
|
||||
foo3(u);
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
struct S<'a> {
|
||||
u: &'a u32,
|
||||
}
|
||||
|
||||
struct R {
|
||||
i: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = String::new();
|
||||
let r_s = &s;
|
||||
foo2(r_s);
|
||||
foo(&"aaa".to_owned());
|
||||
//~^ ERROR mismatched types
|
||||
foo(&mut "aaa".to_owned());
|
||||
//~^ ERROR mismatched types
|
||||
foo3(borrow!(0));
|
||||
foo4(&0);
|
||||
assert_eq!(3i32, &3i32);
|
||||
//~^ ERROR mismatched types
|
||||
let u = 3;
|
||||
let s = S { u };
|
||||
//~^ ERROR mismatched types
|
||||
let s = S { u: u };
|
||||
//~^ ERROR mismatched types
|
||||
let i = &4;
|
||||
let r = R { i };
|
||||
//~^ ERROR mismatched types
|
||||
let r = R { i: i };
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
|
||||
let a = &1;
|
||||
let b = &2;
|
||||
let val: i32 = if true {
|
||||
a + 1
|
||||
} else {
|
||||
b
|
||||
//~^ ERROR mismatched types
|
||||
};
|
||||
let val: i32 = if true {
|
||||
let _ = 2;
|
||||
a + 1
|
||||
} else {
|
||||
let _ = 2;
|
||||
b
|
||||
//~^ ERROR mismatched types
|
||||
};
|
||||
let val = if true {
|
||||
*a
|
||||
} else if true {
|
||||
//~^ ERROR incompatible types
|
||||
b
|
||||
} else {
|
||||
&0
|
||||
};
|
||||
}
|
||||
146
src/test/ui/inference/deref-suggestion.stderr
Normal file
146
src/test/ui/inference/deref-suggestion.stderr
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:8:9
|
||||
|
|
||||
LL | foo(s);
|
||||
| ^- help: try using a conversion method: `.to_string()`
|
||||
| |
|
||||
| expected struct `String`, found `&String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:14:10
|
||||
|
|
||||
LL | foo3(u);
|
||||
| ^ expected `u32`, found `&u32`
|
||||
|
|
||||
help: consider dereferencing the borrow
|
||||
|
|
||||
LL | foo3(*u);
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:30:9
|
||||
|
|
||||
LL | foo(&"aaa".to_owned());
|
||||
| ^^^^^^^^^^^^^^^^^ expected struct `String`, found `&String`
|
||||
|
|
||||
help: consider removing the borrow
|
||||
|
|
||||
LL - foo(&"aaa".to_owned());
|
||||
LL + foo("aaa".to_owned());
|
||||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:32:9
|
||||
|
|
||||
LL | foo(&mut "aaa".to_owned());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected struct `String`, found `&mut String`
|
||||
|
|
||||
help: consider removing the borrow
|
||||
|
|
||||
LL - foo(&mut "aaa".to_owned());
|
||||
LL + foo("aaa".to_owned());
|
||||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:2:20
|
||||
|
|
||||
LL | ($x:expr) => { &$x }
|
||||
| ^^^ expected `u32`, found `&{integer}`
|
||||
...
|
||||
LL | foo3(borrow!(0));
|
||||
| ---------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `borrow` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:36:5
|
||||
|
|
||||
LL | assert_eq!(3i32, &3i32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `&i32`
|
||||
|
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:39:17
|
||||
|
|
||||
LL | let s = S { u };
|
||||
| ^
|
||||
| |
|
||||
| expected `&u32`, found integer
|
||||
| help: consider borrowing here: `u: &u`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:41:20
|
||||
|
|
||||
LL | let s = S { u: u };
|
||||
| ^
|
||||
| |
|
||||
| expected `&u32`, found integer
|
||||
| help: consider borrowing here: `&u`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:44:17
|
||||
|
|
||||
LL | let r = R { i };
|
||||
| ^ expected `u32`, found `&{integer}`
|
||||
|
|
||||
help: consider dereferencing the borrow
|
||||
|
|
||||
LL | let r = R { i: *i };
|
||||
| ~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:46:20
|
||||
|
|
||||
LL | let r = R { i: i };
|
||||
| ^ expected `u32`, found `&{integer}`
|
||||
|
|
||||
help: consider dereferencing the borrow
|
||||
|
|
||||
LL | let r = R { i: *i };
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:55:9
|
||||
|
|
||||
LL | b
|
||||
| ^ expected `i32`, found `&{integer}`
|
||||
|
|
||||
help: consider dereferencing the borrow
|
||||
|
|
||||
LL | *b
|
||||
| +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:63:9
|
||||
|
|
||||
LL | b
|
||||
| ^ expected `i32`, found `&{integer}`
|
||||
|
|
||||
help: consider dereferencing the borrow
|
||||
|
|
||||
LL | *b
|
||||
| +
|
||||
|
||||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/deref-suggestion.rs:68:12
|
||||
|
|
||||
LL | let val = if true {
|
||||
| _______________-
|
||||
LL | | *a
|
||||
| | -- expected because of this
|
||||
LL | | } else if true {
|
||||
| |____________^
|
||||
LL | ||
|
||||
LL | || b
|
||||
LL | || } else {
|
||||
LL | || &0
|
||||
LL | || };
|
||||
| || ^
|
||||
| ||_____|
|
||||
| |______`if` and `else` have incompatible types
|
||||
| expected `i32`, found `&{integer}`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue