Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #122457

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bf62d59
Give `TRACK_DIAGNOSTIC` a return value.
nnethercote Feb 9, 2024
ecd3718
Inline and remove `Level::get_diagnostic_id`.
nnethercote Feb 13, 2024
272e60b
Move `DelayedBug` handling into the `match`.
nnethercote Feb 13, 2024
c81767e
Reorder `has_future_breakage` handling.
nnethercote Feb 13, 2024
aec4bdb
Move `Expect`/`ForceWarning` handling into the `match`.
nnethercote Feb 13, 2024
a7d9262
Add comments about `TRACK_DIAGNOSTIC` use.
nnethercote Feb 13, 2024
7ef605b
Make the `match` in `emit_diagnostic` complete.
nnethercote Mar 1, 2024
15b71f4
Add CStr::bytes iterator
clarfonthey Nov 13, 2022
c076509
Add methods to create constants
celinval Mar 1, 2024
893a910
Add a test to SMIR body transformation
celinval Mar 12, 2024
a38a556
Reduce unsafe code, use more NonNull APIs per @cuviper review
clarfonthey Mar 12, 2024
f2fcfe8
Various style improvements to `rustc_lint::levels`
Zalathar Mar 13, 2024
bf71825
CFI: Break tests into smaller files
rcvalle Mar 12, 2024
90acda1
Fix accidental re-addition of removed code in a previous PR
oli-obk Mar 13, 2024
f10ebfe
Generalize `eval_in_interpreter` with a helper trait
oli-obk Mar 11, 2024
44b1f8a
Move only usage of `take_static_root_alloc` to its definition and inl…
oli-obk Mar 11, 2024
31fa142
Move error handling into const_validate_mplace
oli-obk Mar 11, 2024
71ef9e2
Move InterpCx into eval_in_interpreter
oli-obk Mar 11, 2024
bd7580b
Move generate_stacktrace_from_stack away from InterpCx to avoid havin…
oli-obk Mar 11, 2024
7aee665
Directly pass in the stack instead of computing it from a machine
oli-obk Mar 11, 2024
ffaf082
Remove an argument that can be computed cheaply
oli-obk Mar 12, 2024
66a46bb
Share the `InterpCx` creation between static and const evaluation
oli-obk Mar 12, 2024
af59eec
Move validation into eval_body_using_ecx
oli-obk Mar 12, 2024
2a1a6fa
Move the entire success path into `eval_body_using_ecx`
oli-obk Mar 12, 2024
3393227
Rename some things around validation error reporting to signal that i…
oli-obk Mar 13, 2024
b6312eb
Create some minimal HIR for associated opaque types
petrochenkov Feb 11, 2024
12cd322
Make incremental sessions identity no longer depend on the crate name…
Zoxc Feb 28, 2024
514b274
const-eval: organize and extend tests for required-consts
RalfJung Mar 13, 2024
11e1f53
Rollup merge of #104353 - clarfonthey:cstr-bytes-iter, r=cuviper
matthiaskrgr Mar 13, 2024
0eab80b
Rollup merge of #120699 - nnethercote:rm-useless-TRACK_DIAGNOSTIC-cal…
matthiaskrgr Mar 13, 2024
f4e9710
Rollup merge of #120943 - petrochenkov:somehir3, r=oli-obk
matthiaskrgr Mar 13, 2024
e4d89a8
Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk
matthiaskrgr Mar 13, 2024
0f8bae1
Rollup merge of #122375 - rcvalle:rust-cfi-break-tests-into-smaller-f…
matthiaskrgr Mar 13, 2024
c99ae2b
Rollup merge of #122397 - oli-obk:machine-read-hook2, r=RalfJung
matthiaskrgr Mar 13, 2024
74f8248
Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk
matthiaskrgr Mar 13, 2024
f4d4443
Rollup merge of #122416 - Zalathar:levels, r=petrochenkov
matthiaskrgr Mar 13, 2024
b76648f
Rollup merge of #122440 - RalfJung:required-consts, r=oli-obk
matthiaskrgr Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move only usage of take_static_root_alloc to its definition and inl…
…ine it
  • Loading branch information
