Skip to content

Rollup of 7 pull requests #112716

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 19 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e77b14e
Relax implicit `R: Sized` bound on `BufReader<R>`
WaffleLapkin May 1, 2023
a497533
Relax implicit `W: Sized` bound on `BufWriter<W>`
WaffleLapkin May 1, 2023
29302a2
Relax implicit `W: Sized` bound on `LineWriter<W>`
WaffleLapkin May 1, 2023
25b3751
std: available_parallelism using native netbsd api first
devnexen Jun 2, 2023
204bfb6
Support 128-bit enum variant in debuginfo codegen
ldm0 Jun 9, 2023
859bac7
Fix codegen tests
ldm0 Jun 10, 2023
ea19243
Add test
ldm0 Jun 10, 2023
b4ba7c4
Make assumption functions in new solver take clause
compiler-errors Jun 15, 2023
c54672e
Disable alignment checks on i686-pc-windows-msvc
saethlin Jun 15, 2023
dc3e91c
`#[lang_item]` for `core::ptr::Unique`
Vanille-N Jun 15, 2023
73c5c97
Add `SyntaxContext::is_root`
WaffleLapkin Jun 16, 2023
4ef316f
Update compiler/rustc_mir_transform/src/check_alignment.rs
wesleywiser Jun 16, 2023
c55af41
Rollup merge of #111074 - WaffleLapkin:🌟unsizes_your_buf_reader🌟, r=A…
compiler-errors Jun 16, 2023
4d5e7cd
Rollup merge of #112226 - devnexen:netbsd_affinity, r=cuviper
compiler-errors Jun 16, 2023
3eb8c2a
Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=comp…
compiler-errors Jun 16, 2023
38fc6be
Rollup merge of #112662 - Vanille-N:symbol_unique, r=RalfJung
compiler-errors Jun 16, 2023
cef94ec
Rollup merge of #112665 - compiler-errors:assumption-takes-clause, r=…
compiler-errors Jun 16, 2023
a5f8859
Rollup merge of #112684 - saethlin:ignore-windows-alignment, r=wesley…
compiler-errors Jun 16, 2023
56c96d7
Rollup merge of #112706 - WaffleLapkin:syntax_context_is_root, r=petr…
compiler-errors Jun 16, 2023
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
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.const_uint(self.type_u64(), i)
}

fn const_u128(&self, i: u128) -> RValue<'gcc> {
self.const_uint_big(self.type_u128(), i)
}

fn const_usize(&self, i: u64) -> RValue<'gcc> {
let bit_size = self.data_layout().pointer_size.bits();
if bit_size < 64 {
Expand Down Expand Up @@ -254,7 +258,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
// SIMD builtins require a constant value.
self.bitcast_if_needed(value, typ)
}

fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
self.context.new_array_access(None, base_addr, self.const_usize(offset.bytes())).get_address(None)
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
self.const_uint(self.type_i64(), i)
}

fn const_u128(&self, i: u128) -> &'ll Value {
self.const_uint_big(self.type_i128(), i)
}

fn const_usize(&self, i: u64) -> &'ll Value {
let bit_size = self.data_layout().pointer_size.bits();
if bit_size < 64 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
return existing_di_node;
}

debug!("type_di_node: {:?}", t);
debug!("type_di_node: {:?} kind: {:?}", t, t.kind());

let DINodeCreationResult { di_node, already_stored_in_typemap } = match *t.kind() {
ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
enum_type_and_layout.size.bits(),
enum_type_and_layout.align.abi.bits() as u32,
Size::ZERO.bits(),
discr_value.opt_single_val().map(|value| {
// NOTE(eddyb) do *NOT* remove this assert, until
// we pass the full 128-bit value to LLVM, otherwise
// truncation will be silent and remain undetected.
assert_eq!(value as u64 as u128, value);
cx.const_u64(value as u64)
}),
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
DIFlags::FlagZero,
variant_member_info.variant_struct_type_di_node,
)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/traits/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
fn const_i32(&self, i: i32) -> Self::Value;
fn const_u32(&self, i: u32) -> Self::Value;
fn const_u64(&self, i: u64) -> Self::Value;
fn const_u128(&self, i: u128) -> Self::Value;
fn const_usize(&self, i: u64) -> Self::Value;
fn const_u8(&self, i: u8) -> Self::Value;
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_session::parse::{feature_err, ParseSess};
use rustc_span::symbol::{kw, sym, Ident};

