diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-28 17:25:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-28 17:25:49 +0100 |
| commit | db2850c1fb959823f1473af5444a0835109e3125 (patch) | |
| tree | d342af718a7a401f4332784b4142e2afa220921e /src | |
| parent | 412f05c9e8f0b619300b061b1affc963020f8c98 (diff) | |
| parent | 7a378dd0fb2b383be75722666d8a3c761882af15 (diff) | |
| download | rust-db2850c1fb959823f1473af5444a0835109e3125.tar.gz rust-db2850c1fb959823f1473af5444a0835109e3125.zip | |
Rollup merge of #104956 - mucinoab:issue-104870, r=compiler-errors
Avoid ICE if the Clone trait is not found while building error suggestions Fixes #104870 r? `@compiler-errors`
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`. |
