Skip to content

Commit 3a8bad9

Browse files
authoredSep 23, 2022
Rollup merge of #102137 - b-naber:lazy-const-val-conversion, r=lcnr
Don't convert valtree to constvalue during normalization r? ``@lcnr``
2 parents 3de0d67 + ded3eda commit 3a8bad9

File tree

3 files changed

+7
-54
lines changed

3 files changed

+7
-54
lines changed
 

Diff for: ‎compiler/rustc_trait_selection/src/traits/query/normalize.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
351351
&mut self,
352352
constant: mir::ConstantKind<'tcx>,
353353
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
354-
Ok(match constant {
355-
mir::ConstantKind::Ty(c) => {
356-
let const_folded = c.try_super_fold_with(self)?;
357-
match const_folded.kind() {
358-
ty::ConstKind::Value(valtree) => {
359-
let tcx = self.infcx.tcx;
360-
let ty = const_folded.ty();
361-
let const_val = tcx.valtree_to_const_val((ty, valtree));
362-
debug!(?ty, ?valtree, ?const_val);
363-
364-
mir::ConstantKind::Val(const_val, ty)
365-
}
366-
_ => mir::ConstantKind::Ty(const_folded),
367-
}
368-
}
369-
mir::ConstantKind::Val(_, _) | mir::ConstantKind::Unevaluated(..) => {
370-
constant.try_super_fold_with(self)?
371-
}
372-
})
354+
constant.try_super_fold_with(self)
373355
}
374356

375357
#[inline]

Diff for: ‎src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ mod assert {
2424
Src,
2525
Context,
2626
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
27-
//~^ ERROR E0080
28-
//~| ERROR E0080
29-
//~| ERROR E0080
30-
//~| ERROR E0080
3127
>,
3228
{}
3329

Original file line numberDiff line numberDiff line change
@@ -1,52 +1,27 @@
11
error[E0308]: mismatched types
2-
--> $DIR/wrong-type-assume.rs:53:51
2+
--> $DIR/wrong-type-assume.rs:49:51
33
|
44
LL | assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>();
55
| ^^^ expected `bool`, found `u8`
66

7-
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, {0u8}, false, false, false>::{constant#0}` failed
8-
--> $DIR/wrong-type-assume.rs:26:15
9-
|
10-
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
12-
137
error[E0308]: mismatched types
14-
--> $DIR/wrong-type-assume.rs:54:58
8+
--> $DIR/wrong-type-assume.rs:50:58
159
|
1610
LL | assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>();
1711
| ^^^ expected `bool`, found `u8`
1812

19-
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, {0u8}, false, false>::{constant#0}` failed
20-
--> $DIR/wrong-type-assume.rs:26:15
21-
|
22-
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
24-
2513
error[E0308]: mismatched types
26-
--> $DIR/wrong-type-assume.rs:55:65
14+
--> $DIR/wrong-type-assume.rs:51:65
2715
|
2816
LL | assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>();
2917
| ^^^ expected `bool`, found `u8`
3018

31-
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, false, {0u8}, false>::{constant#0}` failed
32-
--> $DIR/wrong-type-assume.rs:26:15
33-
|
34-
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
36-
3719
error[E0308]: mismatched types
38-
--> $DIR/wrong-type-assume.rs:56:72
20+
--> $DIR/wrong-type-assume.rs:52:72
3921
|
4022
LL | assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>();
4123
| ^^^ expected `bool`, found `u8`
4224

43-
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, false, false, {0u8}>::{constant#0}` failed
44-
--> $DIR/wrong-type-assume.rs:26:15
45-
|
46-
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
48-
49-
error: aborting due to 8 previous errors
25+
error: aborting due to 4 previous errors
5026

51-
Some errors have detailed explanations: E0080, E0308.
52-
For more information about an error, try `rustc --explain E0080`.
27+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.