Skip to content

Commit d692444

Browse files
committed
Update test
1 parent 0674eca commit d692444

File tree

3 files changed

+70
-14
lines changed

3 files changed

+70
-14
lines changed

tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ struct S;
44
trait Trait {
55
fn foo() {}
66
}
7-
impl Trait for &S {}
87
impl Trait for &mut S {}
8+
trait Trait2 {
9+
fn bar() {}
10+
}
11+
impl Trait2 for &S {}
12+
impl Trait2 for &mut S {}
913
fn main() {
1014
let _ = <&str>::from("value");
1115
//~^ ERROR the trait bound `str: From<_>` is not satisfied
1216
//~| ERROR the size for values of type `str` cannot be known at compilation time
1317
let _ = <&mut S>::foo();
1418
//~^ ERROR the trait bound `S: Trait` is not satisfied
15-
let _ = <&S>::foo();
19+
let _ = <&mut S>::foo();
20+
//~^ ERROR the trait bound `S: Trait` is not satisfied
21+
let _ = <&mut S>::foo();
1622
//~^ ERROR the trait bound `S: Trait` is not satisfied
23+
let _ = <&mut S>::bar();
24+
//~^ ERROR the trait bound `S: Trait2` is not satisfied
25+
let _ = <&S>::bar();
26+
//~^ ERROR the trait bound `S: Trait2` is not satisfied
1727
}

tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ struct S;
44
trait Trait {
55
fn foo() {}
66
}
7-
impl Trait for &S {}
87
impl Trait for &mut S {}
8+
trait Trait2 {
9+
fn bar() {}
10+
}
11+
impl Trait2 for &S {}
12+
impl Trait2 for &mut S {}
913
fn main() {
1014
let _ = &str::from("value");
1115
//~^ ERROR the trait bound `str: From<_>` is not satisfied
@@ -14,4 +18,10 @@ fn main() {
1418
//~^ ERROR the trait bound `S: Trait` is not satisfied
1519
let _ = &S::foo();
1620
//~^ ERROR the trait bound `S: Trait` is not satisfied
21+
let _ = S::foo();
22+
//~^ ERROR the trait bound `S: Trait` is not satisfied
23+
let _ = &mut S::bar();
24+
//~^ ERROR the trait bound `S: Trait2` is not satisfied
25+
let _ = &S::bar();
26+
//~^ ERROR the trait bound `S: Trait2` is not satisfied
1727
}
Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `str: From<_>` is not satisfied
2-
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
2+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:14:14
33
|
44
LL | let _ = &str::from("value");
55
| ^^^ the trait `From<_>` is not implemented for `str`
@@ -17,42 +17,78 @@ LL | let _ = <&str>::from("value");
1717
| + +
1818

1919
error[E0277]: the trait bound `S: Trait` is not satisfied
20-
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:13:18
20+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:17:18
2121
|
2222
LL | let _ = &mut S::foo();
2323
| ^ the trait `Trait` is not implemented for `S`
2424
|
25-
= help: the following other types implement trait `Trait`:
26-
&S
27-
&mut S
25+
= help: the trait `Trait` is implemented for `&mut S`
2826
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`
2927
|
3028
LL | let _ = <&mut S>::foo();
3129
| + +
3230

3331
error[E0277]: the trait bound `S: Trait` is not satisfied
34-
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:15:14
32+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:19:14
3533
|
3634
LL | let _ = &S::foo();
3735
| ^ the trait `Trait` is not implemented for `S`
3836
|
39-
= help: the following other types implement trait `Trait`:
37+
= help: the trait `Trait` is implemented for `&mut S`
38+
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`
39+
|
40+
LL - let _ = &S::foo();
41+
LL + let _ = <&mut S>::foo();
42+
|
43+
44+
error[E0277]: the trait bound `S: Trait` is not satisfied
45+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:21:13
46+
|
47+
LL | let _ = S::foo();
48+
| ^ the trait `Trait` is not implemented for `S`
49+
|
50+
help: consider mutably borrowing here
51+
|
52+
LL | let _ = <&mut S>::foo();
53+
| +++++ +
54+
55+
error[E0277]: the trait bound `S: Trait2` is not satisfied
56+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:23:18
57+
|
58+
LL | let _ = &mut S::bar();
59+
| ^ the trait `Trait2` is not implemented for `S`
60+
|
61+
= help: the following other types implement trait `Trait2`:
4062
&S
4163
&mut S
42-
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`
64+
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`
65+
|
66+
LL | let _ = <&mut S>::bar();
67+
| + +
68+
69+
error[E0277]: the trait bound `S: Trait2` is not satisfied
70+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:25:14
71+
|
72+
LL | let _ = &S::bar();
73+
| ^ the trait `Trait2` is not implemented for `S`
74+
|
75+
= help: the following other types implement trait `Trait2`:
76+
&S
77+
&mut S
78+
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`
4379
|
44-
LL | let _ = <&S>::foo();
80+
LL | let _ = <&S>::bar();
4581
| + +
4682

4783
error[E0277]: the size for values of type `str` cannot be known at compilation time
48-
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
84+
--> $DIR/dont-suggest-borrowing-existing-borrow.rs:14:14
4985
|
5086
LL | let _ = &str::from("value");
5187
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
5288
|
5389
= help: the trait `Sized` is not implemented for `str`
5490
= note: the return type of a function must have a statically known size
5591

56-
error: aborting due to 4 previous errors
92+
error: aborting due to 7 previous errors
5793

5894
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)