Skip to content

Commit

Permalink
Add test of NtTy in a qpath
Browse files Browse the repository at this point in the history
Currently fails:

    error: expected identifier, found `ToOwned`
      --> src/test/ui/macros/macro-interpolation.rs:23:19
       |
    LL |         <$type as $trait>::$name
       |                   ^^^^^^ expected identifier
    ...
    LL |     let _: qpath!(ty, <str as ToOwned>::Owned);
       |            -----------------------------------
       |            |
       |            this macro call doesn't expand to a type
       |            in this macro invocation
  • Loading branch information
dtolnay committed Nov 25, 2021
1 parent 01800ca commit 558ddee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/test/ui/macros/macro-interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ macro_rules! overly_complicated {
}

macro_rules! qpath {
(<$type:ty as $trait:path>::$name:ident) => {
(path, <$type:ty as $trait:path>::$name:ident) => {
<$type as $trait>::$name
};

(ty, <$type:ty as $trait:ty>::$name:ident) => {
<$type as $trait>::$name
};
}

pub fn main() {
let _: qpath!(<str as ToOwned>::Owned);
let _: qpath!(path, <str as ToOwned>::Owned);
let _: qpath!(ty, <str as ToOwned>::Owned);

assert!(overly_complicated!(f, x, Option<usize>, { return Some(x); },
Some(8), Some(y), y) == 8)
Expand Down

0 comments on commit 558ddee

Please sign in to comment.