Skip to content

Commit 703c557

Browse files
committed
Fix more tests
1 parent ff24ac4 commit 703c557

20 files changed

+103
-50
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
927927
self.instantiate_poly_trait_ref(
928928
&b.trait_ref,
929929
b.span,
930-
constness,
930+
Constness::NotConst,
931931
param_ty,
932932
bounds,
933933
false,
@@ -937,7 +937,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
937937
self.instantiate_poly_trait_ref(
938938
&b.trait_ref,
939939
b.span,
940-
Constness::NotConst,
940+
constness,
941941
param_ty,
942942
bounds,
943943
false,

src/test/ui/consts/const-eval/issue-49296.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/issue-49296.rs:20:16
2+
--> $DIR/issue-49296.rs:11:16
33
|
44
LL | const X: u64 = *wat(42);
55
| ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed

src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized`
44
LL | type Assoc = OnlySized<<T as Foo>::Item>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
note: required by a bound in `Foo::Item`
8-
--> $DIR/projection-bound-cycle-generic.rs:11:49
7+
note: required by a bound in `OnlySized`
8+
--> $DIR/projection-bound-cycle-generic.rs:28:18
99
|
10-
LL | type Item: Sized where <Self as Foo>::Item: Sized;
11-
| ^^^^^ required by this bound in `Foo::Item`
10+
LL | struct OnlySized<T> where T: Sized { f: T }
11+
| ^ required by this bound in `OnlySized`
1212

1313
error: aborting due to previous error
1414

src/test/ui/generic-associated-types/projection-bound-cycle.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Item: Sized`
44
LL | type Assoc = OnlySized<<T as Foo>::Item>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
note: required by a bound in `Foo::Item`
8-
--> $DIR/projection-bound-cycle.rs:13:49
7+
note: required by a bound in `OnlySized`
8+
--> $DIR/projection-bound-cycle.rs:30:18
99
|
10-
LL | type Item: Sized where <Self as Foo>::Item: Sized;
11-
| ^^^^^ required by this bound in `Foo::Item`
10+
LL | struct OnlySized<T> where T: Sized { f: T }
11+
| ^ required by this bound in `OnlySized`
1212

1313
error: aborting due to previous error
1414

src/test/ui/parser/bounds-type.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ struct S<
99
T: Tr +, // OK
1010
T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
1111

12-
T: ?const Tr, // OK
13-
T: ?const ?Tr, // OK
14-
T: ?const Tr + 'a, // OK
15-
T: ?const 'a, //~ ERROR `?const` may only modify trait bounds, not lifetime bounds
12+
T: ~const Tr, // OK
13+
T: ~const ?Tr, // OK
14+
T: ~const Tr + 'a, // OK
15+
T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds
1616
>;
1717

1818
fn main() {}

src/test/ui/parser/bounds-type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ error: `?` may only modify trait bounds, not lifetime bounds
44
LL | T: ?'a,
55
| ^
66

7-
error: `?const` may only modify trait bounds, not lifetime bounds
7+
error: `~const` may only modify trait bounds, not lifetime bounds
88
--> $DIR/bounds-type.rs:15:8
99
|
10-
LL | T: ?const 'a,
10+
LL | T: ~const 'a,
1111
| ^^^^^^
1212

1313
error: aborting due to 2 previous errors

src/test/ui/parser/trait-object-delimiters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn foo1(_: &dyn Drop + AsRef<str>) {} //~ ERROR ambiguous `+` in a type
66
fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect braces around trait bounds
77

88
fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{`
9-
//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
9+
//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
1010
//~| ERROR at least one trait is required for an object type
1111

1212
fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<`

src/test/ui/parser/trait-object-delimiters.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ error: expected parameter name, found `{`
2222
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
2323
| ^ expected parameter name
2424

25-
error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
25+
error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
2626
--> $DIR/trait-object-delimiters.rs:8:17
2727
|
2828
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
29-
| -^ expected one of 8 possible tokens
29+
| -^ expected one of 9 possible tokens
3030
| |
3131
| help: missing `,`
3232

src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// FIXME(fee1-dead): this should have a better error message
22
#![feature(const_trait_impl)]
3-
#![feature(const_trait_bound_opt_out)]
4-
#![allow(incomplete_features)]
53

64
struct NonConstAdd(i32);
75

@@ -14,7 +12,7 @@ impl std::ops::Add for NonConstAdd {
1412
}
1513

1614
trait Foo {
17-
type Bar: std::ops::Add;
15+
type Bar: ~const std::ops::Add;
1816
}
1917

2018
impl const Foo for NonConstAdd {
@@ -23,7 +21,7 @@ impl const Foo for NonConstAdd {
2321
}
2422

2523
trait Baz {
26-
type Qux: ?const std::ops::Add;
24+
type Qux: std::ops::Add;
2725
}
2826

2927
impl const Baz for NonConstAdd {

src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd`
2-
--> $DIR/assoc-type.rs:21:5
2+
--> $DIR/assoc-type.rs:19:5
33
|
44
LL | type Bar = NonConstAdd;
55
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
66
|
77
= help: the trait `Add` is not implemented for `NonConstAdd`
88
note: required by a bound in `Foo::Bar`
9-
--> $DIR/assoc-type.rs:17:15
9+
--> $DIR/assoc-type.rs:15:15
1010
|
11-
LL | type Bar: std::ops::Add;
12-
| ^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
11+
LL | type Bar: ~const std::ops::Add;
12+
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
1313
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
1414
|
1515
LL | impl const Foo for NonConstAdd where NonConstAdd: Add {

src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trait MyPartialEq {
66
fn eq(&self, other: &Self) -> bool;
77
}
88

9-
impl<T: PartialEq> const MyPartialEq for T {
9+
impl<T: ~const PartialEq> const MyPartialEq for T {
1010
fn eq(&self, other: &Self) -> bool {
1111
PartialEq::eq(self, other)
1212
}

src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ impl const PartialEq for S {
1616
}
1717
}
1818

19-
const fn equals_self<T: PartialEq>(t: &T) -> bool {
19+
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
2020
*t == *t
2121
}
2222

23-
const fn equals_self_wrapper<T: PartialEq>(t: &T) -> bool {
23+
const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
2424
equals_self(t)
2525
}
2626

src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2-
--> $DIR/call-generic-method-fail.rs:7:5
2+
--> $DIR/call-generic-method-fail.rs:5:5
33
|
44
LL | *t == *t
55
| ^^^^^^^^

src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl PartialEq for S {
99
}
1010
}
1111

12-
const fn equals_self<T: PartialEq>(t: &T) -> bool {
12+
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
1313
true
1414
}
1515

src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ LL | pub const EQ: bool = equals_self(&S);
88
note: required by a bound in `equals_self`
99
--> $DIR/call-generic-method-nonconst.rs:12:25
1010
|
11-
LL | const fn equals_self<T: PartialEq>(t: &T) -> bool {
12-
| ^^^^^^^^^ required by this bound in `equals_self`
11+
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
12+
| ^^^^^^^^^^^^^^^^ required by this bound in `equals_self`
1313

1414
error: aborting due to previous error
1515

src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl const PartialEq for S {
1616
}
1717
}
1818

19-
const fn equals_self<T: PartialEq>(t: &T) -> bool {
19+
const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
2020
*t == *t
2121
}
2222

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected a trait, found type
2+
--> $DIR/impl-tilde-const-trait.rs:6:6
3+
|
4+
LL | impl ~const T for S {}
5+
| ^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: inherent impls cannot be `const`
2-
--> $DIR/inherent-impl.rs:9:12
2+
--> $DIR/inherent-impl.rs:7:12
33
|
44
LL | impl const S {}
55
| ----- ^ inherent impl for this type
@@ -9,7 +9,7 @@ LL | impl const S {}
99
= note: only trait implementations may be annotated with `const`
1010

1111
error: inherent impls cannot be `const`
12-
--> $DIR/inherent-impl.rs:12:12
12+
--> $DIR/inherent-impl.rs:10:12
1313
|
1414
LL | impl const T {}
1515
| ----- ^ inherent impl for this type

src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,13 @@ fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
1717
fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
1818
//~^ ERROR `~const` is not allowed
1919

20-
fn generic<T: ~const T>() {}
20+
fn generic<P: ~const T>() {}
2121
//~^ ERROR `~const` is not allowed
2222

23-
fn where_clause<T>() where T: ~const T {}
23+
fn where_clause<P>() where P: ~const T {}
2424
//~^ ERROR `~const` is not allowed
2525

26-
impl ~const T {}
27-
//~^ ERROR `~const` is not allowed
28-
29-
fn trait_object() -> &'static dyn ~const T { &S }
30-
//~^ ERROR `~const` is not allowed
31-
32-
fn trait_object_in_apit(_: impl IntoIterator<Item = Box<dyn ~const T>>) {}
33-
//~^ ERROR `~const` is not allowed
34-
35-
struct S<T: ~const ?Sized>(std::marker::PhantomData<T>);
26+
struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
3627
//~^ ERROR `~const` and `?` are mutually exclusive
3728

3829
fn main() {}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
error: `~const` is not allowed here
2+
--> $DIR/tilde-const-invalid-places.rs:8:19
3+
|
4+
LL | fn rpit() -> impl ~const T { S }
5+
| ^^^^^^^^
6+
|
7+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
8+
9+
error: `~const` is not allowed here
10+
--> $DIR/tilde-const-invalid-places.rs:11:17
11+
|
12+
LL | fn apit(_: impl ~const T) {}
13+
| ^^^^^^^^
14+
|
15+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
16+
17+
error: `~const` is not allowed here
18+
--> $DIR/tilde-const-invalid-places.rs:14:50
19+
|
20+
LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
21+
| ^^^^^^^^
22+
|
23+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
24+
25+
error: `~const` is not allowed here
26+
--> $DIR/tilde-const-invalid-places.rs:17:48
27+
|
28+
LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
29+
| ^^^^^^^^
30+
|
31+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
32+
33+
error: `~const` is not allowed here
34+
--> $DIR/tilde-const-invalid-places.rs:20:15
35+
|
36+
LL | fn generic<P: ~const T>() {}
37+
| ^^^^^^^^
38+
|
39+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
40+
41+
error: `~const` is not allowed here
42+
--> $DIR/tilde-const-invalid-places.rs:23:31
43+
|
44+
LL | fn where_clause<P>() where P: ~const T {}
45+
| ^^^^^^^^
46+
|
47+
= note: only allowed on bounds on traits' associated types, const fns, const impls and its associated functions
48+
49+
error: `~const` and `?` are mutually exclusive
50+
--> $DIR/tilde-const-invalid-places.rs:26:25
51+
|
52+
LL | struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
53+
| ^^^^^^^^^^^^^
54+
55+
error: aborting due to 7 previous errors
56+

0 commit comments

Comments
 (0)