oli-obk committed Mar 13, 2024
commit 44b1f8a5c54118d6798f251da0fd57e9537a7829
18 changes: 4 additions & 14 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::errors;
use crate::errors::ConstEvalError;
use crate::interpret::eval_nullary_intrinsic;
use crate::interpret::{
create_static_alloc, intern_const_alloc_recursive, take_static_root_alloc, CtfeValidationMode,
GlobalId, Immediate, InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind,
OpTy, RefTracking, StackPopCleanup,
create_static_alloc, intern_const_alloc_recursive, CtfeValidationMode, GlobalId, Immediate,
InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking,
StackPopCleanup,
};

// Returns a pointer to where the result lives
Expand Down Expand Up @@ -293,7 +293,7 @@ pub fn eval_static_initializer_provider<'tcx>(
eval_in_interpreter(&mut ecx, cid, true)
}

trait InterpretationResult<'tcx> {
pub trait InterpretationResult<'tcx> {
/// This function takes the place where the result of the evaluation is stored
/// and prepares it for returning it in the appropriate format needed by the specific
/// evaluation query.
Expand All @@ -303,16 +303,6 @@ trait InterpretationResult<'tcx> {
) -> Self;
}

impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {
fn make_result<'mir>(
mplace: MPlaceTy<'tcx>,
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
) -> Self {
let alloc = take_static_root_alloc(ecx, mplace.ptr().provenance.unwrap().alloc_id());
ecx.tcx.mk_const_alloc(alloc)
}
}

impl<'tcx> InterpretationResult<'tcx> for ConstAlloc<'tcx> {
fn make_result<'mir>(
mplace: MPlaceTy<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub fn intern_const_alloc_recursive<
// This gives us the initial set of nested allocations, which will then all be processed
// recursively in the loop below.
let mut todo: Vec<_> = if is_static {
// Do not steal the root allocation, we need it later for `take_static_root_alloc`
// Do not steal the root allocation, we need it later to create the return value of `eval_static_initializer`.
// But still change its mutability to match the requested one.
let alloc = ecx.memory.alloc_map.get_mut(&base_alloc_id).unwrap();
alloc.1.mutability = base_mutability;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ use self::{
};

pub(crate) use self::intrinsics::eval_nullary_intrinsic;
pub(crate) use self::util::{create_static_alloc, take_static_root_alloc};
pub(crate) use self::util::create_static_alloc;
use eval_context::{from_known_layout, mir_assign_valid_types};
21 changes: 13 additions & 8 deletions compiler/rustc_const_eval/src/interpret/util.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::const_eval::CompileTimeEvalContext;
use crate::const_eval::{CompileTimeEvalContext, CompileTimeInterpreter, InterpretationResult};
use crate::interpret::{MemPlaceMeta, MemoryKind};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::mir::interpret::{AllocId, Allocation, InterpResult, Pointer};
use rustc_middle::mir;
use rustc_middle::mir::interpret::{Allocation, InterpResult, Pointer};
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
};
use std::ops::ControlFlow;

use super::MPlaceTy;
use super::{InterpCx, MPlaceTy};

/// Checks whether a type contains generic parameters which must be instantiated.
///
Expand Down Expand Up @@ -80,11 +81,15 @@ where
}
}

pub(crate) fn take_static_root_alloc<'mir, 'tcx: 'mir>(
ecx: &mut CompileTimeEvalContext<'mir, 'tcx>,
alloc_id: AllocId,
) -> Allocation {
ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1
impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {
fn make_result<'mir>(
mplace: MPlaceTy<'tcx>,
ecx: &mut InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
) -> Self {
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();
let alloc = ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1;
ecx.tcx.mk_const_alloc(alloc)
}
}

pub(crate) fn create_static_alloc<'mir, 'tcx: 'mir>(
Expand Down