forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#65077 - estebank:mut-trait-expected, r=niko…
…matsakis Note when a mutable trait object is needed Fix rust-lang#63619, fix rust-lang#37914. CC rust-lang#64068.
- Loading branch information
Showing
14 changed files
with
292 additions
and
57 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
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
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
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
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
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
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,14 @@ | ||
trait Trait {} | ||
|
||
struct S; | ||
|
||
impl<'a> Trait for &'a mut S {} | ||
|
||
fn foo<X: Trait>(_: X) {} | ||
|
||
|
||
fn main() { | ||
let s = S; | ||
foo(&s); //~ ERROR the trait bound `&S: Trait` is not satisfied | ||
foo(s); //~ ERROR the trait bound `S: Trait` is not satisfied | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/ui/suggestions/imm-ref-trait-object-literal.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,30 @@ | ||
error[E0277]: the trait bound `&S: Trait` is not satisfied | ||
--> $DIR/imm-ref-trait-object-literal.rs:12:7 | ||
| | ||
LL | fn foo<X: Trait>(_: X) {} | ||
| --- ----- required by this bound in `foo` | ||
... | ||
LL | foo(&s); | ||
| -^ | ||
| | | ||
| the trait `Trait` is not implemented for `&S` | ||
| help: consider changing this borrow's mutability: `&mut` | ||
| | ||
= help: the following implementations were found: | ||
<&'a mut S as Trait> | ||
|
||
error[E0277]: the trait bound `S: Trait` is not satisfied | ||
--> $DIR/imm-ref-trait-object-literal.rs:13:7 | ||
| | ||
LL | fn foo<X: Trait>(_: X) {} | ||
| --- ----- required by this bound in `foo` | ||
... | ||
LL | foo(s); | ||
| ^ the trait `Trait` is not implemented for `S` | ||
| | ||
= help: the following implementations were found: | ||
<&'a mut S as Trait> | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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,8 @@ | ||
fn test(t: &dyn Iterator<Item=&u64>) -> u64 { | ||
t.min().unwrap() //~ ERROR the `min` method cannot be invoked on a trait object | ||
} | ||
|
||
fn main() { | ||
let array = [0u64]; | ||
test(&mut array.iter()); | ||
} |
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,10 @@ | ||
error: the `min` method cannot be invoked on a trait object | ||
--> $DIR/imm-ref-trait-object.rs:2:8 | ||
| | ||
LL | t.min().unwrap() | ||
| ^^^ | ||
| | ||
= note: you need `&mut dyn std::iter::Iterator<Item = &u64>` instead of `&dyn std::iter::Iterator<Item = &u64>` | ||
|
||
error: aborting due to previous error | ||
|
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
Oops, something went wrong.