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 8 pull requests #91198

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bd287fa
Disable aarch64 outline atomics with musl for now.
hkratz Nov 10, 2021
e6ab982
Reduce prominence of item-infos
jsha Nov 20, 2021
0e1c211
On type mismatch caused by assignment, point at assignee
estebank May 7, 2021
d4e5cf4
Account for type obligation coming from `const` and `static`
estebank Nov 21, 2021
08a500f
fix test in std::process on android
name1e5s Nov 23, 2021
8756d07
Derive Ord and PartialOrd for TraitRef
compiler-errors Nov 22, 2021
c969b1d
Add supertraits method to rustc_middle
compiler-errors Nov 22, 2021
ce182d1
Elaborate trait generics and associated types
compiler-errors Nov 20, 2021
b84a52c
Add generator lang-item
compiler-errors Nov 22, 2021
471334e
Suppress noisy generator associated type
compiler-errors Nov 22, 2021
9ae575c
Update test outputs
compiler-errors Nov 20, 2021
9cc1179
Fix printing unit return ty, don't elaborate FnOnce unless we see it
compiler-errors Nov 23, 2021
94c9c22
explain why CTFE/Miri perform truncation on shift offset
RalfJung Nov 23, 2021
5f6ccf6
document BinOp behavior quirks in the corresponding enum
RalfJung Nov 24, 2021
3b25e92
Debug
fee1-dead Sep 29, 2021
e0c2ff7
Allow more cases to match ~const Drop.
fee1-dead Sep 29, 2021
b200511
Allow features like const_try in d_m_b_i_c
fee1-dead Sep 29, 2021
4f29f3c
Add impl polarity to fields
fee1-dead Nov 24, 2021
5872009
Fix more <a> color
GuillaumeGomez Nov 24, 2021
0ba92fe
Update GUI tests for <a> color
GuillaumeGomez Nov 24, 2021
87a5f2c
Rollup merge of #85102 - estebank:point-at-assignment, r=oli-obk
GuillaumeGomez Nov 24, 2021
a336475
Rollup merge of #89359 - fee1-dead:const-it, r=oli-obk
GuillaumeGomez Nov 24, 2021
25f0f43
Rollup merge of #90044 - rusticstuff:disable_arm_outline_atomics_for_…
GuillaumeGomez Nov 24, 2021
2d7852f
Rollup merge of #91075 - jsha:chill-item-info, r=GuillaumeGomez
GuillaumeGomez Nov 24, 2021
520eef3
Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=es…
GuillaumeGomez Nov 24, 2021
9e73b07
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
GuillaumeGomez Nov 24, 2021
eed5f31
Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obk
GuillaumeGomez Nov 24, 2021
0dfe08c
Rollup merge of #91179 - GuillaumeGomez:a-color, r=jsha
GuillaumeGomez Nov 24, 2021
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
16 changes: 12 additions & 4 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
}
if !self.sess.features_untracked().destructuring_assignment {
feature_err(
let mut err = feature_err(
&self.sess.parse_sess,
sym::destructuring_assignment,
eq_sign_span,
"destructuring assignments are unstable",
)
.span_label(lhs.span, "cannot assign to this expression")
.emit();
);
err.span_label(lhs.span, "cannot assign to this expression");
if self.is_in_loop_condition {
err.span_suggestion_verbose(
lhs.span.shrink_to_lo(),
"you might have meant to use pattern destructuring",
"let ".to_string(),
rustc_errors::Applicability::MachineApplicable,
);
}
err.emit();
}

let mut assignments = vec![];
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let signed = left_layout.abi.is_signed();
let size = u128::from(left_layout.size.bits());
let overflow = r >= size;
let r = r % size; // mask to type size
// The shift offset is implicitly masked to the type size, to make sure this operation
// is always defined. This is the one MIR operator that does *not* directly map to a
// single LLVM operation. See
// <https://github.com/rust-lang/rust/blob/a3b9405ae7bb6ab4e8103b414e75c44598a10fd2/compiler/rustc_codegen_ssa/src/common.rs#L131-L158>
// for the corresponding truncation in our codegen backends.
let r = r % size;
let r = u32::try_from(r).unwrap(); // we masked so this will always fit
let result = if signed {
let l = self.sign_extend(l, left_layout) as i128;
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_const_eval/src/transform/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,12 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
}

