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 6 pull requests #91221

Merged
merged 25 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
ae126ad
Do not visit attributes in `ItemLowerer`.
cjgillot Nov 21, 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
f0b990a
Remove `-Z force-overflow-checks`
camelid Nov 24, 2021
7f5d3ff
Do not visit attributes in `LateResolutionVisitor`.
cjgillot Nov 24, 2021
fa18030
The correct LLVM target for aarch64-apple-darwin is arm64-... (as wit…
hkratz Nov 2, 2021
8f4d88c
Set the default deployment target for Macos ARM64 to 11.0.
hkratz Nov 2, 2021
b376f56
Set MACOSX_DEPLOYMENT_TARGET env var to default for linking if not set.
hkratz Nov 2, 2021
90dd7c0
Rollup merge of #89359 - fee1-dead:const-it, r=oli-obk
matthiaskrgr Nov 25, 2021
0780889
Rollup merge of #90499 - rusticstuff:macos-target-fixes, r=petrochenkov
matthiaskrgr Nov 25, 2021
6970cf5
Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=es…
matthiaskrgr Nov 25, 2021
5f6cb2c
Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoerister
matthiaskrgr Nov 25, 2021
5fff1d7
Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obk
matthiaskrgr Nov 25, 2021
984e644
Rollup merge of #91185 - camelid:rm-force-overflow-checks, r=wesleywiser
matthiaskrgr Nov 25, 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
5 changes: 5 additions & 0 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ impl ItemLowerer<'_, '_, '_> {
}

impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
fn visit_attribute(&mut self, _: &'a Attribute) {
// We do not want to lower expressions that appear in attributes,
// as they are not accessible to the rest of the HIR.
}

fn visit_item(&mut self, item: &'a Item) {
let hir_id = self.lctx.with_hir_id_owner(item.id, |lctx| {
let node = lctx.without_in_scope_lifetime_defs(|lctx| lctx.lower_item(item));
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
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ fn test_debugging_options_tracking_hash() {
tracked!(dep_info_omit_d_target, true);
tracked!(dual_proc_macros, true);
tracked!(fewer_names, Some(true));
tracked!(force_overflow_checks, Some(true));
tracked!(force_unstable_if_unmarked, true);
tracked!(fuel, Some(("abc".to_string(), 99)));
tracked!(function_sections, Some(false));
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