Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4ee18c9
Clean up E0124 explanation
GuillaumeGomez Dec 22, 2019
1474d2a
Clean up E0128 explanation
GuillaumeGomez Dec 22, 2019
101dd7b
Use `is_none` instead of `if let`
JohnTitor Dec 22, 2019
7c485cc
Add test for issue-61747
JohnTitor Dec 22, 2019
96253c2
Add test for issue-66205
JohnTitor Dec 22, 2019
6ec3a63
Add test for issue-66270
JohnTitor Dec 22, 2019
256eec4
Update E0124.md
Dylan-DPC Dec 23, 2019
1485c16
Add long error code explanation message for E0627
ldm0 Dec 23, 2019
587d03b
Yield is an expression form, not a statement.
ldm0 Dec 23, 2019
24f3dcf
remove `description` from `Error` impls in docs
euclio Dec 23, 2019
1f2fa93
Add test for issue-67424
JohnTitor Dec 22, 2019
d918319
Apply suggestion from Centril
JohnTitor Dec 22, 2019
2536c75
Don't ICE on the use of integer addresses for ZST constants in patter…
oli-obk Dec 13, 2019
cc5cc67
Retire `to_ptr` which should already have no users but still kept get…
oli-obk Dec 13, 2019
8be7c54
Simplify `force_allocation_maybe_sized`
oli-obk Dec 13, 2019
53ca738
Comment on a few odd things that we should look at
oli-obk Dec 13, 2019
6976435
Prevent an ICE on invalid transmutes
oli-obk Dec 13, 2019
68ecc21
Interning even happens when validation of a constant fails
oli-obk Dec 14, 2019
c4f9215
Immediately evaluate and validate constants when we want them as oper…
oli-obk Dec 20, 2019
7ef8cf4
Add regression test for ZST statics being allowed to "read" from them…
oli-obk Dec 20, 2019
58eec17
Explain ParamEnv::reveal_all usage
oli-obk Dec 22, 2019
51937ef
Comments should start capitalized and end in a period
oli-obk Dec 22, 2019
5b278bc
Explain what we are doing with parameter environments for statics
oli-obk Dec 22, 2019
efbbc69
Explain the currently necessary existance of `TransmuteSizeDiff`
oli-obk Dec 22, 2019
405dbc6
Remove unintended noisy log statement
oli-obk Dec 22, 2019
eabe066
Typo
oli-obk Dec 22, 2019
af8ca7a
Explain why `const_eval` is ok here
oli-obk Dec 22, 2019
4c40bb7
Early abort instead of building up zero sized values
oli-obk Dec 22, 2019
09dd13c
Add a `const_eval` helper to `InterpCx`
oli-obk Dec 22, 2019
79960b4
Documentation nit
oli-obk Dec 22, 2019
e9dc860
Reintroduce the recursion comment
oli-obk Dec 22, 2019
aaf7015
Use the targetted const eval functions
oli-obk Dec 23, 2019
65bb805
Fix rebase fallout
oli-obk Dec 23, 2019
cefeb66
Use the chocolatey CDN directly to avoid the flaky API
aidanhs Dec 23, 2019
df4d490
Minimize unsafety in encode_utf8
Mark-Simulacrum Dec 23, 2019
318c52f
Rollup merge of #67192 - oli-obk:const_zst_addr, r=RalfJung,varkor
Mark-Simulacrum Dec 24, 2019
587f694
Rollup merge of #67543 - JohnTitor:regression-tests, r=Centril
Mark-Simulacrum Dec 24, 2019
93116b2
Rollup merge of #67547 - GuillaumeGomez:cleanup-err-codes, r=Dylan-DPC
Mark-Simulacrum Dec 24, 2019
8a1015f
Rollup merge of #67551 - ldm0:E0627, r=Dylan-DPC
Mark-Simulacrum Dec 24, 2019
b8b9a0f
Rollup merge of #67561 - euclio:remove-description, r=jonas-schievink
Mark-Simulacrum Dec 24, 2019
cb5e4ab
Rollup merge of #67569 - Mark-Simulacrum:opt-char-encode, r=oli-obk
Mark-Simulacrum Dec 24, 2019
37f97de
Rollup merge of #67572 - aidanhs:aphs-choco-direct-cdn, r=Mark-Simula…
Mark-Simulacrum Dec 24, 2019
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
Retire to_ptr which should already have no users but still kept get…
…ting new ones
  • Loading branch information
oli-obk committed Dec 23, 2019
commit cc5cc6744b5ae5a5ee6db0db80448aa12a5d45f6
9 changes: 2 additions & 7 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ impl<'tcx, Tag> Scalar<Tag> {
}

