2018-08-08 17:10:19 -05:00
|
|
|
// Unit test for the "user substitutions" that are annotated on each
|
|
|
|
// node.
|
|
|
|
|
|
|
|
// compile-flags:-Zverbose
|
|
|
|
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
2018-08-23 16:37:41 -05:00
|
|
|
// Note: we reference the names T and U in the comments below.
|
2018-08-08 17:10:19 -05:00
|
|
|
trait Bazoom<T> {
|
|
|
|
fn method<U>(&self, arg: T, arg2: U) { }
|
|
|
|
}
|
|
|
|
|
2019-02-11 15:09:47 -06:00
|
|
|
impl<S, T> Bazoom<T> for S {
|
2018-08-08 17:10:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn foo<'a, T>(_: T) { }
|
|
|
|
|
2023-07-11 16:35:29 -05:00
|
|
|
#[rustc_dump_user_args]
|
2018-08-08 17:10:19 -05:00
|
|
|
fn main() {
|
|
|
|
// Here: nothing is given, so we don't have any annotation.
|
|
|
|
let x = foo;
|
|
|
|
x(22);
|
|
|
|
|
2019-02-11 15:09:47 -06:00
|
|
|
// Here: `u32` is given, which doesn't contain any lifetimes, so we don't
|
|
|
|
// have any annotation.
|
|
|
|
let x = foo::<u32>;
|
2018-08-08 17:10:19 -05:00
|
|
|
x(22);
|
|
|
|
|
2019-02-11 15:09:47 -06:00
|
|
|
let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32]
|
|
|
|
x(&22);
|
|
|
|
|
2018-08-08 17:10:19 -05:00
|
|
|
// Here: we only want the `T` to be given, the rest should be variables.
|
2018-08-23 16:37:41 -05:00
|
|
|
//
|
|
|
|
// (`T` refers to the declaration of `Bazoom`)
|
2018-11-03 13:34:28 -05:00
|
|
|
let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1]
|
2018-08-08 17:10:19 -05:00
|
|
|
x(&22, 44, 66);
|
|
|
|
|
2019-02-11 15:09:47 -06:00
|
|
|
// Here: all are given and definitely contain no lifetimes, so we
|
|
|
|
// don't have any annotation.
|
|
|
|
let x = <u8 as Bazoom<u16>>::method::<u32>;
|
2018-08-08 17:10:19 -05:00
|
|
|
x(&22, 44, 66);
|
|
|
|
|
2019-02-11 15:09:47 -06:00
|
|
|
// Here: all are given and we have a lifetime.
|
|
|
|
let x = <u8 as Bazoom<&'static u16>>::method::<u32>; //~ ERROR [u8, &ReStatic u16, u32]
|
|
|
|
x(&22, &44, 66);
|
|
|
|
|
2018-08-08 17:10:19 -05:00
|
|
|
// Here: we want in particular that *only* the method `U`
|
|
|
|
// annotation is given, the rest are variables.
|
2018-08-23 16:37:41 -05:00
|
|
|
//
|
|
|
|
// (`U` refers to the declaration of `Bazoom`)
|
2018-08-08 17:10:19 -05:00
|
|
|
let y = 22_u32;
|
2018-11-03 13:34:28 -05:00
|
|
|
y.method::<u32>(44, 66); //~ ERROR [^0, ^1, u32]
|
2018-08-08 17:10:19 -05:00
|
|
|
|
|
|
|
// Here: nothing is given, so we don't have any annotation.
|
|
|
|
let y = 22_u32;
|
|
|
|
y.method(44, 66);
|
|
|
|
}
|