let mut err_span = self.span;
let ty_of_dropped_place = dropped_place.ty(self.body, self.tcx).ty;

let ty_needs_non_const_drop = qualifs::NeedsNonConstDrop::in_any_value_of_ty(
self.ccx,
dropped_place.ty(self.body, self.tcx).ty,
);
let ty_needs_non_const_drop =
qualifs::NeedsNonConstDrop::in_any_value_of_ty(self.ccx, ty_of_dropped_place);

debug!(?ty_of_dropped_place, ?ty_needs_non_const_drop);

if !ty_needs_non_const_drop {
return;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ language_item_table! {
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
GeneratorState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None;
Generator, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1);
GeneratorReturn, sym::generator_return, generator_return, Target::AssocTy, GenericRequirement::None;
Unpin, sym::unpin, unpin_trait, Target::Trait, GenericRequirement::None;
Pin, sym::pin, pin_type, Target::Struct, GenericRequirement::None;

Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2246,8 +2246,12 @@ pub enum BinOp {
/// The `*` operator (multiplication)
Mul,
/// The `/` operator (division)
///
/// Division by zero is UB.
Div,
/// The `%` operator (modulus)
///
/// Using zero as the modulus (second operand) is UB.
Rem,
/// The `^` operator (bitwise xor)
BitXor,
Expand All @@ -2256,8 +2260,12 @@ pub enum BinOp {
/// The `|` operator (bitwise or)
BitOr,
/// The `<<` operator (shift left)
///
/// The offset is truncated to the size of the first operand before shifting.
Shl,
/// The `>>` operator (shift right)
///
/// The offset is truncated to the size of the first operand before shifting.
Shr,
/// The `==` operator (equality)
Eq,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod query;
pub mod select;
pub mod specialization_graph;
mod structural_impls;
pub mod util;

use crate::infer::canonical::Canonical;
use crate::thir::abstract_const::NotConstEvaluatable;
Expand Down
49 changes: 49 additions & 0 deletions compiler/rustc_middle/src/traits/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use rustc_data_structures::stable_set::FxHashSet;

use crate::ty::{PolyTraitRef, TyCtxt};

/// Given a PolyTraitRef, get the PolyTraitRefs of the trait's (transitive) supertraits.
///
/// A simplfied version of the same function at `rustc_infer::traits::util::supertraits`.
pub fn supertraits<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
) -> impl Iterator<Item = PolyTraitRef<'tcx>> {
Elaborator { tcx, visited: FxHashSet::from_iter([trait_ref]), stack: vec![trait_ref] }
}

struct Elaborator<'tcx> {
tcx: TyCtxt<'tcx>,
visited: FxHashSet<PolyTraitRef<'tcx>>,
stack: Vec<PolyTraitRef<'tcx>>,
}

impl<'tcx> Elaborator<'tcx> {
fn elaborate(&mut self, trait_ref: PolyTraitRef<'tcx>) {
let supertrait_refs = self
.tcx
.super_predicates_of(trait_ref.def_id())
.predicates
.into_iter()
.flat_map(|(pred, _)| {
pred.subst_supertrait(self.tcx, &trait_ref).to_opt_poly_trait_ref()
})
.map(|t| t.value)
.filter(|supertrait_ref| self.visited.insert(*supertrait_ref));

self.stack.extend(supertrait_refs);
}
}

impl<'tcx> Iterator for Elaborator<'tcx> {
type Item = PolyTraitRef<'tcx>;

fn next(&mut self) -> Option<PolyTraitRef<'tcx>> {
if let Some(trait_ref) = self.stack.pop() {
self.elaborate(trait_ref);
Some(trait_ref)
} else {
None
}
}
}
Loading