Skip to content

Rollup of 7 pull requests #97126

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

Merged
merged 25 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b712135
rustdoc-json-types: Improve docs for HRTB fields
Enselic May 2, 2022
1f15ce5
rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate
Enselic May 2, 2022
774b525
rustdoc-json: Add tests for all three HRTB fields
Enselic May 4, 2022
7f11749
rustdoc: don't build `rayon` for non-windows targets
klensy May 6, 2022
03007de
Omit unnecessary help to add `#[cfg(test)]` when already annotated
ken-matsui May 2, 2022
17f2893
Types with reachable constructors are reachable
tmiasko May 17, 2022
658be0d
Add tmm_reg clobbers
chorman0773 May 17, 2022
50ce367
add clobbers
chorman0773 May 17, 2022
89ab77b
Handle tmm_reg in rustc_codegen_gcc
chorman0773 May 17, 2022
6354bfc
Add ABI clobbers
chorman0773 May 17, 2022
eabe851
fix clobber_abi tests
chorman0773 May 17, 2022
e170d87
Update browser-ui-test version to 0.9.2
GuillaumeGomez May 16, 2022
d765b73
Fix duplicated "in" in the search result text
GuillaumeGomez May 17, 2022
5601044
Add GUI test for search result "title"
GuillaumeGomez May 17, 2022
0f8b3f4
Fix display of search crate filter select
GuillaumeGomez May 17, 2022
440bbce
Add GUI test for search crate filter select CSS properties
GuillaumeGomez May 17, 2022
501f5d0
interpret/validity: reject references to uninhabited types
RalfJung May 17, 2022
201750d
bless 32bit
RalfJung May 17, 2022
ce49ce2
Rollup merge of #96647 - Enselic:fix-hrtb-for-wherepredicate, r=Craft…
JohnTitor May 17, 2022
78c709c
Rollup merge of #96651 - ken-matsui:omit-unnecessary-help-to-add-cfg-…
JohnTitor May 17, 2022
e9f3733
Rollup merge of #96761 - klensy:no-rayon-here, r=CraftSpider
JohnTitor May 17, 2022
f597846
Rollup merge of #97096 - tmiasko:reachable-constructor, r=petrochenkov
JohnTitor May 17, 2022
7361b22
Rollup merge of #97097 - chorman0773:add_tmm_clobers, r=joshtriplett
JohnTitor May 17, 2022
b8dd270
Rollup merge of #97113 - GuillaumeGomez:search-ui-fixes, r=notriddle
JohnTitor May 17, 2022
248890c
Rollup merge of #97116 - RalfJung:ref-validity, r=oli-obk
JohnTitor May 17, 2022
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
interpret/validity: reject references to uninhabited types
  • Loading branch information
RalfJung committed May 17, 2022
commit 501f5d09a0920c66d50fc898ae7649794ea26fa3
17 changes: 11 additions & 6 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,22 +412,27 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
self.path,
err_ub!(AlignmentCheckFailed { required, has }) =>
{
"an unaligned {} (required {} byte alignment but found {})",
kind,
"an unaligned {kind} (required {} byte alignment but found {})",
required.bytes(),
has.bytes()
},
err_ub!(DanglingIntPointer(0, _)) =>
{ "a null {}", kind },
{ "a null {kind}" },
err_ub!(DanglingIntPointer(i, _)) =>
{ "a dangling {} (address 0x{:x} is unallocated)", kind, i },
{ "a dangling {kind} (address 0x{i:x} is unallocated)" },
err_ub!(PointerOutOfBounds { .. }) =>
{ "a dangling {} (going beyond the bounds of its allocation)", kind },
{ "a dangling {kind} (going beyond the bounds of its allocation)" },
// This cannot happen during const-eval (because interning already detects
// dangling pointers), but it can happen in Miri.
err_ub!(PointerUseAfterFree(..)) =>
{ "a dangling {} (use-after-free)", kind },
{ "a dangling {kind} (use-after-free)" },
);
// Do not allow pointers to uninhabited types.
if place.layout.abi.is_uninhabited() {
throw_validation_failure!(self.path,
{ "a {kind} pointing to uninhabited type {}", place.layout.ty }
)
}
// Recursive checking
if let Some(ref mut ref_tracking) = self.ref_tracking {
// Proceed recursively even for ZST, no reason to skip them!
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-uninhabit.rs:18:1
|
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>: encountered a value of uninhabited type Bar
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type Bar
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/validate_never_arrays.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/validate_never_arrays.rs:4:1
|
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>[0]: encountered a value of the never type `!`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type [!; 1]
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
Expand Down