From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/resolve/issue-100365.rs | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/ui/resolve/issue-100365.rs (limited to 'tests/ui/resolve/issue-100365.rs') diff --git a/tests/ui/resolve/issue-100365.rs b/tests/ui/resolve/issue-100365.rs new file mode 100644 index 000000000..1d8835036 --- /dev/null +++ b/tests/ui/resolve/issue-100365.rs @@ -0,0 +1,50 @@ +fn main() { + let addr = Into::.into([127, 0, 0, 1]); + //~^ ERROR expected value, found trait `Into` + //~| HELP use the path separator + + let _ = Into.into(()); + //~^ ERROR expected value, found trait `Into` + //~| HELP use the path separator + + let _ = Into::<()>.into; + //~^ ERROR expected value, found trait `Into` + //~| HELP use the path separator +} + +macro_rules! Trait { + () => { + ::std::iter::Iterator + //~^ ERROR expected value, found trait `std::iter::Iterator` + //~| ERROR expected value, found trait `std::iter::Iterator` + }; +} + +macro_rules! create { + () => { + Into::.into("") + //~^ ERROR expected value, found trait `Into` + //~| HELP use the path separator + }; +} + +fn interaction_with_macros() { + // + // Note that if the receiver is a macro call, we do not want to suggest to replace + // `.` with `::` as that would be a syntax error. + // Since the receiver is a trait and not a type, we cannot suggest to surround + // it with angle brackets. It would be interpreted as a trait object type void of + // `dyn` which is most likely not what the user intended to write. + // `<_ as Trait!()>::` is also not an option as it's equally syntactically invalid. + // + + Trait!().map(std::convert::identity); // no `help` here! + + Trait!().map; // no `help` here! + + // + // Ensure that the suggestion is shown for expressions inside of macro definitions. + // + + let _ = create!(); +} -- cgit v1.2.3