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.
Avoid ICE if the Clone trait is not found while building error sugges…
…tions
- Loading branch information
Showing
3 changed files
with
49 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
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,19 @@ | ||
// Avoid panicking if the Clone trait is not found while building error suggestions | ||
|
||
#![feature(no_core, lang_items)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
fn g<T>(x: T) {} | ||
|
||
fn f(x: *mut u8) { | ||
g(x); | ||
g(x); //~ ERROR use of moved value: `x` | ||
} | ||
|
||
fn main() {} |
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,21 @@ | ||
error[E0382]: use of moved value: `x` | ||
--> $DIR/issue-104870.rs:16:7 | ||
| | ||
LL | fn f(x: *mut u8) { | ||
| - move occurs because `x` has type `*mut u8`, which does not implement the `Copy` trait | ||
LL | g(x); | ||
| - value moved here | ||
LL | g(x); | ||
| ^ value used here after move | ||
| | ||
note: consider changing this parameter type in function `g` to borrow instead if owning the value isn't necessary | ||
--> $DIR/issue-104870.rs:12:12 | ||
| | ||
LL | fn g<T>(x: T) {} | ||
| - ^ this parameter takes ownership of the value | ||
| | | ||
| in this function | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |