Add test of NtTy in a qpath

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
This commit is contained in:
David Tolnay 2021-11-22 19:58:18 -08:00
parent 01800caddf
commit 558ddee2ce
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -15,13 +15,18 @@ fn $fnname($arg: $ty) -> Option<$ty> $body
}
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)