Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b1774b8

Browse files
committed
Fix tests
1 parent b4079c6 commit b1774b8

19 files changed

+356
-92
lines changed

‎tests/crashes/133199.rs‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎tests/crashes/136894.rs‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎tests/crashes/137813.rs‎

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(generic_arg_infer, associated_const_equality, generic_const_items)]
2+
#![expect(incomplete_features)]
3+
4+
// Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even
5+
// though it contained inference variables, which would cause ICEs.
6+
7+
trait Foo {
8+
const ASSOC<const N: u32>: u32;
9+
}
10+
11+
impl Foo for () {
12+
const ASSOC<const N: u32>: u32 = N;
13+
}
14+
15+
fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
16+
17+
fn main() {
18+
bar::<_, ()>();
19+
//~^ ERROR: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
20+
21+
// FIXME(mgca):
22+
// FIXME(associated_const_equality):
23+
// This ought to start compiling once const items are aliases rather than bodies
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0271]: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
2+
--> $DIR/equality_bound_with_infer.rs:18:14
3+
|
4+
LL | bar::<_, ()>();
5+
| ^^ expected `10`, found `<() as Foo>::ASSOC::<_>`
6+
|
7+
= note: expected constant `10`
8+
found constant `<() as Foo>::ASSOC::<_>`
9+
note: required by a bound in `bar`
10+
--> $DIR/equality_bound_with_infer.rs:15:29
11+
|
12+
LL | fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
13+
| ^^^^^^^^^^^^^ required by this bound in `bar`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0271`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// regression test for #137813 where we would assume all constants in the type system
2+
// cannot contain inference variables, even though associated const equality syntax
3+
// was still lowered without the feature gate enabled.
4+
5+
trait AssocConst {
6+
const A: u8;
7+
}
8+
9+
impl<T> AssocConst for (T,) {
10+
const A: u8 = 0;
11+
}
12+
13+
trait Trait {}
14+
15+
impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
16+
//~^ ERROR associated const equality is incomplete
17+
//~| ERROR the type parameter `U` is not constrained by the impl trait
18+
19+
fn foo()
20+
where
21+
(): Trait,
22+
//~^ ERROR type mismatch resolving
23+
{
24+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0658]: associated const equality is incomplete
2+
--> $DIR/unconstrained_impl_param.rs:15:45
3+
|
4+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
5+
| ^^^^^^^^^
6+
|
7+
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
8+
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
12+
--> $DIR/unconstrained_impl_param.rs:15:6
13+
|
14+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
15+
| ^ unconstrained type parameter
16+
17+
error[E0271]: type mismatch resolving `<(_,) as AssocConst>::A == 0`
18+
--> $DIR/unconstrained_impl_param.rs:21:5
19+
|
20+
LL | (): Trait,
21+
| ^^^^^^^^^ expected `0`, found `<(_,) as AssocConst>::A`
22+
|
23+
= note: expected constant `0`
24+
found constant `<(_,) as AssocConst>::A`
25+
note: required for `()` to implement `Trait`
26+
--> $DIR/unconstrained_impl_param.rs:15:9
27+
|
28+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
29+
| ^^^^^ ^^ --------- unsatisfied trait bound introduced here
30+
= help: see issue #48214
31+
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
32+
|
33+
LL + #![feature(trivial_bounds)]
34+
|
35+
36+
error: aborting due to 3 previous errors
37+
38+
Some errors have detailed explanations: E0207, E0271, E0658.
39+
For more information about an error, try `rustc --explain E0207`.

‎tests/crashes/auxiliary/aux133199.rs‎ renamed to ‎tests/ui/const-generics/generic_const_exprs/auxiliary/cross-crate-2.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(incomplete_features)]
22
#![feature(generic_const_exprs)]
33

4-
pub struct FixedBitSet<const N: usize>;
4+
pub struct Foo<const N: usize>;
55

6-
impl<const N: usize> FixedBitSet<N>
6+
impl<const N: usize> Foo<N>
77
where
88
[u8; N.div_ceil(8)]: Sized,
99
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ check-pass
2+
//@ aux-build: cross-crate-2.rs
3+
4+
extern crate cross_crate_2;
5+
6+
use cross_crate_2::Foo;
7+
8+
fn main() {
9+
Foo::<7>::new();
10+
}

‎tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: generic parameters may not be used in const operations
2-
--> $DIR/dependence_lint.rs:14:32
2+
--> $DIR/dependence_lint.rs:15:32
33
|
44
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
55
| ^ cannot perform const operation using `T`
@@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
88
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
11-
--> $DIR/dependence_lint.rs:21:37
11+
--> $DIR/dependence_lint.rs:22:37
1212
|
1313
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
1414
| ^ cannot perform const operation using `T`
@@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_
2727
= note: `#[warn(const_evaluatable_unchecked)]` on by default
2828

2929
warning: cannot use constants which depend on generic parameters in types
30-
--> $DIR/dependence_lint.rs:17:9
30+
--> $DIR/dependence_lint.rs:18:9
3131
|
3232
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /