Skip to content

Commit dc56653

Browse files
committed
resolve_instance: ErrorReported for missing value
1 parent 1120301 commit dc56653

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ where
1313
T: TypeVisitable<'tcx>,
1414
{
1515
debug!("ensure_monomorphic_enough: ty={:?}", ty);
16-
if !(ty.needs_subst() || ty.has_opaque_types()) {
16+
if !(ty.needs_subst() || ty.has_opaque_types()) {
1717
return Ok(());
1818
}
1919

compiler/rustc_ty_utils/src/instance.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,11 @@ fn resolve_associated_item<'tcx>(
279279

280280
// If the item does not have a value, then we cannot return an instance.
281281
if !leaf_def.item.defaultness(tcx).has_value() {
282-
return Ok(None);
282+
let guard = tcx.sess.delay_span_bug(
283+
tcx.def_span(leaf_def.item.def_id),
284+
"missing value for assoc item in impl",
285+
);
286+
return Err(guard);
283287
}
284288

285289
let substs = tcx.erase_regions(substs);

src/test/ui/const-generics/issues/issue-98629.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ trait Trait {
44
const N: usize;
55
}
66

7-
// FIXME: We should mention that `N` is missing
87
impl const Trait for i32 {}
8+
//~^ ERROR not all trait items implemented, missing: `N`
99

1010
fn f()
1111
where
1212
[(); <i32 as Trait>::N]:,
13-
//~^ ERROR unable to use constant with a hidden value in the type system
1413
{}
1514

1615
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
error: unable to use constant with a hidden value in the type system
2-
--> $DIR/issue-98629.rs:11:5
1+
error[E0046]: not all trait items implemented, missing: `N`
2+
--> $DIR/issue-98629.rs:7:1
33
|
4-
LL | [(); <i32 as Trait>::N]:,
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | const N: usize;
5+
| -------------- `N` from trait
6+
...
7+
LL | impl const Trait for i32 {}
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing `N` in implementation
69

710
error: aborting due to previous error
811

12+
For more information about this error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)