Skip to content

Commit 96f609a

Browse files
committed
Make "parent also has host effect param?" a span_delayed_bug.
Fixes rust-lang#121418.
1 parent 4a11628 commit 96f609a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
315315

316316
if is_host_effect {
317317
if let Some(idx) = host_effect_index {
318-
tcx.dcx().span_bug(
318+
tcx.dcx().span_delayed_bug(
319319
param.span,
320320
format!("parent also has host effect param? index: {idx}, def: {def_id:?}"),
321321
);

tests/ui/generics/issue-121418.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(const_trait_impl)]
2+
#![feature(effects)]
3+
4+
struct S;
5+
trait T {}
6+
7+
impl const dyn T {
8+
//~^ ERROR inherent impls cannot be `const`
9+
//~| ERROR the const parameter `host` is not constrained by the impl trait, self type, or
10+
pub const fn new() -> std::sync::Mutex<dyn T> {}
11+
}
12+
13+
fn main() {}

tests/ui/generics/issue-121418.stderr

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: inherent impls cannot be `const`
2+
--> $DIR/issue-121418.rs:7:12
3+
|
4+
LL | impl const dyn T {
5+
| ----- ^^^^^ inherent impl for this type
6+
| |
7+
| `const` because of this
8+
|
9+
= note: only trait implementations may be annotated with `const`
10+
11+
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
12+
--> $DIR/issue-121418.rs:7:6
13+
|
14+
LL | impl const dyn T {
15+
| ^^^^^ unconstrained const parameter
16+
|
17+
= note: expressions using a const parameter must map each value to a distinct output value
18+
= note: proving the result of expressions other than the parameter are unique is not supported
19+
20+
error: aborting due to 2 previous errors
21+
22+
For more information about this error, try `rustc --explain E0207`.

0 commit comments

Comments
 (0)