]> git.lizzy.rs Git - rust.git/blob - tests/ui/resolve/issue-100365.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / resolve / issue-100365.rs
1 fn main() {
2     let addr = Into::<std::net::IpAddr>.into([127, 0, 0, 1]);
3     //~^ ERROR expected value, found trait `Into`
4     //~| HELP use the path separator
5
6     let _ = Into.into(());
7     //~^ ERROR expected value, found trait `Into`
8     //~| HELP use the path separator
9
10     let _ = Into::<()>.into;
11     //~^ ERROR expected value, found trait `Into`
12     //~| HELP use the path separator
13 }
14
15 macro_rules! Trait {
16     () => {
17         ::std::iter::Iterator
18         //~^ ERROR expected value, found trait `std::iter::Iterator`
19         //~| ERROR expected value, found trait `std::iter::Iterator`
20     };
21 }
22
23 macro_rules! create {
24     () => {
25         Into::<String>.into("")
26         //~^ ERROR expected value, found trait `Into`
27         //~| HELP use the path separator
28     };
29 }
30
31 fn interaction_with_macros() {
32     //
33     // Note that if the receiver is a macro call, we do not want to suggest to replace
34     // `.` with `::` as that would be a syntax error.
35     // Since the receiver is a trait and not a type, we cannot suggest to surround
36     // it with angle brackets. It would be interpreted as a trait object type void of
37     // `dyn` which is most likely not what the user intended to write.
38     // `<_ as Trait!()>::` is also not an option as it's equally syntactically invalid.
39     //
40
41     Trait!().map(std::convert::identity); // no `help` here!
42
43     Trait!().map; // no `help` here!
44
45     //
46     // Ensure that the suggestion is shown for expressions inside of macro definitions.
47     //
48
49     let _ = create!();
50 }