Skip to content

Commit 670a0ed

Browse files
committed
Auto merge of rust-lang#112716 - compiler-errors:rollup-h77daia, r=compiler-errors
Rollup of 7 pull requests Successful merges: - rust-lang#111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`) - rust-lang#112226 (std: available_parallelism using native netbsd api first) - rust-lang#112474 (Support 128-bit enum variant in debuginfo codegen) - rust-lang#112662 (`#[lang_item]` for `core::ptr::Unique`) - rust-lang#112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`) - rust-lang#112684 (Disable alignment checks on i686-pc-windows-msvc) - rust-lang#112706 (Add `SyntaxContext::is_root`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6bba061 + 56c96d7 commit 670a0ed

File tree

29 files changed

+331
-163
lines changed

29 files changed

+331
-163
lines changed

compiler/rustc_codegen_gcc/src/common.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
108108
self.const_uint(self.type_u64(), i)
109109
}
110110

111+
fn const_u128(&self, i: u128) -> RValue<'gcc> {
112+
self.const_uint_big(self.type_u128(), i)
113+
}
114+
111115
fn const_usize(&self, i: u64) -> RValue<'gcc> {
112116
let bit_size = self.data_layout().pointer_size.bits();
113117
if bit_size < 64 {
@@ -254,7 +258,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
254258
// SIMD builtins require a constant value.
255259
self.bitcast_if_needed(value, typ)
256260
}
257-
261+
258262
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
259263
self.context.new_array_access(None, base_addr, self.const_usize(offset.bytes())).get_address(None)
260264
}

compiler/rustc_codegen_llvm/src/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
168168
self.const_uint(self.type_i64(), i)
169169
}
170170

171+
fn const_u128(&self, i: u128) -> &'ll Value {
172+
self.const_uint_big(self.type_i128(), i)
173+
}
174+
171175
fn const_usize(&self, i: u64) -> &'ll Value {
172176
let bit_size = self.data_layout().pointer_size.bits();
173177
if bit_size < 64 {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
429429
return existing_di_node;
430430
}
431431

432-
debug!("type_di_node: {:?}", t);
432+
debug!("type_di_node: {:?} kind: {:?}", t, t.kind());
433433

