test suggesting immutable or mutable trait implementations
This commit is contained in:
parent
3e41397ef2
commit
3bab36357c
@ -1,13 +0,0 @@
|
||||
trait Trait {}
|
||||
|
||||
struct S;
|
||||
|
||||
impl Trait for &S {}
|
||||
impl Trait for &mut S {}
|
||||
|
||||
fn foo<X: Trait>(_: X) {}
|
||||
|
||||
fn main() {
|
||||
let s = S;
|
||||
foo(s); //~ ERROR the trait bound `S: Trait` is not satisfied
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
error[E0277]: the trait bound `S: Trait` is not satisfied
|
||||
--> $DIR/suggest-both-imm-and-mut-trait-implementation.rs:12:9
|
||||
|
|
||||
LL | foo(s);
|
||||
| --- ^ expected an implementor of trait `Trait`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/suggest-both-imm-and-mut-trait-implementation.rs:8:11
|
||||
|
|
||||
LL | fn foo<X: Trait>(_: X) {}
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
help: consider borrowing here
|
||||
|
|
||||
LL | foo(&s);
|
||||
| +
|
||||
LL | foo(&mut s);
|
||||
| ++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -0,0 +1,23 @@
|
||||
trait Trait {}
|
||||
|
||||
struct A;
|
||||
struct B;
|
||||
struct C;
|
||||
|
||||
impl Trait for &A {}
|
||||
impl Trait for &mut A {}
|
||||
|
||||
impl Trait for &B {}
|
||||
|
||||
impl Trait for &mut C {}
|
||||
|
||||
fn foo<X: Trait>(_: X) {}
|
||||
|
||||
fn main() {
|
||||
let a = A;
|
||||
let b = B;
|
||||
let c = C;
|
||||
foo(a); //~ ERROR the trait bound `A: Trait` is not satisfied
|
||||
foo(b); //~ ERROR the trait bound `B: Trait` is not satisfied
|
||||
foo(c); //~ ERROR the trait bound `C: Trait` is not satisfied
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
error[E0277]: the trait bound `A: Trait` is not satisfied
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:20:9
|
||||
|
|
||||
LL | foo(a);
|
||||
| --- ^ expected an implementor of trait `Trait`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
|
||||
|
|
||||
LL | fn foo<X: Trait>(_: X) {}
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
help: consider borrowing here
|
||||
|
|
||||
LL | foo(&a);
|
||||
| +
|
||||
LL | foo(&mut a);
|
||||
| ++++
|
||||
|
||||
error[E0277]: the trait bound `B: Trait` is not satisfied
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:21:9
|
||||
|
|
||||
LL | foo(b);
|
||||
| --- ^ expected an implementor of trait `Trait`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
|
||||
|
|
||||
LL | fn foo<X: Trait>(_: X) {}
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
help: consider borrowing here
|
||||
|
|
||||
LL | foo(&b);
|
||||
| +
|
||||
|
||||
error[E0277]: the trait bound `C: Trait` is not satisfied
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:22:9
|
||||
|
|
||||
LL | foo(c);
|
||||
| --- ^ expected an implementor of trait `Trait`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
|
||||
|
|
||||
LL | fn foo<X: Trait>(_: X) {}
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
help: consider mutably borrowing here
|
||||
|
|
||||
LL | foo(&mut c);
|
||||
| ++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user