Skip to content

Commit d476d21

Browse files
authored
Rollup merge of rust-lang#104444 - chenyukang:yukang/fix-104390, r=compiler-errors
Fix ICE in in_operand for ty error Fixes rust-lang#104390 By the way, moving some test cases to proper directory for tidy bless.
2 parents 3c4be61 + 20ea083 commit d476d21

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ where
351351
// FIXME(valtrees): check whether const qualifs should behave the same
352352
// way for type and mir constants.
353353
let uneval = match constant.literal {
354-
ConstantKind::Ty(ct) if matches!(ct.kind(), ty::ConstKind::Param(_)) => None,
354+
ConstantKind::Ty(ct)
355+
if matches!(ct.kind(), ty::ConstKind::Param(_) | ty::ConstKind::Error(_)) =>
356+
{
357+
None
358+
}
355359
ConstantKind::Ty(c) => bug!("expected ConstKind::Param here, found {:?}", c),
356360
ConstantKind::Unevaluated(uv, _) => Some(uv),
357361
ConstantKind::Val(..) => None,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn f1() -> impl Sized { & 2E } //~ ERROR expected at least one digit in exponent
2+
fn f2() -> impl Sized { && 2E } //~ ERROR expected at least one digit in exponent
3+
fn f3() -> impl Sized { &'a 2E } //~ ERROR expected at least one digit in exponent
4+
//~^ ERROR borrow expressions cannot be annotated with lifetimes
5+
fn f4() -> impl Sized { &'static 2E } //~ ERROR expected at least one digit in exponent
6+
//~^ ERROR borrow expressions cannot be annotated with lifetimes
7+
fn f5() -> impl Sized { *& 2E } //~ ERROR expected at least one digit in exponent
8+
fn f6() -> impl Sized { &'_ 2E } //~ ERROR expected at least one digit in exponent
9+
//~^ ERROR borrow expressions cannot be annotated with lifetimes
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
error: expected at least one digit in exponent
2+
--> $DIR/issue-104390.rs:1:27
3+
|
4+
LL | fn f1() -> impl Sized { & 2E }
5+
| ^^
6+
7+
error: expected at least one digit in exponent
8+
--> $DIR/issue-104390.rs:2:28
9+
|
10+
LL | fn f2() -> impl Sized { && 2E }
11+
| ^^
12+
13+
error: expected at least one digit in exponent
14+
--> $DIR/issue-104390.rs:3:29
15+
|
16+
LL | fn f3() -> impl Sized { &'a 2E }
17+
| ^^
18+
19+
error: expected at least one digit in exponent
20+
--> $DIR/issue-104390.rs:5:34
21+
|
22+
LL | fn f4() -> impl Sized { &'static 2E }
23+
| ^^
24+
25+
error: expected at least one digit in exponent
26+
--> $DIR/issue-104390.rs:7:28
27+
|
28+
LL | fn f5() -> impl Sized { *& 2E }
29+
| ^^
30+
31+
error: expected at least one digit in exponent
32+
--> $DIR/issue-104390.rs:8:29
33+
|
34+
LL | fn f6() -> impl Sized { &'_ 2E }
35+
| ^^
36+
37+
error: borrow expressions cannot be annotated with lifetimes
38+
--> $DIR/issue-104390.rs:3:25
39+
|
40+
LL | fn f3() -> impl Sized { &'a 2E }
41+
| ^--^^^
42+
| |
43+
| annotated with lifetime here
44+
| help: remove the lifetime annotation
45+
46+
error: borrow expressions cannot be annotated with lifetimes
47+
--> $DIR/issue-104390.rs:5:25
48+
|
49+
LL | fn f4() -> impl Sized { &'static 2E }
50+
| ^-------^^^
51+
| |
52+
| annotated with lifetime here
53+
| help: remove the lifetime annotation
54+
55+
error: borrow expressions cannot be annotated with lifetimes
56+
--> $DIR/issue-104390.rs:8:25
57+
|
58+
LL | fn f6() -> impl Sized { &'_ 2E }
59+
| ^--^^^
60+
| |
61+
| annotated with lifetime here
62+
| help: remove the lifetime annotation
63+
64+
error: aborting due to 9 previous errors
65+

0 commit comments

Comments
 (0)