Fix more tests

This commit is contained in:
Deadbeef 2021-08-25 15:21:55 +00:00
parent ff24ac4f2b
commit 703c557aaa
No known key found for this signature in database
GPG Key ID: 027DF9338862ADDD
20 changed files with 103 additions and 50 deletions

View File

@ -927,7 +927,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.instantiate_poly_trait_ref(
&b.trait_ref,
b.span,
constness,
Constness::NotConst,
param_ty,
bounds,
false,
@ -937,7 +937,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.instantiate_poly_trait_ref(
&b.trait_ref,
b.span,
Constness::NotConst,
constness,
param_ty,
bounds,
false,

View File

@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-49296.rs:20:16
--> $DIR/issue-49296.rs:11:16
|
LL | const X: u64 = *wat(42);
| ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed

View File

@ -4,11 +4,11 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized`
LL | type Assoc = OnlySized<<T as Foo>::Item>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `Foo::Item`
--> $DIR/projection-bound-cycle-generic.rs:11:49
note: required by a bound in `OnlySized`
--> $DIR/projection-bound-cycle-generic.rs:28:18
|
LL | type Item: Sized where <Self as Foo>::Item: Sized;
| ^^^^^ required by this bound in `Foo::Item`
LL | struct OnlySized<T> where T: Sized { f: T }
| ^ required by this bound in `OnlySized`
error: aborting due to previous error

View File

@ -4,11 +4,11 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized`
LL | type Assoc = OnlySized<<T as Foo>::Item>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `Foo::Item`
--> $DIR/projection-bound-cycle.rs:13:49
note: required by a bound in `OnlySized`
--> $DIR/projection-bound-cycle.rs:30:18
|
LL | type Item: Sized where <Self as Foo>::Item: Sized;
| ^^^^^ required by this bound in `Foo::Item`
LL | struct OnlySized<T> where T: Sized { f: T }
| ^ required by this bound in `OnlySized`
error: aborting due to previous error

View File

@ -9,10 +9,10 @@ struct S<
T: Tr +, // OK
T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
T: ?const Tr, // OK
T: ?const ?Tr, // OK
T: ?const Tr + 'a, // OK
T: ?const 'a, //~ ERROR `?const` may only modify trait bounds, not lifetime bounds
T: ~const Tr, // OK
T: ~const ?Tr, // OK
T: ~const Tr + 'a, // OK
T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds
>;
fn main() {}

View File

@ -4,10 +4,10 @@ error: `?` may only modify trait bounds, not lifetime bounds
LL | T: ?'a,
| ^
error: `?const` may only modify trait bounds, not lifetime bounds
error: `~const` may only modify trait bounds, not lifetime bounds
--> $DIR/bounds-type.rs:15:8
|
LL | T: ?const 'a,
LL | T: ~const 'a,
| ^^^^^^
error: aborting due to 2 previous errors

View File

@ -6,7 +6,7 @@ fn foo1(_: &dyn Drop + AsRef<str>) {} //~ ERROR ambiguous `+` in a type
fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect braces around trait bounds
fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{`
//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
//~| ERROR at least one trait is required for an object type
fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<`

View File

@ -22,11 +22,11 @@ error: expected parameter name, found `{`
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
| ^ expected parameter name
error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
--> $DIR/trait-object-delimiters.rs:8:17
|
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
| -^ expected one of 8 possible tokens
| -^ expected one of 9 possible tokens
| |
| help: missing `,`

View File

@ -1,7 +1,5 @@
// FIXME(fee1-dead): this should have a better error message
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]
struct NonConstAdd(i32);
@ -14,7 +12,7 @@ impl std::ops::Add for NonConstAdd {
}
trait Foo {
type Bar: std::ops::Add;
type Bar: ~const std::ops::Add;
}
impl const Foo for NonConstAdd {
@ -23,7 +21,7 @@ impl const Foo for NonConstAdd {
}
trait Baz {
type Qux: ?const std::ops::Add;
type Qux: std::ops::Add;
}
impl const Baz for NonConstAdd {

View File

@ -1,15 +1,15 @@
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd`
--> $DIR/assoc-type.rs:21:5
--> $DIR/assoc-type.rs:19:5
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
= help: the trait `Add` is not implemented for `NonConstAdd`
note: required by a bound in `Foo::Bar`
--> $DIR/assoc-type.rs:17:15
--> $DIR/assoc-type.rs:15:15
|
LL | type Bar: std::ops::Add;
| ^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
LL | type Bar: ~const std::ops::Add;
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
|
LL | impl const Foo for NonConstAdd where NonConstAdd: Add {

View File

@ -6,7 +6,7 @@ trait MyPartialEq {
fn eq(&self, other: &Self) -> bool;
}
impl<T: PartialEq> const MyPartialEq for T {
impl<T: ~const PartialEq> const MyPartialEq for T {
fn eq(&self, other: &Self) -> bool {
PartialEq::eq(self, other)
}

View File

@ -16,11 +16,11 @@ impl const PartialEq for S {
}
}
const fn equals_self<T: PartialEq>(t: &T) -> bool {
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
*t == *t
}
const fn equals_self_wrapper<T: PartialEq>(t: &T) -> bool {
const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
equals_self(t)
}

View File

@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/call-generic-method-fail.rs:7:5
--> $DIR/call-generic-method-fail.rs:5:5
|
LL | *t == *t
| ^^^^^^^^

View File

@ -9,7 +9,7 @@ impl PartialEq for S {
}
}
const fn equals_self<T: PartialEq>(t: &T) -> bool {
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
true
}

View File

@ -8,8 +8,8 @@ LL | pub const EQ: bool = equals_self(&S);
note: required by a bound in `equals_self`
--> $DIR/call-generic-method-nonconst.rs:12:25
|
LL | const fn equals_self<T: PartialEq>(t: &T) -> bool {
| ^^^^^^^^^ required by this bound in `equals_self`
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^^^^^^^^^^^ required by this bound in `equals_self`
error: aborting due to previous error

View File

@ -16,7 +16,7 @@ impl const PartialEq for S {
}
}
const fn equals_self<T: PartialEq>(t: &T) -> bool {
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
*t == *t
}

View File

@ -0,0 +1,8 @@
error: expected a trait, found type
--> $DIR/impl-tilde-const-trait.rs:6:6
|
LL | impl ~const T for S {}
| ^^^^^^^^
error: aborting due to previous error

View File

@ -1,5 +1,5 @@
error: inherent impls cannot be `const`
--> $DIR/inherent-impl.rs:9:12
--> $DIR/inherent-impl.rs:7:12
|
LL | impl const S {}
| ----- ^ inherent impl for this type
@ -9,7 +9,7 @@ LL | impl const S {}
= note: only trait implementations may be annotated with `const`
error: inherent impls cannot be `const`
--> $DIR/inherent-impl.rs:12:12
--> $DIR/inherent-impl.rs:10:12
|
LL | impl const T {}
| ----- ^ inherent impl for this type

View File

@ -17,22 +17,13 @@ fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
//~^ ERROR `~const` is not allowed
fn generic<T: ~const T>() {}
fn generic<P: ~const T>() {}
//~^ ERROR `~const` is not allowed
fn where_clause<T>() where T: ~const T {}
fn where_clause<P>() where P: ~const T {}
//~^ ERROR `~const` is not allowed
impl ~const T {}
//~^ ERROR `~const` is not allowed
fn trait_object() -> &'static dyn ~const T { &S }
//~^ ERROR `~const` is not allowed
fn trait_object_in_apit(_: impl IntoIterator<Item = Box<dyn ~const T>>) {}
//~^ ERROR `~const` is not allowed
struct S<T: ~const ?Sized>(std::marker::PhantomData<T>);
struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
//~^ ERROR `~const` and `?` are mutually exclusive
fn main() {}

View File

@ -0,0 +1,56 @@
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:8:19
|
LL | fn rpit() -> impl ~const T { S }
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:11:17
|
LL | fn apit(_: impl ~const T) {}
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:14:50
|
LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:17:48
|
LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:20:15
|
LL | fn generic<P: ~const T>() {}
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` is not allowed here
--> $DIR/tilde-const-invalid-places.rs:23:31
|
LL | fn where_clause<P>() where P: ~const T {}
| ^^^^^^^^
|
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
error: `~const` and `?` are mutually exclusive
--> $DIR/tilde-const-invalid-places.rs:26:25
|
LL | struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
| ^^^^^^^^^^^^^
error: aborting due to 7 previous errors