forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make InferCtxtExt::could_impl_trait less messed up
- Loading branch information
1 parent
1d8d7b1
commit 04a6fd2
Showing
13 changed files
with
118 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::marker::PhantomData; | ||
|
||
struct Example<E, FakeParam>(PhantomData<(fn(E), fn(FakeParam))>); | ||
|
||
struct NoLifetime; | ||
struct Immutable<'a>(PhantomData<&'a ()>); | ||
|
||
impl<'a, E: 'a> Copy for Example<E, Immutable<'a>> {} | ||
impl<'a, E: 'a> Clone for Example<E, Immutable<'a>> { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} | ||
|
||
impl<E, FakeParam> Example<E, FakeParam> { | ||
unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { | ||
Example(PhantomData) | ||
} | ||
} | ||
|
||
impl<E> Example<E, NoLifetime> { | ||
fn the_ice(&mut self) -> Example<E, Immutable<'_>> { | ||
unsafe { self.change() } | ||
//~^ ERROR cannot move out of `*self` which is behind a mutable reference | ||
} | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
tests/ui/borrowck/issue-119915-bad-clone-suggestion.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,17 @@ | ||
error[E0507]: cannot move out of `*self` which is behind a mutable reference | ||
--> $DIR/issue-119915-bad-clone-suggestion.rs:23:18 | ||
| | ||
LL | unsafe { self.change() } | ||
| ^^^^ -------- `*self` moved due to this method call | ||
| | | ||
| move occurs because `*self` has type `Example<E, NoLifetime>`, which does not implement the `Copy` trait | ||
| | ||
note: `Example::<E, FakeParam>::change` takes ownership of the receiver `self`, which moves `*self` | ||
--> $DIR/issue-119915-bad-clone-suggestion.rs:16:36 | ||
| | ||
LL | unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { | ||
| ^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |
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