From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/hygiene/globs.stderr | 18 +++++++++++++-- src/test/ui/hygiene/impl_items-2.rs | 26 ++++++++++++++++++++++ src/test/ui/hygiene/impl_items-2.stderr | 15 +++++++++++++ src/test/ui/hygiene/impl_items.rs | 2 +- src/test/ui/hygiene/impl_items.stderr | 2 +- .../ui/hygiene/rustc-macro-transparency.stderr | 8 +------ 6 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 src/test/ui/hygiene/impl_items-2.rs create mode 100644 src/test/ui/hygiene/impl_items-2.stderr (limited to 'src/test/ui/hygiene') diff --git a/src/test/ui/hygiene/globs.stderr b/src/test/ui/hygiene/globs.stderr index bcfcc28ad..1f2a96a4c 100644 --- a/src/test/ui/hygiene/globs.stderr +++ b/src/test/ui/hygiene/globs.stderr @@ -1,9 +1,16 @@ error[E0425]: cannot find function `f` in this scope --> $DIR/globs.rs:22:9 | +LL | pub fn g() {} + | ---------- similarly named function `g` defined here +... LL | f(); - | ^ not found in this scope + | ^ + | +help: a function with a similar name exists | +LL | g(); + | ~ help: consider importing this function | LL | use foo::f; @@ -12,8 +19,11 @@ LL | use foo::f; error[E0425]: cannot find function `g` in this scope --> $DIR/globs.rs:15:5 | +LL | pub fn f() {} + | ---------- similarly named function `f` defined here +... LL | g(); - | ^ not found in this scope + | ^ ... LL | / m! { LL | | use bar::*; @@ -23,6 +33,10 @@ LL | | } | |_____- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a function with a similar name exists + | +LL | f(); + | ~ help: consider importing this function | LL | use bar::g; diff --git a/src/test/ui/hygiene/impl_items-2.rs b/src/test/ui/hygiene/impl_items-2.rs new file mode 100644 index 000000000..465e444ae --- /dev/null +++ b/src/test/ui/hygiene/impl_items-2.rs @@ -0,0 +1,26 @@ +#![feature(decl_macro)] + +trait Trait { + fn foo() {} +} + +macro trait_impl() { + fn foo() {} +} + +// Check that we error on multiple impl items that resolve to the same trait item. +impl Trait for i32 { + trait_impl!(); + fn foo() {} + //~^ ERROR duplicate definitions with name `foo`: [E0201] +} + +struct Type; + +// Check that we do not error with inherent impls. +impl Type { + trait_impl!(); + fn foo() {} +} + +fn main() {} diff --git a/src/test/ui/hygiene/impl_items-2.stderr b/src/test/ui/hygiene/impl_items-2.stderr new file mode 100644 index 000000000..3c0ffeb10 --- /dev/null +++ b/src/test/ui/hygiene/impl_items-2.stderr @@ -0,0 +1,15 @@ +error[E0201]: duplicate definitions with name `foo`: + --> $DIR/impl_items-2.rs:14:5 + | +LL | fn foo() {} + | ----------- item in trait +... +LL | fn foo() {} + | ----------- previous definition here +... +LL | fn foo() {} + | ^^^^^^^^^^^ duplicate definition + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0201`. diff --git a/src/test/ui/hygiene/impl_items.rs b/src/test/ui/hygiene/impl_items.rs index 37794c6e0..ddb25c06b 100644 --- a/src/test/ui/hygiene/impl_items.rs +++ b/src/test/ui/hygiene/impl_items.rs @@ -9,7 +9,7 @@ mod foo { } pub macro m() { - let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private + let _: () = S.f(); //~ ERROR type `for<'a> fn(&'a foo::S) {foo::S::f}` is private } } diff --git a/src/test/ui/hygiene/impl_items.stderr b/src/test/ui/hygiene/impl_items.stderr index 523309f43..46a250038 100644 --- a/src/test/ui/hygiene/impl_items.stderr +++ b/src/test/ui/hygiene/impl_items.stderr @@ -1,4 +1,4 @@ -error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private +error: type `for<'a> fn(&'a foo::S) {foo::S::f}` is private --> $DIR/impl_items.rs:12:23 | LL | let _: () = S.f(); diff --git a/src/test/ui/hygiene/rustc-macro-transparency.stderr b/src/test/ui/hygiene/rustc-macro-transparency.stderr index 17d05dd09..1d2a1e124 100644 --- a/src/test/ui/hygiene/rustc-macro-transparency.stderr +++ b/src/test/ui/hygiene/rustc-macro-transparency.stderr @@ -19,14 +19,8 @@ LL | semitransparent; error[E0423]: expected value, found macro `opaque` --> $DIR/rustc-macro-transparency.rs:30:5 | -LL | struct Opaque; - | -------------- similarly named unit struct `Opaque` defined here -... LL | opaque; - | ^^^^^^ - | | - | not a value - | help: a unit struct with a similar name exists (notice the capitalization): `Opaque` + | ^^^^^^ not a value error: aborting due to 3 previous errors -- cgit v1.2.3