use rustc_span::edition::Edition;
use rustc_span::{Span, SyntaxContext};
use rustc_span::Span;

const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
Expand Down Expand Up @@ -72,7 +72,7 @@ pub(super) fn parse(
// `SyntaxContext::root()` from a foreign crate will
// have the edition of that crate (which we manually
// retrieve via the `edition` parameter).
if span.ctxt() == SyntaxContext::root() {
if span.ctxt().is_root() {
edition
} else {
span.edition()
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ language_item_table! {
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;

OwnedBox, sym::owned_box, owned_box, Target::Struct, GenericRequirement::Minimum(1);
// Experimental language item for Miri
PtrUnique, sym::ptr_unique, ptr_unique, Target::Struct, GenericRequirement::Exact(1);

PhantomData, sym::phantom_data, phantom_data, Target::Struct, GenericRequirement::Exact(1);

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/spanview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_middle::hir;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::MirSpanview;
use rustc_span::{BytePos, Pos, Span, SyntaxContext};
use rustc_span::{BytePos, Pos, Span};

use std::cmp;
use std::io::{self, Write};
Expand Down Expand Up @@ -327,7 +327,7 @@ fn compute_block_span(data: &BasicBlockData<'_>, body_span: Span) -> Span {
let mut span = data.terminator().source_info.span;
for statement_span in data.statements.iter().map(|statement| statement.source_info.span) {
// Only combine Spans from the root context, and within the function's body_span.
if statement_span.ctxt() == SyntaxContext::root() && body_span.contains(statement_span) {
if statement_span.ctxt().is_root() && body_span.contains(statement_span) {
span = span.to(statement_span);
}
}
Expand Down
66 changes: 66 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,24 @@ pub enum Clause<'tcx> {
ConstArgHasType(Const<'tcx>, Ty<'tcx>),
}

impl<'tcx> Binder<'tcx, Clause<'tcx>> {
pub fn as_trait_clause(self) -> Option<Binder<'tcx, TraitPredicate<'tcx>>> {
if let ty::Clause::Trait(trait_clause) = self.skip_binder() {
Some(self.rebind(trait_clause))
} else {
None
}
}

pub fn as_projection_clause(self) -> Option<Binder<'tcx, ProjectionPredicate<'tcx>>> {
if let ty::Clause::Projection(projection_clause) = self.skip_binder() {
Some(self.rebind(projection_clause))
} else {
None
}
}
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub enum PredicateKind<'tcx> {
Expand Down Expand Up @@ -1203,6 +1221,17 @@ impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
}
}

impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for TraitRef<'tcx> {
#[inline(always)]
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
Binder::dummy(Clause::Trait(TraitPredicate {
trait_ref: self,
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Positive,
}))
}
}

impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
#[inline(always)]
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
Expand All @@ -1211,6 +1240,14 @@ impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
}
}

impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for Binder<'tcx, TraitRef<'tcx>> {
#[inline(always)]
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
let pred: PolyTraitPredicate<'tcx> = self.to_predicate(tcx);
pred.to_predicate(tcx)
}
}

impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
#[inline(always)]
fn to_predicate(self, _: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
Expand Down Expand Up @@ -1240,6 +1277,12 @@ impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
}
}

impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyTraitPredicate<'tcx> {
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
self.map_bound(|p| Clause::Trait(p))
}
}

impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
self.map_bound(|p| PredicateKind::Clause(Clause::RegionOutlives(p))).to_predicate(tcx)
Expand All @@ -1258,6 +1301,12 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
}
}

impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyProjectionPredicate<'tcx> {
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
self.map_bound(|p| Clause::Projection(p))
}
}

impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateKind::Clause(Clause::Trait(self)).to_predicate(tcx)
Expand Down Expand Up @@ -1327,6 +1376,23 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::TypeWellFormedFromEnv(..) => None,
}
}

