Skip to content

Commit ec12977

Browse files
committed
Auto merge of #115762 - oli-obk:early_const_prop_lint2, r=<try>
Avoid revealing in layout_of r? `@compiler-errors` I feel like `layout_of` is doing too many things at once, and I don't really know why. It could allow us to if callers could decide whether to reveal opaque types.
2 parents 3ebb562 + 21e8d63 commit ec12977

File tree

12 files changed

+28
-28
lines changed

12 files changed

+28
-28
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ build/
5252
/src/tools/x/target
5353
# Created by default with `src/ci/docker/run.sh`
5454
/obj/
55+
# Created on ICE during build
56+
rustc-ice-*.txt
5557

5658
## Temporary files
5759
*~

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
324324
param_env: ty::ParamEnv<'tcx>,
325325
) -> Result<SizeSkeleton<'tcx>, &'tcx LayoutError<'tcx>> {
326326
debug_assert!(!ty.has_non_region_infer());
327+
let param_env = param_env.with_reveal_all_normalized(tcx);
327328

328329
// First try computing a static layout.
329330
let err = match tcx.layout_of(param_env.and(ty)) {

compiler/rustc_mir_transform/src/const_prop_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
176176
) -> ConstPropagator<'mir, 'tcx> {
177177
let def_id = body.source.def_id();
178178
let args = &GenericArgs::identity_for_item(tcx, def_id);
179-
let param_env = tcx.param_env_reveal_all_normalized(def_id);
179+
let param_env = tcx.param_env(def_id);
180180

181181
let can_const_prop = CanConstProp::check(tcx, param_env, body);
182182
let mut ecx = InterpCx::new(

compiler/rustc_passes/src/layout_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn ensure_wf<'tcx>(
6666
}
6767

6868
fn dump_layout_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribute) {
69-
let param_env = tcx.param_env(item_def_id);
69+
let param_env = tcx.param_env_reveal_all_normalized(item_def_id);
7070
let ty = tcx.type_of(item_def_id).instantiate_identity();
7171
let span = tcx.def_span(item_def_id.to_def_id());
7272
if !ensure_wf(tcx, param_env, ty, item_def_id, span) {

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,10 @@ pub fn typeid_for_instance<'tcx>(
11061106
options: TypeIdOptions,
11071107
) -> String {
11081108
let fn_abi = tcx
1109-
.fn_abi_of_instance(tcx.param_env(instance.def_id()).and((*instance, ty::List::empty())))
1109+
.fn_abi_of_instance(
1110+
tcx.param_env_reveal_all_normalized(instance.def_id())
1111+
.and((*instance, ty::List::empty())),
1112+
)
11101113
.unwrap_or_else(|instance| {
11111114
bug!("typeid_for_instance: couldn't get fn_abi of instance {:?}", instance)
11121115
});

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn layout_of<'tcx>(
3636
let (param_env, ty) = query.into_parts();
3737
debug!(?ty);
3838

39-
let param_env = param_env.with_reveal_all_normalized(tcx);
4039
let unnormalized_ty = ty;
4140

4241
// FIXME: We might want to have two different versions of `layout_of`:

src/etc/rust_analyzer_settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"compiler/rustc_codegen_gcc/Cargo.toml"
1717
],
1818
"rust-analyzer.rustfmt.overrideCommand": [
19-
"./build/host/rustfmt/bin/rustfmt",
19+
"${workspaceFolder}/build/host/rustfmt/bin/rustfmt",
2020
"--edition=2021"
2121
],
2222
"rust-analyzer.procMacro.server": "./build/host/stage0/libexec/rust-analyzer-proc-macro-srv",

tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-249
44
LL | const BAR: u32 = IMPL_REF_BAR;
55
| ^^^^^^^^^^^^
66
|
7-
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
8-
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
9-
|
10-
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^
127
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
138
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:27
149
|

tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0391]: cycle detected when elaborating drops for `FooDefault::BAR`
44
LL | const BAR: u32 = DEFAULT_REF_BAR;
55
| ^^^^^^^^^^^^^^^
66
|
7-
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
8-
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
9-
|
10-
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
127
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
138
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:30
149
|

tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-249
44
LL | const BAR: u32 = TRAIT_REF_BAR;
55
| ^^^^^^^^^^^^^
66
|
7-
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
8-
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
9-
|
10-
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^
127
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
138
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:28
149
|

0 commit comments

Comments
 (0)