Skip to content

Add display of lifetime of Ref in fn fmt() for TypeError #107475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<'tcx> Ty<'tcx> {
if tymut_string != "_"
&& (ty.is_simple_text() || tymut_string.len() < "mutable reference".len())
{
format!("`&{}`", tymut_string).into()
format!("`{}`", self).into()
} else {
// Unknown type name, it's long or has type arguments
match mutbl {
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/argument-suggestions/invalid_arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ error[E0308]: mismatched types
--> $DIR/invalid_arguments.rs:16:19
|
LL | two_arg_same(1, "");
| ------------ ^^ expected `i32`, found `&str`
| ------------ ^^ expected `i32`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand All @@ -30,7 +30,7 @@ error[E0308]: mismatched types
--> $DIR/invalid_arguments.rs:17:16
|
LL | two_arg_same("", 1);
| ------------ ^^ expected `i32`, found `&str`
| ------------ ^^ expected `i32`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand All @@ -44,9 +44,9 @@ error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:18:3
|
LL | two_arg_same("", "");
| ^^^^^^^^^^^^ -- -- expected `i32`, found `&str`
| ^^^^^^^^^^^^ -- -- expected `i32`, found `&'static str`
| |
| expected `i32`, found `&str`
| expected `i32`, found `&'static str`
|
note: function defined here
--> $DIR/invalid_arguments.rs:6:4
Expand All @@ -58,7 +58,7 @@ error[E0308]: mismatched types
--> $DIR/invalid_arguments.rs:19:19
|
LL | two_arg_diff(1, "");
| ------------ ^^ expected `f32`, found `&str`
| ------------ ^^ expected `f32`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand All @@ -72,7 +72,7 @@ error[E0308]: mismatched types
--> $DIR/invalid_arguments.rs:20:16
|
LL | two_arg_diff("", 1.0);
| ------------ ^^ expected `i32`, found `&str`
| ------------ ^^ expected `i32`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand All @@ -86,9 +86,9 @@ error[E0308]: arguments to this function are incorrect
--> $DIR/invalid_arguments.rs:21:3
|
LL | two_arg_diff("", "");
| ^^^^^^^^^^^^ -- -- expected `f32`, found `&str`
| ^^^^^^^^^^^^ -- -- expected `f32`, found `&'static str`
| |
| expected `i32`, found `&str`
| expected `i32`, found `&'static str`
|
note: function defined here
--> $DIR/invalid_arguments.rs:7:4
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/argument-suggestions/issue-96638.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0061]: this function takes 3 arguments but 2 arguments were supplied
--> $DIR/issue-96638.rs:8:5
|
LL | f(&x, "");
| ^ -- -- expected `usize`, found `&str`
| ^ -- -- expected `usize`, found `&'static str`
| |
| an argument of type `usize` is missing
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/argument-suggestions/mixed_cases.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
LL | two_args(1, "", X {});
| ^^^^^^^^ -- ---- argument of type `X` unexpected
| |
| expected `f32`, found `&str`
| expected `f32`, found `&'static str`
|
note: function defined here
--> $DIR/mixed_cases.rs:5:4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0326]: implemented const `FROM` has an incompatible type for trait
--> $DIR/associated-const-generic-obligations.rs:14:17
|
LL | const FROM: &'static str = "foo";
| ^^^^^^^^^^^^ expected associated type, found `&str`
| ^^^^^^^^^^^^ expected associated type, found `&'static str`
|
note: type in trait
--> $DIR/associated-const-generic-obligations.rs:10:17
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-type-bounds/elision.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/elision.rs:5:79
|
LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() }
| ----------------------------- -------------- ^^^^^^^^ expected `&()`, found type parameter `impl Iterator<Item = &'_ ()>`
| ----------------------------- -------------- ^^^^^^^^ expected `&'static ()`, found type parameter `impl Iterator<Item = &'_ ()>`
| | |
| | expected `Option<&'static ()>` because of return type
| this type parameter
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/closures/closure-return-type-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/closure-return-type-mismatch.rs:12:20
|
LL | return "hello"
| ^^^^^^^ expected `bool`, found `&str`
| ^^^^^^^ expected `bool`, found `&'static str`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/codemap_tests/tab.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0308]: mismatched types
LL | fn foo() {
| - help: try adding a return type: `-> &'static str`
LL | "bar boo"
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&str`
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&'static str`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/issue-69310-array-size-lit-wrong-ty.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69310-array-size-lit-wrong-ty.rs:11:15
|
LL | const B: [(); b"a"] = [()];
| ^^^^ expected `usize`, found `&[u8; 1]`
| ^^^^ expected `usize`, found `&'static [u8; 1]`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/deref-patterns/gate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | match String::new() {
| ------------- this expression has type `String`
LL | "" | _ => {}
| ^^ expected struct `String`, found `&str`
| ^^ expected struct `String`, found `&'static str`

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/brackets-to-braces-single-element.rs:1:24
|
LL | const A: [&str; 1] = { "hello" };
| ^^^^^^^ expected array `[&'static str; 1]`, found `&str`
| ^^^^^^^ expected array `[&'static str; 1]`, found `&'static str`
|
help: to create an array, use square brackets instead of curly braces
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/inference/char-as-str-multi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ error[E0308]: mismatched types
--> $DIR/char-as-str-multi.rs:5:19
|
LL | let _: char = "foo";
| ---- ^^^^^ expected `char`, found `&str`
| ---- ^^^^^ expected `char`, found `&'static str`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/char-as-str-multi.rs:6:19
|
LL | let _: char = "";
| ---- ^^ expected `char`, found `&str`
| ---- ^^ expected `char`, found `&'static str`
| |
| expected due to this

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/inference/char-as-str-single.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/char-as-str-single.rs:9:19
|
LL | let _: char = "a";
| ---- ^^^ expected `char`, found `&str`
| ---- ^^^ expected `char`, found `&'static str`
| |
| expected due to this
|
Expand All @@ -15,7 +15,7 @@ error[E0308]: mismatched types
--> $DIR/char-as-str-single.rs:10:19
|
LL | let _: char = "人";
| ---- ^^^^ expected `char`, found `&str`
| ---- ^^^^ expected `char`, found `&'static str`
| |
| expected due to this
|
Expand All @@ -28,7 +28,7 @@ error[E0308]: mismatched types
--> $DIR/char-as-str-single.rs:11:19
|
LL | let _: char = "'";
| ---- ^^^ expected `char`, found `&str`
| ---- ^^^ expected `char`, found `&'static str`
| |
| expected due to this
|
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/issues/issue-20225.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | impl<'a, T> Fn<(&'a T,)> for Foo {
LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
| ^^^^
| |
| expected `&T`, found type parameter `T`
| expected `&'a T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)`
|
= note: expected signature `extern "rust-call" fn(&Foo, (&'a T,))`
Expand All @@ -20,7 +20,7 @@ LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
| ^^^^
| |
| expected `&T`, found type parameter `T`
| expected `&'a T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)`
|
= note: expected signature `extern "rust-call" fn(&mut Foo, (&'a T,))`
Expand All @@ -35,7 +35,7 @@ LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
| ^^^^
| |
| expected `&T`, found type parameter `T`
| expected `&'a T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)`
|
= note: expected signature `extern "rust-call" fn(Foo, (&'a T,))`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-41742.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-41742.rs:24:7
|
LL | H["?"].f();
| ^^^ expected `u32`, found `&str`
| ^^^ expected `u32`, found `&'static str`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-7061.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-7061.rs:4:46
|
LL | fn foo(&'a mut self) -> Box<BarStruct> { self }
| -------------- ^^^^ expected struct `Box`, found `&mut BarStruct`
| -------------- ^^^^ expected struct `Box`, found `&'a mut BarStruct`
| |
| expected `Box<BarStruct>` because of return type
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lexer/lex-bad-char-literals-6.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ error[E0308]: mismatched types
--> $DIR/lex-bad-char-literals-6.rs:13:20
|
LL | let a: usize = "";
| ----- ^^ expected `usize`, found `&str`
| ----- ^^ expected `usize`, found `&'static str`
| |
| expected due to this

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lifetimes/issue-26638.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ error[E0308]: mismatched types
--> $DIR/issue-26638.rs:1:69
|
LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
| ---- ^^^^^^^^^^^ expected `&str`, found enum `Option`
| ---- ^^^^^^^^^^^ expected `&'static str`, found enum `Option`
| |
| expected `&'static str` because of return type
|
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/loops/loop-break-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:16:15
|
LL | break "asdf";
| ^^^^^^ expected `i32`, found `&str`
| ^^^^^^ expected `i32`, found `&'static str`

error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:21:31
|
LL | break 'outer_loop "nope";
| ^^^^^^ expected `i32`, found `&str`
| ^^^^^^ expected `i32`, found `&'static str`

error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:73:26
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/match/match-arm-resolving-to-never.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | | E::D => 4,
LL | | E::E => unimplemented!(""),
| | ------------------ this and all prior arms are found to be of type `{integer}`
LL | | E::F => "",
| | ^^ expected integer, found `&str`
| | ^^ expected integer, found `&'static str`
LL | | };
| |_____- `match` arms have incompatible types

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/match/single-line.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: `match` arms have incompatible types
--> $DIR/single-line.rs:2:52
|
LL | let _ = match Some(42) { Some(x) => x, None => "" };
| -------------- - ^^ expected integer, found `&str`
| -------------- - ^^ expected integer, found `&'static str`
| | |
| | this is found to be of type `{integer}`
| `match` arms have incompatible types
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/methods/issues/issue-61525.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ error[E0308]: mismatched types
--> $DIR/issue-61525.rs:14:33
|
LL | 1.query::<dyn ToString>("")
| --------------------- ^^ expected trait object `dyn ToString`, found `&str`
| --------------------- ^^ expected trait object `dyn ToString`, found `&'static str`
| |
| arguments to this method are incorrect
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/mismatched_types/normalize-fn-sig.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/normalize-fn-sig.rs:14:22
|
LL | needs_i32_ref_fn(foo::<()>);
| ---------------- ^^^^^^^^^ expected `&i32`, found `i32`
| ---------------- ^^^^^^^^^ expected `&'static i32`, found `i32`
| |
| arguments to this function are incorrect
|
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/mismatched_types/overloaded-calls-bad.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/overloaded-calls-bad.rs:33:17
|
LL | let ans = s("what");
| - ^^^^^^ expected `isize`, found `&str`
| - ^^^^^^ expected `isize`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand Down Expand Up @@ -34,7 +34,7 @@ error[E0057]: this function takes 1 argument but 2 arguments were supplied
LL | let ans = s("burma", "shave");
| ^ ------- ------- argument of type `&'static str` unexpected
| |
| expected `isize`, found `&str`
| expected `isize`, found `&'static str`
|
note: implementation defined here
--> $DIR/overloaded-calls-bad.rs:10:1
Expand All @@ -50,7 +50,7 @@ error[E0308]: mismatched types
--> $DIR/overloaded-calls-bad.rs:40:7
|
LL | F("");
| - ^^ expected `i32`, found `&str`
| - ^^ expected `i32`, found `&'static str`
| |
| arguments to this struct are incorrect
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/never_type/call-fn-never-arg-wrong-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/call-fn-never-arg-wrong-type.rs:10:9
|
LL | foo("wow");
| --- ^^^^^ expected `!`, found `&str`
| --- ^^^^^ expected `!`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/never_type/never-assign-wrong-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/never-assign-wrong-type.rs:7:16
|
LL | let x: ! = "hello";
| - ^^^^^^^ expected `!`, found `&str`
| - ^^^^^^^ expected `!`, found `&'static str`
| |
| expected due to this
|
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/parser/fn-arg-doc-comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fn main() {
// verify that the parser recovered and properly typechecked the args
f("", "");
//~^ ERROR arguments to this function are incorrect
//~| NOTE expected `u8`, found `&str`
//~| NOTE expected `u8`, found `&str`
//~| NOTE expected `u8`, found `&'static str`
//~| NOTE expected `u8`, found `&'static str`
bar("");
//~^ ERROR mismatched types
//~| NOTE arguments to this function are incorrect
//~| NOTE expected `i32`, found `&str`
//~| NOTE expected `i32`, found `&'static str`
}
6 changes: 3 additions & 3 deletions tests/ui/parser/fn-arg-doc-comment.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ error[E0308]: arguments to this function are incorrect
--> $DIR/fn-arg-doc-comment.rs:22:5
|
LL | f("", "");
| ^ -- -- expected `u8`, found `&str`
| ^ -- -- expected `u8`, found `&'static str`
| |
| expected `u8`, found `&str`
| expected `u8`, found `&'static str`
|
note: function defined here
--> $DIR/fn-arg-doc-comment.rs:1:8
Expand All @@ -46,7 +46,7 @@ error[E0308]: mismatched types
--> $DIR/fn-arg-doc-comment.rs:26:9
|
LL | bar("");
| --- ^^ expected `i32`, found `&str`
| --- ^^ expected `i32`, found `&'static str`
| |
| arguments to this function are incorrect
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/parser/numeric-lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/numeric-lifetime.rs:6:20
|
LL | let x: usize = "";
| ----- ^^ expected `usize`, found `&str`
| ----- ^^ expected `usize`, found `&'static str`
| |
| expected due to this

Expand Down
Loading