diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2021-08-25 15:21:55 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2021-08-27 05:07:38 +0000 |
| commit | 703c557aaa48ba647f6fafea2330819a8bbe6734 (patch) | |
| tree | 0f9a09b4a0aaabed162d556b8fe4a05e2d9b3319 | |
| parent | ff24ac4f2b1415cc93e0cc3edb70097df6dae073 (diff) | |
| download | rust-703c557aaa48ba647f6fafea2330819a8bbe6734.tar.gz rust-703c557aaa48ba647f6fafea2330819a8bbe6734.zip | |
Fix more tests
20 files changed, 103 insertions, 50 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index d916ff7db3d..b7054d15626 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -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, diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 28fdcb7c486..bc3074b10be 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -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 diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr index 5e7e72ca562..2b57c439fe9 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr @@ -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 diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr index 1153bf53ba4..d9d0bf4274b 100644 --- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr +++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr @@ -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 diff --git a/src/test/ui/parser/bounds-type.rs b/src/test/ui/parser/bounds-type.rs index 7a187a0518a..4ae4549ea58 100644 --- a/src/test/ui/parser/bounds-type.rs +++ b/src/test/ui/parser/bounds-type.rs @@ -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() {} diff --git a/src/test/ui/parser/bounds-type.stderr b/src/test/ui/parser/bounds-type.stderr index 9a1f2ed3982..005bc1e54bd 100644 --- a/src/test/ui/parser/bounds-type.stderr +++ b/src/test/ui/parser/bounds-type.stderr @@ -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 diff --git a/src/test/ui/parser/trait-object-delimiters.rs b/src/test/ui/parser/trait-object-delimiters.rs index 650ab572261..b5258eebb90 100644 --- a/src/test/ui/parser/trait-object-delimiters.rs +++ b/src/test/ui/parser/trait-object-delimiters.rs @@ -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 `<` diff --git a/src/test/ui/parser/trait-object-delimiters.stderr b/src/test/ui/parser/trait-object-delimiters.stderr index 1ae0205615c..ee638d8a4f5 100644 --- a/src/test/ui/parser/trait-object-delimiters.stderr +++ b/src/test/ui/parser/trait-object-delimiters.stderr @@ -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 `,` diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs index 1dbd000afd7..228b5ed71e8 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs @@ -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 { diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr index ada29ba3f8b..b894092205e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr @@ -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 { diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs index 536c1d73740..4b706a190e6 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs @@ -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) } diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs index f3391aa6346..adf8d4f9ea5 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs @@ -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) } diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr index 4b2fc56aaa7..818c5828696 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr @@ -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 | ^^^^^^^^ diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs index 8343974f8c7..6881db0aa02 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs @@ -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 } diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr index 7cc54e0129a..9b9bda7c90e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr @@ -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 diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs index aee88d6053e..aa9bd4d824e 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs @@ -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 } diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr new file mode 100644 index 00000000000..0a91719e1f1 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr @@ -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 + diff --git a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr index 834f6a409f5..8c55627031d 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr @@ -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 diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs index a8912705d94..b4302f3e75f 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs @@ -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() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr new file mode 100644 index 00000000000..b026099f682 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr @@ -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 + |