434434
let DINodeCreationResult { di_node, already_stored_in_typemap } = match *t.kind() {
435435
ty::Never | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) => {

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,7 @@ fn build_enum_variant_member_di_node<'ll, 'tcx>(
412412
enum_type_and_layout.size.bits(),
413413
enum_type_and_layout.align.abi.bits() as u32,
414414
Size::ZERO.bits(),
415-
discr_value.opt_single_val().map(|value| {
416-
// NOTE(eddyb) do *NOT* remove this assert, until
417-
// we pass the full 128-bit value to LLVM, otherwise
418-
// truncation will be silent and remain undetected.
419-
assert_eq!(value as u64 as u128, value);
420-
cx.const_u64(value as u64)
421-
}),
415+
discr_value.opt_single_val().map(|value| cx.const_u128(value)),
422416
DIFlags::FlagZero,
423417
variant_member_info.variant_struct_type_di_node,
424418
)

compiler/rustc_codegen_ssa/src/traits/consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
1515
fn const_i32(&self, i: i32) -> Self::Value;
1616
fn const_u32(&self, i: u32) -> Self::Value;
1717
fn const_u64(&self, i: u64) -> Self::Value;
18+
fn const_u128(&self, i: u128) -> Self::Value;
1819
fn const_usize(&self, i: u64) -> Self::Value;
1920
fn const_u8(&self, i: u8) -> Self::Value;
2021
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;

compiler/rustc_expand/src/mbe/quoted.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_session::parse::{feature_err, ParseSess};
99
use rustc_span::symbol::{kw, sym, Ident};
1010

1111
use rustc_span::edition::Edition;
12-
use rustc_span::{Span, SyntaxContext};
12+
use rustc_span::Span;
1313

1414
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
1515
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
@@ -72,7 +72,7 @@ pub(super) fn parse(
7272
// `SyntaxContext::root()` from a foreign crate will
7373
// have the edition of that crate (which we manually
7474
// retrieve via the `edition` parameter).
75-
if span.ctxt() == SyntaxContext::root() {
75+
if span.ctxt().is_root() {
7676
edition
7777
} else {
7878
span.edition()

compiler/rustc_hir/src/lang_items.rs

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ language_item_table! {
260260
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;
261261

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

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

compiler/rustc_middle/src/mir/spanview.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_middle::hir;
33
use rustc_middle::mir::*;
44
use rustc_middle::ty::TyCtxt;
55
use rustc_session::config::MirSpanview;
6-
use rustc_span::{BytePos, Pos, Span, SyntaxContext};
6+
use rustc_span::{BytePos, Pos, Span};
77

88
use std::cmp;
99
use std::io::{self, Write};
@@ -327,7 +327,7 @@ fn compute_block_span(data: &BasicBlockData<'_>, body_span: Span) -> Span {
327327
let mut span = data.terminator().source_info.span;
328328
for statement_span in data.statements.iter().map(|statement| statement.source_info.span) {
329329
// Only combine Spans from the root context, and within the function's body_span.
330-
if statement_span.ctxt() == SyntaxContext::root() && body_span.contains(statement_span) {
330+
if statement_span.ctxt().is_root() && body_span.contains(statement_span) {
331331
span = span.to(statement_span);
332332
}
333333
}

compiler/rustc_middle/src/ty/mod.rs

+66
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,24 @@ pub enum Clause<'tcx> {
586586
ConstArgHasType(Const<'tcx>, Ty<'tcx>),
587587
}
588588

589+
impl<'tcx> Binder<'tcx, Clause<'tcx>> {
590+
pub fn as_trait_clause(self) -> Option<Binder<'tcx, TraitPredicate<'tcx>>> {
591+
if let ty::Clause::Trait(trait_clause) = self.skip_binder() {
592+
Some(self.rebind(trait_clause))
593+
} else {
594+
None
595+
}
596+
}
597+
598+
pub fn as_projection_clause(self) -> Option<Binder<'tcx, ProjectionPredicate<'tcx>>> {
599+
if let ty::Clause::Projection(projection_clause) = self.skip_binder() {
600+
Some(self.rebind(projection_clause))
601+
} else {
602+
None
603+
}
604+
}
605+
}
606+
589607
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
590608
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
591609
pub enum PredicateKind<'tcx> {
@@ -1203,6 +1221,17 @@ impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
12031221
}
12041222
}
12051223

1224+
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for TraitRef<'tcx> {
1225+
#[inline(always)]
1226+
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
1227+
Binder::dummy(Clause::Trait(TraitPredicate {
1228+
trait_ref: self,
1229+
constness: ty::BoundConstness::NotConst,
1230+
polarity: ty::ImplPolarity::Positive,
1231+
}))
1232+
}
1233+
}
1234+
12061235
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
12071236
#[inline(always)]
12081237
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
@@ -1211,6 +1240,14 @@ impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
12111240
}
12121241
}
12131242

1243+
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for Binder<'tcx, TraitRef<'tcx>> {
1244+
#[inline(always)]
1245+
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
1246+
let pred: PolyTraitPredicate<'tcx> = self.to_predicate(tcx);
1247+
pred.to_predicate(tcx)
1248+
}
1249+
}
1250+
12141251
impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
12151252
#[inline(always)]
12161253
fn to_predicate(self, _: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
@@ -1240,6 +1277,12 @@ impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
12401277
}
12411278
}
12421279

1280+
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyTraitPredicate<'tcx> {
1281+
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
1282+
self.map_bound(|p| Clause::Trait(p))
1283+
}
1284+
}
1285+
12431286
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
12441287
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
12451288
self.map_bound(|p| PredicateKind::Clause(Clause::RegionOutlives(p))).to_predicate(tcx)
@@ -1258,6 +1301,12 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
12581301
}
12591302
}
12601303

1304+
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyProjectionPredicate<'tcx> {
1305+
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
1306+
self.map_bound(|p| Clause::Projection(p))
1307+
}
1308+
}
1309+
12611310
impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
12621311
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
12631312
PredicateKind::Clause(Clause::Trait(self)).to_predicate(tcx)
@@ -1327,6 +1376,23 @@ impl<'tcx> Predicate<'tcx> {
13271376
| PredicateKind::TypeWellFormedFromEnv(..) => None,
13281377
}
13291378
}
1379+
1380+
pub fn as_clause(self) -> Option<Binder<'tcx, Clause<'tcx>>> {
1381+
let predicate = self.kind();
1382+
match predicate.skip_binder() {
1383+
PredicateKind::Clause(clause) => Some(predicate.rebind(clause)),
1384+
PredicateKind::AliasRelate(..)
1385+
| PredicateKind::Subtype(..)
1386+
| PredicateKind::Coerce(..)
1387+
| PredicateKind::WellFormed(..)
1388+
| PredicateKind::ObjectSafe(..)
1389+
| PredicateKind::ClosureKind(..)
1390+
| PredicateKind::ConstEvaluatable(..)
1391+
| PredicateKind::ConstEquate(..)
1392+
| PredicateKind::Ambiguous
1393+
| PredicateKind::TypeWellFormedFromEnv(..) => None,
1394+
}
1395+
}
13301396
}
13311397

