Skip to content

Commit 3bab363

Browse files
committed
test suggesting immutable or mutable trait implementations
1 parent 3e41397 commit 3bab363

4 files changed

+82
-36
lines changed

Diff for: src/test/ui/suggestions/suggest-both-imm-and-mut-trait-implementation.rs

-13
This file was deleted.

Diff for: src/test/ui/suggestions/suggest-both-imm-and-mut-trait-implementation.stderr

-23
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
trait Trait {}
2+
3+
struct A;
4+
struct B;
5+
struct C;
6+
7+
impl Trait for &A {}
8+
impl Trait for &mut A {}
9+
10+
impl Trait for &B {}
11+
12+
impl Trait for &mut C {}
13+
14+
fn foo<X: Trait>(_: X) {}
15+
16+
fn main() {
17+
let a = A;
18+
let b = B;
19+
let c = C;
20+
foo(a); //~ ERROR the trait bound `A: Trait` is not satisfied
21+
foo(b); //~ ERROR the trait bound `B: Trait` is not satisfied
22+
foo(c); //~ ERROR the trait bound `C: Trait` is not satisfied
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
error[E0277]: the trait bound `A: Trait` is not satisfied
2+
--> $DIR/suggest-imm-mut-trait-implementations.rs:20:9
3+
|
4+
LL | foo(a);
5+
| --- ^ expected an implementor of trait `Trait`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
note: required by a bound in `foo`
10+
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
11+
|
12+
LL | fn foo<X: Trait>(_: X) {}
13+
| ^^^^^ required by this bound in `foo`
14+
help: consider borrowing here
15+
|
16+
LL | foo(&a);
17+
| +
18+
LL | foo(&mut a);
19+
| ++++
20+
21+
error[E0277]: the trait bound `B: Trait` is not satisfied
22+
--> $DIR/suggest-imm-mut-trait-implementations.rs:21:9
23+
|
24+
LL | foo(b);
25+
| --- ^ expected an implementor of trait `Trait`
26+
| |
27+
| required by a bound introduced by this call
28+
|
29+
note: required by a bound in `foo`
30+
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
31+
|
32+
LL | fn foo<X: Trait>(_: X) {}
33+
| ^^^^^ required by this bound in `foo`
34+
help: consider borrowing here
35+
|
36+
LL | foo(&b);
37+
| +
38+
39+
error[E0277]: the trait bound `C: Trait` is not satisfied
40+
--> $DIR/suggest-imm-mut-trait-implementations.rs:22:9
41+
|
42+
LL | foo(c);
43+
| --- ^ expected an implementor of trait `Trait`
44+
| |
45+
| required by a bound introduced by this call
46+
|
47+
note: required by a bound in `foo`
48+
--> $DIR/suggest-imm-mut-trait-implementations.rs:14:11
49+
|
50+
LL | fn foo<X: Trait>(_: X) {}
51+
| ^^^^^ required by this bound in `foo`
52+
help: consider mutably borrowing here
53+
|
54+
LL | foo(&mut c);
55+
| ++++
56+
57+
error: aborting due to 3 previous errors
58+
59+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)