Skip to content

Commit

Permalink
Make "parent also has host effect param?" a span_delayed_bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Feb 22, 2024
1 parent 4a11628 commit 96f609a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {

if is_host_effect {
if let Some(idx) = host_effect_index {
tcx.dcx().span_bug(
tcx.dcx().span_delayed_bug(
param.span,
format!("parent also has host effect param? index: {idx}, def: {def_id:?}"),
);
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/generics/issue-121418.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(const_trait_impl)]
#![feature(effects)]

struct S;
trait T {}

impl const dyn T {
//~^ ERROR inherent impls cannot be `const`
//~| ERROR the const parameter `host` is not constrained by the impl trait, self type, or
pub const fn new() -> std::sync::Mutex<dyn T> {}
}

fn main() {}
22 changes: 22 additions & 0 deletions tests/ui/generics/issue-121418.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error: inherent impls cannot be `const`
--> $DIR/issue-121418.rs:7:12
|
LL | impl const dyn T {
| ----- ^^^^^ inherent impl for this type
| |
| `const` because of this
|
= note: only trait implementations may be annotated with `const`

error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-121418.rs:7:6
|
LL | impl const dyn T {
| ^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0207`.

0 comments on commit 96f609a

Please sign in to comment.