mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Update test
This commit is contained in:
@@ -4,14 +4,24 @@ struct S;
|
||||
trait Trait {
|
||||
fn foo() {}
|
||||
}
|
||||
impl Trait for &S {}
|
||||
impl Trait for &mut S {}
|
||||
trait Trait2 {
|
||||
fn bar() {}
|
||||
}
|
||||
impl Trait2 for &S {}
|
||||
impl Trait2 for &mut S {}
|
||||
fn main() {
|
||||
let _ = <&str>::from("value");
|
||||
//~^ ERROR the trait bound `str: From<_>` is not satisfied
|
||||
//~| ERROR the size for values of type `str` cannot be known at compilation time
|
||||
let _ = <&mut S>::foo();
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = <&S>::foo();
|
||||
let _ = <&mut S>::foo();
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = <&mut S>::foo();
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = <&mut S>::bar();
|
||||
//~^ ERROR the trait bound `S: Trait2` is not satisfied
|
||||
let _ = <&S>::bar();
|
||||
//~^ ERROR the trait bound `S: Trait2` is not satisfied
|
||||
}
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
trait Trait {
|
||||
fn foo() {}
|
||||
}
|
||||
impl Trait for &S {}
|
||||
impl Trait for &mut S {}
|
||||
trait Trait2 {
|
||||
fn bar() {}
|
||||
}
|
||||
impl Trait2 for &S {}
|
||||
impl Trait2 for &mut S {}
|
||||
fn main() {
|
||||
let _ = &str::from("value");
|
||||
//~^ ERROR the trait bound `str: From<_>` is not satisfied
|
||||
@@ -14,4 +18,10 @@ fn main() {
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = &S::foo();
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = S::foo();
|
||||
//~^ ERROR the trait bound `S: Trait` is not satisfied
|
||||
let _ = &mut S::bar();
|
||||
//~^ ERROR the trait bound `S: Trait2` is not satisfied
|
||||
let _ = &S::bar();
|
||||
//~^ ERROR the trait bound `S: Trait2` is not satisfied
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error[E0277]: the trait bound `str: From<_>` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:14:14
|
||||
|
|
||||
LL | let _ = &str::from("value");
|
||||
| ^^^ the trait `From<_>` is not implemented for `str`
|
||||
@@ -17,35 +17,71 @@ LL | let _ = <&str>::from("value");
|
||||
| + +
|
||||
|
||||
error[E0277]: the trait bound `S: Trait` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:13:18
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:17:18
|
||||
|
|
||||
LL | let _ = &mut S::foo();
|
||||
| ^ the trait `Trait` is not implemented for `S`
|
||||
|
|
||||
= help: the following other types implement trait `Trait`:
|
||||
&S
|
||||
&mut S
|
||||
= help: the trait `Trait` is implemented for `&mut S`
|
||||
help: you likely meant to call the associated function `foo` for type `&mut S`, but the code as written calls associated function `foo` on type `S`
|
||||
|
|
||||
LL | let _ = <&mut S>::foo();
|
||||
| + +
|
||||
|
||||
error[E0277]: the trait bound `S: Trait` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:15:14
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:19:14
|
||||
|
|
||||
LL | let _ = &S::foo();
|
||||
| ^ the trait `Trait` is not implemented for `S`
|
||||
|
|
||||
= help: the following other types implement trait `Trait`:
|
||||
&S
|
||||
&mut S
|
||||
= help: the trait `Trait` is implemented for `&mut S`
|
||||
help: you likely meant to call the associated function `foo` for type `&S`, but the code as written calls associated function `foo` on type `S`
|
||||
|
|
||||
LL | let _ = <&S>::foo();
|
||||
LL - let _ = &S::foo();
|
||||
LL + let _ = <&mut S>::foo();
|
||||
|
|
||||
|
||||
error[E0277]: the trait bound `S: Trait` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:21:13
|
||||
|
|
||||
LL | let _ = S::foo();
|
||||
| ^ the trait `Trait` is not implemented for `S`
|
||||
|
|
||||
help: consider mutably borrowing here
|
||||
|
|
||||
LL | let _ = <&mut S>::foo();
|
||||
| +++++ +
|
||||
|
||||
error[E0277]: the trait bound `S: Trait2` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:23:18
|
||||
|
|
||||
LL | let _ = &mut S::bar();
|
||||
| ^ the trait `Trait2` is not implemented for `S`
|
||||
|
|
||||
= help: the following other types implement trait `Trait2`:
|
||||
&S
|
||||
&mut S
|
||||
help: you likely meant to call the associated function `bar` for type `&mut S`, but the code as written calls associated function `bar` on type `S`
|
||||
|
|
||||
LL | let _ = <&mut S>::bar();
|
||||
| + +
|
||||
|
||||
error[E0277]: the trait bound `S: Trait2` is not satisfied
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:25:14
|
||||
|
|
||||
LL | let _ = &S::bar();
|
||||
| ^ the trait `Trait2` is not implemented for `S`
|
||||
|
|
||||
= help: the following other types implement trait `Trait2`:
|
||||
&S
|
||||
&mut S
|
||||
help: you likely meant to call the associated function `bar` for type `&S`, but the code as written calls associated function `bar` on type `S`
|
||||
|
|
||||
LL | let _ = <&S>::bar();
|
||||
| + +
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
|
||||
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:14:14
|
||||
|
|
||||
LL | let _ = &str::from("value");
|
||||
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
@@ -53,6 +89,6 @@ LL | let _ = &str::from("value");
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
= note: the return type of a function must have a statically known size
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
||||
Reference in New Issue
Block a user