-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #100769 - TaKO8Ki:suggest-adding-reference-to-trait-a…
…ssoc-item, r=cjgillot Suggest adding a reference to a trait assoc item fixes #100289
- Loading branch information
Showing
4 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
#![allow(unused_variables)] | ||
|
||
fn foo(foo: &mut usize) { | ||
todo!() | ||
} | ||
|
||
fn bar(bar: &usize) { | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
foo(&mut Default::default()); //~ the trait bound `&mut usize: Default` is not satisfied | ||
bar(&Default::default()); //~ the trait bound `&usize: Default` is not satisfied | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
#![allow(unused_variables)] | ||
|
||
fn foo(foo: &mut usize) { | ||
todo!() | ||
} | ||
|
||
fn bar(bar: &usize) { | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
foo(Default::default()); //~ the trait bound `&mut usize: Default` is not satisfied | ||
bar(Default::default()); //~ the trait bound `&usize: Default` is not satisfied | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0277]: the trait bound `&mut usize: Default` is not satisfied | ||
--> $DIR/suggest-adding-reference-to-trait-assoc-item.rs:13:9 | ||
| | ||
LL | foo(Default::default()); | ||
| ^^^^^^^^^^^^^^^^ expected an implementor of trait `Default` | ||
| | ||
help: consider mutably borrowing here | ||
| | ||
LL | foo(&mut Default::default()); | ||
| ++++ | ||
|
||
error[E0277]: the trait bound `&usize: Default` is not satisfied | ||
--> $DIR/suggest-adding-reference-to-trait-assoc-item.rs:14:9 | ||
| | ||
LL | bar(Default::default()); | ||
| ^^^^^^^^^^^^^^^^ expected an implementor of trait `Default` | ||
| | ||
help: consider borrowing here | ||
| | ||
LL | bar(&Default::default()); | ||
| + | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |