From 33dc44a93e1675a10f3ed29fde4fd4183f79a485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 21 Jun 2024 21:12:00 +0000 Subject: [PATCH] Remove stray `.` from error message --- compiler/rustc_hir_analysis/messages.ftl | 2 +- tests/ui/error-codes/E0116.stderr | 2 +- .../no-attr-empty-impl.stderr | 8 ++++---- .../inherent-impls-missing-due-to-bad-impl.rs | 8 ++++++++ ...herent-impls-missing-due-to-bad-impl.stderr | 18 ++++++++++++++++++ .../ui/traits/trait-or-new-type-instead.stderr | 2 +- 6 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.rs create mode 100644 tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.stderr diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 8c740d87e9535..b8f610e569670 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -194,7 +194,7 @@ hir_analysis_inherent_ty_outside = cannot define inherent `impl` for a type outs .span_help = alternatively add `#[rustc_has_incoherent_inherent_impls]` to the type and `#[rustc_allow_incoherent_impl]` to the relevant impl items hir_analysis_inherent_ty_outside_new = cannot define inherent `impl` for a type outside of the crate where the type is defined - .label = impl for type defined outside of crate. + .label = impl for type defined outside of crate .note = define and implement a trait or new type instead hir_analysis_inherent_ty_outside_primitive = cannot define inherent `impl` for primitive types outside of `core` diff --git a/tests/ui/error-codes/E0116.stderr b/tests/ui/error-codes/E0116.stderr index bf215435ba6a0..1ea5a57f46db1 100644 --- a/tests/ui/error-codes/E0116.stderr +++ b/tests/ui/error-codes/E0116.stderr @@ -2,7 +2,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/E0116.rs:1:1 | LL | impl Vec {} - | ^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead diff --git a/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr b/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr index 6dc1680cf89f8..f8491697910c0 100644 --- a/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr +++ b/tests/ui/incoherent-inherent-impls/no-attr-empty-impl.stderr @@ -2,7 +2,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/no-attr-empty-impl.rs:4:1 | LL | impl extern_crate::StructWithAttr {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead @@ -10,7 +10,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/no-attr-empty-impl.rs:7:1 | LL | impl extern_crate::StructNoAttr {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead @@ -18,7 +18,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/no-attr-empty-impl.rs:10:1 | LL | impl extern_crate::EnumWithAttr {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead @@ -26,7 +26,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/no-attr-empty-impl.rs:13:1 | LL | impl extern_crate::EnumNoAttr {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead diff --git a/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.rs b/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.rs new file mode 100644 index 0000000000000..d2c52f55aa335 --- /dev/null +++ b/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.rs @@ -0,0 +1,8 @@ +fn main() { + let x = "hello"; + // FIXME: the error below shouldn't happen. For that we need to modify `crate_inherent_impls`. + // https://github.com/rust-lang/rust/issues/125814 + x.split(" "); //~ ERROR E0599 +} + +impl Vec {} //~ ERROR E0116 diff --git a/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.stderr b/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.stderr new file mode 100644 index 0000000000000..689cf33e87637 --- /dev/null +++ b/tests/ui/resolve/inherent-impls-missing-due-to-bad-impl.stderr @@ -0,0 +1,18 @@ +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/inherent-impls-missing-due-to-bad-impl.rs:8:1 + | +LL | impl Vec {} + | ^^^^^^^^^^^^^^^ impl for type defined outside of crate + | + = note: define and implement a trait or new type instead + +error[E0599]: no method named `split` found for reference `&str` in the current scope + --> $DIR/inherent-impls-missing-due-to-bad-impl.rs:5:7 + | +LL | x.split(" "); + | ^^^^^ method not found in `&str` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0116, E0599. +For more information about an error, try `rustc --explain E0116`. diff --git a/tests/ui/traits/trait-or-new-type-instead.stderr b/tests/ui/traits/trait-or-new-type-instead.stderr index 17ee939887864..5f5aa3ac56982 100644 --- a/tests/ui/traits/trait-or-new-type-instead.stderr +++ b/tests/ui/traits/trait-or-new-type-instead.stderr @@ -2,7 +2,7 @@ error[E0116]: cannot define inherent `impl` for a type outside of the crate wher --> $DIR/trait-or-new-type-instead.rs:1:1 | LL | impl Option { - | ^^^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | ^^^^^^^^^^^^^^^^^ impl for type defined outside of crate | = note: define and implement a trait or new type instead