diff options
| author | Bruno A. Muciño <mucinoab@gmail.com> | 2022-11-27 20:50:13 -0600 |
|---|---|---|
| committer | Bruno A. Muciño <mucinoab@gmail.com> | 2022-11-27 20:50:13 -0600 |
| commit | 7a378dd0fb2b383be75722666d8a3c761882af15 (patch) | |
| tree | 125cb071aac5b369bdecf6139d5fb3902ab411ac /src | |
| parent | 07e664c41ae5679b912ba9d1f7364ebaac8e51b6 (diff) | |
| download | rust-7a378dd0fb2b383be75722666d8a3c761882af15.tar.gz rust-7a378dd0fb2b383be75722666d8a3c761882af15.zip | |
Avoid ICE if the Clone trait is not found while building error suggestions
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/lang-items/missing-clone-for-suggestion.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/lang-items/missing-clone-for-suggestion.stderr | 21 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/lang-items/missing-clone-for-suggestion.rs b/src/test/ui/lang-items/missing-clone-for-suggestion.rs new file mode 100644 index 00000000000..e8290c0098a --- /dev/null +++ b/src/test/ui/lang-items/missing-clone-for-suggestion.rs @@ -0,0 +1,20 @@ +// Avoid panicking if the Clone trait is not found while building error suggestions +// See #104870 + +#![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() {} diff --git a/src/test/ui/lang-items/missing-clone-for-suggestion.stderr b/src/test/ui/lang-items/missing-clone-for-suggestion.stderr new file mode 100644 index 00000000000..35783a1be78 --- /dev/null +++ b/src/test/ui/lang-items/missing-clone-for-suggestion.stderr @@ -0,0 +1,21 @@ +error[E0382]: use of moved value: `x` + --> $DIR/missing-clone-for-suggestion.rs:17: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/missing-clone-for-suggestion.rs:13: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`. |