13321398
/// Represents the bounds declared on a particular set of type

compiler/rustc_mir_transform/src/check_alignment.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ pub struct CheckAlignment;
1515

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

compiler/rustc_span/src/hygiene.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl HygieneData {
507507
self.normalize_to_macro_rules(call_site_ctxt)
508508
};
509509

510-
if call_site_ctxt == SyntaxContext::root() {
510+
if call_site_ctxt.is_root() {
511511
return self.apply_mark_internal(ctxt, expn_id, transparency);
512512
}
513513

@@ -671,12 +671,17 @@ impl SyntaxContext {
671671
}
672672

673673
#[inline]
674-
pub(crate) fn as_u32(self) -> u32 {
674+
pub const fn is_root(self) -> bool {
675+
self.0 == SyntaxContext::root().as_u32()
676+
}
677+
678+
#[inline]
679+
pub(crate) const fn as_u32(self) -> u32 {
675680
self.0
676681
}
677682

678683
#[inline]
679-
pub(crate) fn from_u32(raw: u32) -> SyntaxContext {
684+
pub(crate) const fn from_u32(raw: u32) -> SyntaxContext {
680685
SyntaxContext(raw)
681686
}
682687

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

1503-
if *self == SyntaxContext::root() {
1508+
if self.is_root() {
15041509
TAG_NO_EXPANSION.hash_stable(ctx, hasher);
15051510
} else {
15061511
TAG_EXPANSION.hash_stable(ctx, hasher);

compiler/rustc_span/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,9 @@ impl Span {
826826
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
827827
// have an incomplete span than a completely nonsensical one.
828828
if span_data.ctxt != end_data.ctxt {
829-
if span_data.ctxt == SyntaxContext::root() {
829+
if span_data.ctxt.is_root() {
830830
return end;
831-
} else if end_data.ctxt == SyntaxContext::root() {
831+
} else if end_data.ctxt.is_root() {
832832
return self;
833833
}
834834
// Both spans fall within a macro.
@@ -837,7 +837,7 @@ impl Span {
837837
Span::new(
838838
cmp::min(span_data.lo, end_data.lo),
839839
cmp::max(span_data.hi, end_data.hi),
840-
if span_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt },
840+
if span_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
841841
if span_data.parent == end_data.parent { span_data.parent } else { None },
842842
)
843843
}
@@ -855,7 +855,7 @@ impl Span {
855855
Span::new(
856856
span.hi,
857857
end.lo,
858-
if end.ctxt == SyntaxContext::root() { end.ctxt } else { span.ctxt },
858+
if end.ctxt.is_root() { end.ctxt } else { span.ctxt },
859859
if span.parent == end.parent { span.parent } else { None },
860860
)
861861
}
@@ -879,9 +879,9 @@ impl Span {
879879
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
880880
// have an incomplete span than a completely nonsensical one.
881881
if span_data.ctxt != end_data.ctxt {
882-
if span_data.ctxt == SyntaxContext::root() {
882+
if span_data.ctxt.is_root() {
883883
return end;
884-
} else if end_data.ctxt == SyntaxContext::root() {
884+
} else if end_data.ctxt.is_root() {
885885
return self;
886886
}
887887
// Both spans fall within a macro.
@@ -890,7 +890,7 @@ impl Span {
890890
Span::new(
891891
span_data.lo,
892892
end_data.lo,
893-
if end_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt },
893+
if end_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
894894
if span_data.parent == end_data.parent { span_data.parent } else { None },
895895
)
896896
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ symbols! {
11561156
ptr_null_mut,
11571157
ptr_offset_from,
11581158
ptr_offset_from_unsigned,
1159+
ptr_unique,
11591160
pub_macro_rules,
11601161
pub_restricted,
11611162
public,

0 commit comments

Comments
 (0)