pub fn as_clause(self) -> Option<Binder<'tcx, Clause<'tcx>>> {
let predicate = self.kind();
match predicate.skip_binder() {
PredicateKind::Clause(clause) => Some(predicate.rebind(clause)),
PredicateKind::AliasRelate(..)
| PredicateKind::Subtype(..)
| PredicateKind::Coerce(..)
| PredicateKind::WellFormed(..)
| PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..)
| PredicateKind::ConstEvaluatable(..)
| PredicateKind::ConstEquate(..)
| PredicateKind::Ambiguous
| PredicateKind::TypeWellFormedFromEnv(..) => None,
}
}
}

/// Represents the bounds declared on a particular set of type
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/check_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pub struct CheckAlignment;

impl<'tcx> MirPass<'tcx> for CheckAlignment {
fn is_enabled(&self, sess: &Session) -> bool {
// FIXME(#112480) MSVC and rustc disagree on minimum stack alignment on x86 Windows
if sess.target.llvm_target == "i686-pc-windows-msvc" {
return false;
}
sess.opts.debug_assertions
}

Expand Down
13 changes: 9 additions & 4 deletions compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl HygieneData {
self.normalize_to_macro_rules(call_site_ctxt)
};

if call_site_ctxt == SyntaxContext::root() {
if call_site_ctxt.is_root() {
return self.apply_mark_internal(ctxt, expn_id, transparency);
}

Expand Down Expand Up @@ -671,12 +671,17 @@ impl SyntaxContext {
}

#[inline]
pub(crate) fn as_u32(self) -> u32 {
pub const fn is_root(self) -> bool {
self.0 == SyntaxContext::root().as_u32()
}

#[inline]
pub(crate) const fn as_u32(self) -> u32 {
self.0
}

#[inline]
pub(crate) fn from_u32(raw: u32) -> SyntaxContext {
pub(crate) const fn from_u32(raw: u32) -> SyntaxContext {
SyntaxContext(raw)
}

Expand Down Expand Up @@ -1500,7 +1505,7 @@ impl<CTX: HashStableContext> HashStable<CTX> for SyntaxContext {
const TAG_EXPANSION: u8 = 0;
const TAG_NO_EXPANSION: u8 = 1;

if *self == SyntaxContext::root() {
if self.is_root() {
TAG_NO_EXPANSION.hash_stable(ctx, hasher);
} else {
TAG_EXPANSION.hash_stable(ctx, hasher);
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,9 @@ impl Span {
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
// have an incomplete span than a completely nonsensical one.
if span_data.ctxt != end_data.ctxt {
if span_data.ctxt == SyntaxContext::root() {
if span_data.ctxt.is_root() {
return end;
} else if end_data.ctxt == SyntaxContext::root() {
} else if end_data.ctxt.is_root() {
return self;
}
// Both spans fall within a macro.
Expand All @@ -837,7 +837,7 @@ impl Span {
Span::new(
cmp::min(span_data.lo, end_data.lo),
cmp::max(span_data.hi, end_data.hi),
if span_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt },
if span_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
if span_data.parent == end_data.parent { span_data.parent } else { None },
)
}
Expand All @@ -855,7 +855,7 @@ impl Span {
Span::new(
span.hi,
end.lo,
if end.ctxt == SyntaxContext::root() { end.ctxt } else { span.ctxt },
if end.ctxt.is_root() { end.ctxt } else { span.ctxt },
if span.parent == end.parent { span.parent } else { None },
)
}
Expand All @@ -879,9 +879,9 @@ impl Span {
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
// have an incomplete span than a completely nonsensical one.
if span_data.ctxt != end_data.ctxt {
if span_data.ctxt == SyntaxContext::root() {
if span_data.ctxt.is_root() {
return end;
} else if end_data.ctxt == SyntaxContext::root() {
} else if end_data.ctxt.is_root() {
return self;
}
// Both spans fall within a macro.
Expand All @@ -890,7 +890,7 @@ impl Span {
Span::new(
span_data.lo,
end_data.lo,
if end_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt },
if end_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
if span_data.parent == end_data.parent { span_data.parent } else { None },
)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ symbols! {
ptr_null_mut,
ptr_offset_from,
ptr_offset_from_unsigned,
ptr_unique,
pub_macro_rules,
pub_restricted,
public,
Expand Down
Loading