/// Do not call this method! Use either `assert_ptr` or `force_ptr`.
/// This method is intentionally private, do not make it public.
#[inline]
pub fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
match self {
Scalar::Raw { data: 0, .. } => throw_unsup!(InvalidNullPointerUsage),
Scalar::Raw { .. } => throw_unsup!(ReadBytesAsPointer),
Expand Down Expand Up @@ -544,12 +545,6 @@ impl<'tcx, Tag> ScalarMaybeUndef<Tag> {
}
}

/// Do not call this method! Use either `assert_ptr` or `force_ptr`.
#[inline(always)]
pub fn to_ptr(self) -> InterpResult<'tcx, Pointer<Tag>> {
self.not_undef()?.to_ptr()
}

/// Do not call this method! Use either `assert_bits` or `force_bits`.
#[inline(always)]
pub fn to_bits(self, target_size: Size) -> InterpResult<'tcx, u128> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
Ok(ConstValue::Scalar(a_val))
} else if let ty::FnPtr(_) = a.ty.kind {
let alloc_map = tcx.alloc_map.lock();
let a_instance = alloc_map.unwrap_fn(a_val.to_ptr().unwrap().alloc_id);
let b_instance = alloc_map.unwrap_fn(b_val.to_ptr().unwrap().alloc_id);
let a_instance = alloc_map.unwrap_fn(a_val.assert_ptr().alloc_id);
let b_instance = alloc_map.unwrap_fn(b_val.assert_ptr().alloc_id);
if a_instance == b_instance {
Ok(ConstValue::Scalar(a_val))
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn op_to_const<'tcx>(
};
let val = match immediate {
Ok(mplace) => {
let ptr = mplace.ptr.to_ptr().unwrap();
let ptr = mplace.ptr.assert_ptr();
let alloc = ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
ConstValue::ByRef { alloc, offset: ptr.offset }
},
Expand All @@ -99,7 +99,7 @@ fn op_to_const<'tcx>(
// comes from a constant so it can happen have `Undef`, because the indirect
// memory that was read had undefined bytes.
let mplace = op.assert_mem_place();
let ptr = mplace.ptr.to_ptr().unwrap();
let ptr = mplace.ptr.assert_ptr();
let alloc = ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
ConstValue::ByRef { alloc, offset: ptr.offset }
},
Expand Down Expand Up @@ -626,7 +626,7 @@ fn validate_and_turn_into_const<'tcx>(
// whether they become immediates.
let def_id = cid.instance.def.def_id();
if tcx.is_static(def_id) || cid.promoted.is_some() {
let ptr = mplace.ptr.to_ptr()?;
let ptr = mplace.ptr.assert_ptr();
Ok(tcx.mk_const(ty::Const {
val: ty::ConstKind::Value(ConstValue::ByRef {
alloc: ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id),
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// FIXME: should we tell the user that there was a local which was never written to?
if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local {
trace!("deallocating local");
let ptr = ptr.to_ptr()?;
// All locals have a backing allocation, even if the allocation is empty
// due to the local having ZST type.
let ptr = ptr.assert_ptr();
if log_enabled!(::log::Level::Trace) {
self.memory.dump_alloc(ptr.alloc_id);
}
Expand Down
15 changes: 9 additions & 6 deletions src/librustc_mir/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ impl<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx
if let ty::Dynamic(..) =
self.ecx.tcx.struct_tail_erasing_lifetimes(referenced_ty, self.ecx.param_env).kind
{
if let Ok(vtable) = mplace.meta.unwrap().to_ptr() {
// explitly choose `Immutable` here, since vtables are immutable, even
// if the reference of the fat pointer is mutable
self.intern_shallow(vtable.alloc_id, Mutability::Not, None)?;
}
// Validation has already errored on an invalid vtable pointer so this `assert_ptr`
// will never panic.
let vtable = mplace.meta.unwrap().assert_ptr();
// explitly choose `Immutable` here, since vtables are immutable, even
// if the reference of the fat pointer is mutable
self.intern_shallow(vtable.alloc_id, Mutability::Not, None)?;
}
// Check if we have encountered this pointer+layout combination before.
// Only recurse for allocation-backed pointers.
Expand Down Expand Up @@ -281,7 +282,9 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
ecx,
leftover_allocations,
base_intern_mode,
ret.ptr.to_ptr()?.alloc_id,
// The outermost allocation must exist, because we allocated it with
// `Memory::allocate`.
ret.ptr.assert_ptr().alloc_id,
base_mutability,
Some(ret.layout.ty),
)?;
Expand Down