Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e852cc
remove redundant clones (clippy::redundant_clone)
matthiaskrgr Dec 24, 2020
a8775d4
Edit rustc_span documentation
pierwill Dec 24, 2020
1b77f8e
Constify intrinsics::copy[_nonoverlapping]
usbalbin Dec 26, 2020
7594d2a
Constify ptr::read and ptr::read_unaligned
usbalbin Dec 26, 2020
d4fd798
Constify *const T::read[_unaligned] and *mut T::read[_unaligned]
usbalbin Dec 26, 2020
1975a6e
Constify MaybeUninit::assume_init_read
usbalbin Dec 26, 2020
5e27765
Add tests
usbalbin Dec 26, 2020
0cea1c9
Added reference to tracking issue #80377
usbalbin Dec 26, 2020
0f25712
Revert "Cleanup markdown span handling"
Dec 26, 2020
7ac02bd
Don't give an error when creating a file for the first time
jyn514 Dec 27, 2020
c482ffd
bump rust-installer submodule
pietroalbini Dec 14, 2020
2f58422
Improvements to NatVis support
sivadeilra Dec 22, 2020
122e91c
promotion: factor some common code into validate_ref
RalfJung Dec 28, 2020
c177e68
merge two match'es for more exhaustiveness
RalfJung Dec 28, 2020
8d5dc8c
Add missing commas to `rustc_ast_pretty::pp` docs
camelid Dec 28, 2020
4a90a58
make more matches exhaustive
RalfJung Dec 28, 2020
0a2034d
bootstrap: add the dist.compression-formats option
pietroalbini Dec 14, 2020
d0d0ee0
ci: stop producing gzip-compressed dist tarballs
pietroalbini Dec 28, 2020
51cec58
fix a comment
RalfJung Dec 29, 2020
c857cbe
Lint on redundant trailing semicolon after item
Aaron1011 Dec 7, 2020
21ed141
Remove trailing semicolon in librustdoc
Aaron1011 Dec 8, 2020
4c4700d
Remove unnecessary semicolon from Rustdoc-generated code
Aaron1011 Dec 28, 2020
6bef37c
Remove unnecessary semicolon from Clippy test
Aaron1011 Dec 29, 2020
927a94a
Rollup merge of #79684 - usbalbin:const_copy, r=oli-obk
Dylan-DPC Dec 30, 2020
b6e565f
Rollup merge of #79812 - Aaron1011:lint-item-trailing-semi, r=oli-obk
Dylan-DPC Dec 30, 2020
7a32e57
Rollup merge of #80311 - sivadeilra:natvis, r=petrochenkov
Dylan-DPC Dec 30, 2020
2932e87
Rollup merge of #80348 - matthiaskrgr:less_clones, r=Dylan-DPC
Dylan-DPC Dec 30, 2020
16550d2
Rollup merge of #80358 - pierwill:edit_rustc_span, r=lcnr
Dylan-DPC Dec 30, 2020
9b5cdd8
Rollup merge of #80381 - rust-lang:revert-80244-spans, r=GuillaumeGomez
Dylan-DPC Dec 30, 2020
b432edb
Rollup merge of #80424 - jyn514:bootstrap-cleanup, r=Mark-Simulacrum
Dylan-DPC Dec 30, 2020
13ef40a
Rollup merge of #80435 - pietroalbini:compression-formats, r=Mark-Sim…
Dylan-DPC Dec 30, 2020
fd364d6
Rollup merge of #80457 - camelid:pretty-docs-commas, r=jonas-schievink
Dylan-DPC Dec 30, 2020
ea43757
Rollup merge of #80458 - RalfJung:promotion-refactor, r=oli-obk
Dylan-DPC Dec 30, 2020
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
make more matches exhaustive
  • Loading branch information
RalfJung committed Dec 28, 2020
commit 4a90a58c34cdc47e51b3b6ae54c6da7578498866
61 changes: 41 additions & 20 deletions compiler/rustc_mir/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,15 @@ impl<'tcx> Validator<'_, 'tcx> {

fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
match rvalue {
Rvalue::Use(operand) | Rvalue::Repeat(operand, _) | Rvalue::UnaryOp(_, operand) => {
Rvalue::Use(operand)
| Rvalue::Repeat(operand, _)
| Rvalue::UnaryOp(UnOp::Not | UnOp::Neg, operand) => {
self.validate_operand(operand)?;
}

Rvalue::Discriminant(place) | Rvalue::Len(place) => self.validate_place(place.as_ref())?,
Rvalue::Discriminant(place) | Rvalue::Len(place) => {
self.validate_place(place.as_ref())?
}

Rvalue::ThreadLocalRef(_) => return Err(Unpromotable),

Expand All @@ -606,35 +610,52 @@ impl<'tcx> Validator<'_, 'tcx> {
self.validate_operand(operand)?;
}

Rvalue::BinaryOp(op, lhs, rhs)
| Rvalue::CheckedBinaryOp(op, lhs, rhs) => {
Rvalue::BinaryOp(op, lhs, rhs) | Rvalue::CheckedBinaryOp(op, lhs, rhs) => {
let op = *op;
if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).kind() {
assert!(
op == BinOp::Eq
|| op == BinOp::Ne
|| op == BinOp::Le
|| op == BinOp::Lt
|| op == BinOp::Ge
|| op == BinOp::Gt
|| op == BinOp::Offset
);

// raw pointer operations are not allowed inside consts and thus not promotable
assert!(matches!(
op,
BinOp::Eq
| BinOp::Ne
| BinOp::Le
| BinOp::Lt
| BinOp::Ge
| BinOp::Gt
| BinOp::Offset
));
return Err(Unpromotable);
}

// FIXME: reject operations that can fail -- namely, division and modulo.
match op {
// FIXME: reject operations that can fail -- namely, division and modulo.
BinOp::Eq
| BinOp::Ne
| BinOp::Le
| BinOp::Lt
| BinOp::Ge
| BinOp::Gt
| BinOp::Offset
| BinOp::Add
| BinOp::Sub
| BinOp::Mul
| BinOp::Div
| BinOp::Rem
| BinOp::BitXor
| BinOp::BitAnd
| BinOp::BitOr
| BinOp::Shl
| BinOp::Shr => {}
}

self.validate_operand(lhs)?;
self.validate_operand(rhs)?;
}

Rvalue::NullaryOp(op, _) => {
if matches!(op, NullOp::Box) {
return Err(Unpromotable);
}
}
Rvalue::NullaryOp(op, _) => match op {
NullOp::Box => return Err(Unpromotable),
NullOp::SizeOf => {}
},

Rvalue::AddressOf(_, place) => {
// We accept `&raw *`, i.e., raw reborrows -- creating a raw pointer is
Expand Down