Check the self-type of inherent associated constants
This commit is contained in:
parent
de111e6367
commit
283ffcfce7
7 changed files with 74 additions and 30 deletions
|
|
@ -15,5 +15,7 @@ fn main() {
|
|||
|
||||
SomeStruct::<_> { t: 22 }; // Nothing interesting given, no annotation.
|
||||
|
||||
SomeStruct::<u32> { t: 22 }; //~ ERROR [u32]
|
||||
SomeStruct::<u32> { t: 22 }; // No lifetime bounds given.
|
||||
|
||||
SomeStruct::<&'static u32> { t: &22 }; //~ ERROR [&ReStatic u32]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: user substs: UserSubsts { substs: [u32], user_self_ty: None }
|
||||
--> $DIR/dump-adt-brace-struct.rs:18:5
|
||||
error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None }
|
||||
--> $DIR/dump-adt-brace-struct.rs:20:5
|
||||
|
|
||||
LL | SomeStruct::<u32> { t: 22 }; //~ ERROR [u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | SomeStruct::<&'static u32> { t: &22 }; //~ ERROR [&ReStatic u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ trait Bazoom<T> {
|
|||
fn method<U>(&self, arg: T, arg2: U) { }
|
||||
}
|
||||
|
||||
impl<T, U> Bazoom<U> for T {
|
||||
impl<S, T> Bazoom<T> for S {
|
||||
}
|
||||
|
||||
fn foo<'a, T>(_: T) { }
|
||||
|
|
@ -22,20 +22,29 @@ fn main() {
|
|||
let x = foo;
|
||||
x(22);
|
||||
|
||||
// Here: `u32` is given.
|
||||
let x = foo::<u32>; //~ ERROR [u32]
|
||||
// Here: `u32` is given, which doesn't contain any lifetimes, so we don't
|
||||
// have any annotation.
|
||||
let x = foo::<u32>;
|
||||
x(22);
|
||||
|
||||
let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32]
|
||||
x(&22);
|
||||
|
||||
// Here: we only want the `T` to be given, the rest should be variables.
|
||||
//
|
||||
// (`T` refers to the declaration of `Bazoom`)
|
||||
let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1]
|
||||
x(&22, 44, 66);
|
||||
|
||||
// Here: all are given
|
||||
let x = <u8 as Bazoom<u16>>::method::<u32>; //~ ERROR [u8, u16, u32]
|
||||
// Here: all are given and definitely contain no lifetimes, so we
|
||||
// don't have any annotation.
|
||||
let x = <u8 as Bazoom<u16>>::method::<u32>;
|
||||
x(&22, 44, 66);
|
||||
|
||||
// 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);
|
||||
|
||||
// Here: we want in particular that *only* the method `U`
|
||||
// annotation is given, the rest are variables.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
error: user substs: UserSubsts { substs: [u32], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:26:13
|
||||
error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:30:13
|
||||
|
|
||||
LL | let x = foo::<u32>; //~ ERROR [u32]
|
||||
| ^^^^^^^^^^
|
||||
LL | let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: user substs: UserSubsts { substs: [^0, u32, ^1], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:32:13
|
||||
--> $DIR/dump-fn-method.rs:36:13
|
||||
|
|
||||
LL | let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: user substs: UserSubsts { substs: [u8, u16, u32], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:36:13
|
||||
error: user substs: UserSubsts { substs: [u8, &ReStatic u16, u32], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:45:13
|
||||
|
|
||||
LL | let x = <u8 as Bazoom<u16>>::method::<u32>; //~ ERROR [u8, u16, u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | let x = <u8 as Bazoom<&'static u16>>::method::<u32>; //~ ERROR [u8, &ReStatic u16, u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: user substs: UserSubsts { substs: [^0, ^1, u32], user_self_ty: None }
|
||||
--> $DIR/dump-fn-method.rs:44:5
|
||||
--> $DIR/dump-fn-method.rs:53:5
|
||||
|
|
||||
LL | y.method::<u32>(44, 66); //~ ERROR [^0, ^1, u32]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
#![feature(nll)]
|
||||
|
||||
struct A<'a>(&'a ());
|
||||
|
||||
impl A<'static> {
|
||||
const IC: i32 = 10;
|
||||
}
|
||||
|
||||
fn non_wf_associated_const<'a>(x: i32) {
|
||||
A::<'a>::IC; //~ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn wf_associated_const<'a>(x: i32) {
|
||||
A::<'static>::IC;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/inherent-associated-constants.rs:10:5
|
||||
|
|
||||
LL | fn non_wf_associated_const<'a>(x: i32) {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | A::<'a>::IC; //~ ERROR lifetime may not live long enough
|
||||
| ^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue