Skip to content

Commit

Permalink
Update ui test for the new E0283 label
Browse files Browse the repository at this point in the history
label: `cannot call trait method as a free function`
  • Loading branch information
obeis committed Jul 18, 2022
1 parent 8f2c21d commit afaa329
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/associated-types-unconstrained.rs:14:20
|
LL | let x: isize = Foo::bar();
| ^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Foo`
| ^^^^^^^^ cannot call trait method as a free function

error: aborting due to previous error

Expand Down
19 changes: 2 additions & 17 deletions src/test/ui/error-codes/E0283.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@ error[E0283]: type annotations needed
--> $DIR/E0283.rs:30:21
|
LL | let cont: u32 = Generator::create();
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Generator`
| ^^^^^^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/E0283.rs:35:24
|
LL | let bar = foo_impl.into() * 1u32;
| ^^^^
|
note: multiple `impl`s satisfying `Impl: Into<_>` found
--> $DIR/E0283.rs:17:1
|
LL | impl Into<u32> for Impl {
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: and another `impl` found in the `core` crate:
- impl<T, U> Into<U> for T
where U: From<T>;
help: try using a fully qualified path to specify the expected types
|
LL | let bar = <Impl as Into<T>>::into(foo_impl) * 1u32;
| ++++++++++++++++++++++++ ~
| ^^^^ cannot call trait method as a free function

error: aborting due to 2 previous errors

Expand Down
58 changes: 10 additions & 48 deletions src/test/ui/inference/issue-72690.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:22
Expand Down Expand Up @@ -51,31 +47,17 @@ help: try using a fully qualified path to specify the expected types
LL | |x| String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~

error[E0283]: type annotations needed for `&T`
--> $DIR/issue-72690.rs:17:9
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:17:17
|
LL | let _ = "x".as_ref();
| ^ ------ type must be known at this point
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let _: &T = "x".as_ref();
| ++++
| ^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:22
Expand All @@ -97,11 +79,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:22
Expand All @@ -123,11 +101,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:22
Expand All @@ -149,11 +123,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:22
Expand All @@ -175,11 +145,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:22
Expand All @@ -201,11 +167,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
| ^^^^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:22
Expand Down
10 changes: 1 addition & 9 deletions src/test/ui/issues/issue-29147.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-29147.rs:21:13
|
LL | let _ = <S5<_>>::xxx;
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
|
note: multiple `impl`s satisfying `S5<_>: Foo` found
--> $DIR/issue-29147.rs:17:1
|
LL | impl Foo for S5<u32> { fn xxx(&self) {} }
| ^^^^^^^^^^^^^^^^^^^^
LL | impl Foo for S5<u64> { fn xxx(&self) {} }
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^ cannot call trait method as a free function

error: aborting due to previous error

Expand Down
53 changes: 8 additions & 45 deletions src/test/ui/traits/issue-77982.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,22 @@ LL | opts.get::<Q>(opt.as_ref());
| +++++

error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:13:59
--> $DIR/issue-77982.rs:13:44
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
| --------- ^^^^
| |
| type must be known at this point
|
= note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
- impl From<Ipv4Addr> for u32;
- impl From<NonZeroU32> for u32;
- impl From<bool> for u32;
- impl From<char> for u32;
and 3 more
help: try using a fully qualified path to specify the expected types
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect();
| +++++++++++++++++++++++ ~
| ^^^^^^^^^ cannot call trait method as a free function

error[E0283]: type annotations needed for `Box<T>`
--> $DIR/issue-77982.rs:36:9
error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:36:16
|
LL | let _ = ().foo();
| ^ --- type must be known at this point
|
note: multiple `impl`s satisfying `(): Foo<'_, _>` found
--> $DIR/issue-77982.rs:29:1
|
LL | impl Foo<'static, u32> for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | impl<'a> Foo<'a, i16> for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let _: Box<T> = ().foo();
| ++++++++
| ^^^ cannot call trait method as a free function

error[E0283]: type annotations needed for `Box<T>`
--> $DIR/issue-77982.rs:40:9
error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:40:19
|
LL | let _ = (&()).bar();
| ^ --- type must be known at this point
|
note: multiple `impl`s satisfying `&(): Bar<'_, _>` found
--> $DIR/issue-77982.rs:32:1
|
LL | impl<'a> Bar<'static, u32> for &'a () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | impl<'a> Bar<'a, i16> for &'a () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let _: Box<T> = (&()).bar();
| ++++++++
| ^^^ cannot call trait method as a free function

error: aborting due to 5 previous errors

Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/traits/static-method-generic-inference.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/static-method-generic-inference.rs:24:25
|
LL | let _f: base::Foo = base::HasNew::new();
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: HasNew<Foo>`
| ^^^^^^^^^^^^^^^^^ cannot call trait method as a free function

error: aborting due to previous error

Expand Down

0 comments on commit afaa329

Please sign in to comment.