Skip to content

Commit 1120301

Browse files
committed
uwu error message
1 parent e94b1b9 commit 1120301

File tree

20 files changed

+187
-27
lines changed

20 files changed

+187
-27
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 2 additions & 2 deletions
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() {
16+
if !(ty.needs_subst() || ty.has_opaque_types()) {
1717
return Ok(());
1818
}
1919

@@ -31,7 +31,7 @@ where
3131
}
3232

3333
match *ty.kind() {
34-
ty::Param(_) => ControlFlow::Break(FoundParam),
34+
ty::Param(_) | ty::Opaque(..) => ControlFlow::Break(FoundParam),
3535
ty::Closure(def_id, substs)
3636
| ty::Generator(def_id, substs, ..)
3737
| ty::FnDef(def_id, substs) => {

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
186186
let concrete = infcx.const_eval_resolve(param_env, uv.expand(), Some(span));
187187
match concrete {
188188
Err(ErrorHandled::TooGeneric) => {
189-
Err(NotConstEvaluatable::Error(infcx.tcx.sess.delay_span_bug(
189+
Err(NotConstEvaluatable::Error(infcx.tcx.sess.span_err(
190190
span,
191-
format!("Missing value for constant, but no error reported?"),
191+
format!("unable to use constant with a hidden value in the type system"),
192192
)))
193193
}
194194
Err(ErrorHandled::Linted) => {
@@ -237,11 +237,13 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
237237

238238
Err(ErrorHandled::TooGeneric) => Err(if uv.has_infer_types_or_consts() {
239239
NotConstEvaluatable::MentionsInfer
240-
} else if uv.has_param_types_or_consts() {
240+
} else if uv.has_param_types_or_consts() {
241241
NotConstEvaluatable::MentionsParam
242242
} else {
243-
let guar = infcx.tcx.sess.delay_span_bug(span, format!("Missing value for constant, but no error reported?"));
244-
NotConstEvaluatable::Error(guar)
243+
NotConstEvaluatable::Error(infcx.tcx.sess.span_err(
244+
span,
245+
format!("unable to use constant with a hidden value in the type system"),
246+
))
245247
}),
246248
Err(ErrorHandled::Linted) => {
247249
let reported =

src/test/ui/const-generics/generic_const_exprs/issue-76595.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
1414
fn main() {
1515
test::<2>();
1616
//~^ ERROR this function takes 2 generic arguments
17+
//~| ERROR unable to use constant with a hidden value in the type system
1718
}

src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ help: add missing generic argument
1616
LL | test::<2, P>();
1717
| +++
1818

19-
error: aborting due to previous error
19+
error: unable to use constant with a hidden value in the type system
20+
--> $DIR/issue-76595.rs:15:5
21+
|
22+
LL | test::<2>();
23+
| ^^^^^^^^^
24+
25+
error: aborting due to 2 previous errors
2026

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ where
1515
fn unit_literals() {
1616
z(" ");
1717
//~^ ERROR: the trait bound `&str: X` is not satisfied
18+
//~| ERROR: unable to use constant with a hidden value in the type system
1819
}
1920

2021
fn main() {}

src/test/ui/const-generics/issues/issue-86530.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error: unable to use constant with a hidden value in the type system
2+
--> $DIR/issue-86530.rs:16:5
3+
|
4+
LL | z(" ");
5+
| ^
6+
17
error[E0277]: the trait bound `&str: X` is not satisfied
28
--> $DIR/issue-86530.rs:16:7
39
|
@@ -15,6 +21,6 @@ LL | where
1521
LL | T: X,
1622
| ^ required by this bound in `z`
1723

18-
error: aborting due to previous error
24+
error: aborting due to 2 previous errors
1925

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

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

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

7+
// FIXME: We should mention that `N` is missing
78
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
1314
{}
1415

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

107
error: aborting due to previous error
118

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

src/test/ui/impl-trait/in-ctfe/array-len.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This previously compiled, but broke with #101478.
1+
// This previously compiled, but was intentionally changed in #101478.
22
//
33
// See that PR for more details.
44
trait MyTrait: Copy {
@@ -19,5 +19,7 @@ const fn output<T: MyTrait>(_: T) -> usize {
1919

2020
fn main() {
2121
let x = [0u8; output(yeet())];
22+
//~^ ERROR unable to use constant with a hidden value in the type system
2223
println!("{:?}", x);
24+
//~^ ERROR unable to use constant with a hidden value in the type system
2325
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: unable to use constant with a hidden value in the type system
2+
--> $DIR/array-len.rs:21:19
3+
|
4+
LL | let x = [0u8; output(yeet())];
5+
| ^^^^^^^^^^^^^^
6+
7+
error: unable to use constant with a hidden value in the type system
8+
--> $DIR/array-len.rs:23:22
9+
|
10+
LL | println!("{:?}", x);
11+
| ^
12+
|
13+
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
error: aborting due to 2 previous errors
16+

0 commit comments

Comments
 (0)