Skip to content

Commit 87fbf3c

Browse files
committed
ignore type flags insertion in default_anon_const_substs if error occurred
1 parent 4e0d397 commit 87fbf3c

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ pub(super) fn default_anon_const_substs(tcx: TyCtxt<'_>, def_id: DefId) -> Subst
292292
// Getting this wrong can lead to ICE and unsoundness, so we assert it here.
293293
for arg in substs.iter() {
294294
let allowed_flags = ty::TypeFlags::MAY_NEED_DEFAULT_CONST_SUBSTS
295-
| ty::TypeFlags::STILL_FURTHER_SPECIALIZABLE;
295+
| ty::TypeFlags::STILL_FURTHER_SPECIALIZABLE
296+
| ty::TypeFlags::HAS_ERROR;
296297
assert!(!arg.has_type_flags(!allowed_flags));
297298
}
298299
substs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![allow(incomplete_features)]
2+
#![feature(generic_const_exprs)]
3+
4+
struct ConstAssert<const COND: bool>;
5+
trait True {}
6+
impl True for ConstAssert<true> {}
7+
8+
struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T)
9+
//~^ ERROR the type of const parameters must not depend on other generic parameters
10+
//~| ERROR the type of const parameters must not depend on other generic parameters
11+
where
12+
ConstAssert<{ MIN <= MAX }>: True;
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0770]: the type of const parameters must not depend on other generic parameters
2+
--> $DIR/issue-88997.rs:8:40
3+
|
4+
LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T)
5+
| ^ the type must not depend on the parameter `T`
6+
7+
error[E0770]: the type of const parameters must not depend on other generic parameters
8+
--> $DIR/issue-88997.rs:8:54
9+
|
10+
LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T)
11+
| ^ the type must not depend on the parameter `T`
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0770`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct Foo<T, const H: T>(T)
5+
//~^ ERROR the type of const parameters must not depend on other generic parameters
6+
where
7+
[(); 1]:;
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0770]: the type of const parameters must not depend on other generic parameters
2+
--> $DIR/issue-90364.rs:4:28
3+
|
4+
LL | pub struct Foo<T, const H: T>(T)
5+
| ^ the type must not depend on the parameter `T`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0770`.

0 commit comments

Comments
 (0)