Skip to content

Commit 507055b

Browse files
committed
Auto merge of rust-lang#2911 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 47bf8e7 + be4e05a commit 507055b

File tree

307 files changed

+6772
-4342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+6772
-4342
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ jobs:
578578
actions: write
579579
name: "try - ${{ matrix.name }}"
580580
env:
581+
DIST_TRY_BUILD: 1
581582
CI_JOB_NAME: "${{ matrix.name }}"
582583
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
583584
SCCACHE_BUCKET: rust-lang-ci-sccache2

compiler/rustc_abi/src/lib.rs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub enum TargetDataLayoutErrors<'a> {
209209
InvalidAddressSpace { addr_space: &'a str, cause: &'a str, err: ParseIntError },
210210
InvalidBits { kind: &'a str, bit: &'a str, cause: &'a str, err: ParseIntError },
211211
MissingAlignment { cause: &'a str },
212-
InvalidAlignment { cause: &'a str, err: String },
212+
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
213213
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
214214
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
215215
InvalidBitsSize { err: String },
@@ -640,30 +640,65 @@ impl fmt::Debug for Align {
640640
}
641641
}
642642

643+
#[derive(Clone, Copy)]
644+
pub enum AlignFromBytesError {
645+
NotPowerOfTwo(u64),
646+
TooLarge(u64),
647+
}
648+
649+
impl AlignFromBytesError {
650+
pub fn diag_ident(self) -> &'static str {
651+
match self {
652+
Self::NotPowerOfTwo(_) => "not_power_of_two",
653+
Self::TooLarge(_) => "too_large",
654+
}
655+
}
656+
657+
pub fn align(self) -> u64 {
658+
let (Self::NotPowerOfTwo(align) | Self::TooLarge(align)) = self;
659+
align
660+
}
661+
}
662+
663+
impl fmt::Debug for AlignFromBytesError {
664+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
665+
fmt::Display::fmt(self, f)
666+
}
667+
}
668+
669+
impl fmt::Display for AlignFromBytesError {
670+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
671+
match self {
672+
AlignFromBytesError::NotPowerOfTwo(align) => write!(f, "`{align}` is not a power of 2"),
673+
AlignFromBytesError::TooLarge(align) => write!(f, "`{align}` is too large"),
674+
}
675+
}
676+
}
677+
643678
impl Align {
644679
pub const ONE: Align = Align { pow2: 0 };
645680
pub const MAX: Align = Align { pow2: 29 };
646681

647682
#[inline]
648-
pub fn from_bits(bits: u64) -> Result<Align, String> {
683+
pub fn from_bits(bits: u64) -> Result<Align, AlignFromBytesError> {
649684
Align::from_bytes(Size::from_bits(bits).bytes())
650685
}
651686

652687
#[inline]
653-
pub fn from_bytes(align: u64) -> Result<Align, String> {
688+
pub fn from_bytes(align: u64) -> Result<Align, AlignFromBytesError> {
654689
// Treat an alignment of 0 bytes like 1-byte alignment.
655690
if align == 0 {
656691
return Ok(Align::ONE);
657692
}
658693

659694
#[cold]
660-
fn not_power_of_2(align: u64) -> String {
661-
format!("`{}` is not a power of 2", align)
695+
fn not_power_of_2(align: u64) -> AlignFromBytesError {
696+
AlignFromBytesError::NotPowerOfTwo(align)
662697
}
663698

664699
#[cold]
665-
fn too_large(align: u64) -> String {
666-
format!("`{}` is too large", align)
700+
fn too_large(align: u64) -> AlignFromBytesError {
701+
AlignFromBytesError::TooLarge(align)
667702
}
668703

669704
let tz = align.trailing_zeros();

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,18 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
279279
// HACK This bubble is required for this tests to pass:
280280
// nested-return-type2-tait2.rs
281281
// nested-return-type2-tait3.rs
282-
let infcx =
283-
self.tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).build();
282+
// FIXME(-Ztrait-solver=next): We probably should use `DefiningAnchor::Error`
283+
// and prepopulate this `InferCtxt` with known opaque values, rather than
284+
// using the `Bind` anchor here. For now it's fine.
285+
let infcx = self
286+
.tcx
287+
.infer_ctxt()
288+
.with_opaque_type_inference(if self.tcx.trait_solver_next() {
289+
DefiningAnchor::Bind(def_id)
290+
} else {
291+
DefiningAnchor::Bubble
292+
})
293+
.build();
284294
let ocx = ObligationCtxt::new(&infcx);
285295
// Require the hidden type to be well-formed with only the generics of the opaque type.
286296
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
188188

189189
// FIXME(-Ztrait-solver=next): A bit dubious that we're only registering
190190
// predefined opaques in the typeck root.
191-
// FIXME(-Ztrait-solver=next): This is also totally wrong for TAITs, since
192-
// the HIR typeck map defining usages back to their definition params,
193-
// they won't actually match up with the usages in this body...
194191
if infcx.tcx.trait_solver_next() && !infcx.tcx.is_typeck_child(body.source.def_id()) {
195192
checker.register_predefined_opaques_in_new_solver();
196193
}
@@ -1042,10 +1039,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10421039
.typeck(self.body.source.def_id().expect_local())
10431040
.concrete_opaque_types
10441041
.iter()
1045-
.map(|(&def_id, &hidden_ty)| {
1046-
let substs = ty::InternalSubsts::identity_for_item(self.infcx.tcx, def_id);
1047-
(ty::OpaqueTypeKey { def_id, substs }, hidden_ty)
1048-
})
1042+
.map(|(k, v)| (*k, *v))
10491043
.collect();
10501044

10511045
let renumbered_opaques = self.infcx.tcx.fold_regions(opaques, |_, _| {

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_index::IndexVec;
66
use rustc_middle::ty::layout::{
77
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
88
};
9+
use rustc_span::source_map::Spanned;
910
use rustc_span::SourceFile;
1011
use rustc_target::abi::call::FnAbi;
1112
use rustc_target::abi::{Integer, Primitive};
@@ -495,25 +496,16 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
495496
fn_abi_request: FnAbiRequest<'tcx>,
496497
) -> ! {
497498
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
498-
self.0.sess.span_fatal(span, err.to_string())
499+
self.0.sess.emit_fatal(Spanned { span, node: err })
499500
} else {
500501
match fn_abi_request {
501502
FnAbiRequest::OfFnPtr { sig, extra_args } => {
502-
span_bug!(
503-
span,
504-
"`fn_abi_of_fn_ptr({}, {:?})` failed: {}",
505-
sig,
506-
extra_args,
507-
err
508-
);
503+
span_bug!(span, "`fn_abi_of_fn_ptr({sig}, {extra_args:?})` failed: {err:?}");
509504
}
510505
FnAbiRequest::OfInstance { instance, extra_args } => {
511506
span_bug!(
512507
span,
513-
"`fn_abi_of_instance({}, {:?})` failed: {}",
514-
instance,
515-
extra_args,
516-
err
508+
"`fn_abi_of_instance({instance}, {extra_args:?})` failed: {err:?}"
517509
);
518510
}
519511
}

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
758758
assert_eq!(place.llextra.is_some(), place.layout.is_unsized());
759759

760760
if place.layout.is_zst() {
761-
return OperandRef::new_zst(self, place.layout);
761+
return OperandRef::zero_sized(place.layout);
762762
}
763763

764764
fn scalar_load_metadata<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>, load: RValue<'gcc>, scalar: &abi::Scalar) {

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn set_global_alignment<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, gv: LValue<'gcc>
2424
match Align::from_bits(min) {
2525
Ok(min) => align = align.max(min),
2626
Err(err) => {
27-
cx.sess().emit_err(InvalidMinimumAlignment { err });
27+
cx.sess().emit_err(InvalidMinimumAlignment { err: err.to_string() });
2828
}
2929
}
3030
}

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
477477
#[inline]
478478
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
479479
if let LayoutError::SizeOverflow(_) = err {
480-
self.sess().emit_fatal(respan(span, err))
480+
self.sess().emit_fatal(respan(span, err.into_diagnostic()))
481481
} else {
482482
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
483483
}
@@ -499,21 +499,12 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
499499
} else {
500500
match fn_abi_request {
501501
FnAbiRequest::OfFnPtr { sig, extra_args } => {
502-
span_bug!(
503-
span,
504-
"`fn_abi_of_fn_ptr({}, {:?})` failed: {}",
505-
sig,
506-
extra_args,
507-
err
508-
);
502+
span_bug!(span, "`fn_abi_of_fn_ptr({sig}, {extra_args:?})` failed: {err:?}");
509503
}
510504
FnAbiRequest::OfInstance { instance, extra_args } => {
511505
span_bug!(
512506
span,
513-
"`fn_abi_of_instance({}, {:?})` failed: {}",
514-
instance,
515-
extra_args,
516-
err
507+
"`fn_abi_of_instance({instance}, {extra_args:?})` failed: {err:?}"
517508
);
518509
}
519510
}

compiler/rustc_codegen_gcc/src/type_of.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
159159
fn is_gcc_immediate(&self) -> bool {
160160
match self.abi {
161161
Abi::Scalar(_) | Abi::Vector { .. } => true,
162-
Abi::ScalarPair(..) => false,
163-
Abi::Uninhabited | Abi::Aggregate { .. } => self.is_zst(),
162+
Abi::ScalarPair(..) | Abi::Uninhabited | Abi::Aggregate { .. } => false,
164163
}
165164
}
166165

compiler/rustc_codegen_llvm/messages.ftl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ codegen_llvm_error_writing_def_file =
2020
codegen_llvm_from_llvm_diag = {$message}
2121
2222
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
23-
codegen_llvm_invalid_minimum_alignment =
24-
invalid minimum global alignment: {$err}
23+
24+
codegen_llvm_invalid_minimum_alignment_not_power_of_two =
25+
invalid minimum global alignment: {$align} is not power of 2
26+
27+
codegen_llvm_invalid_minimum_alignment_too_large =
28+
invalid minimum global alignment: {$align} is too large
2529
2630
codegen_llvm_load_bitcode = failed to load bitcode of module "{$name}"
2731
codegen_llvm_load_bitcode_with_llvm_err = failed to load bitcode of module "{$name}": {$llvm_err}

0 commit comments

Comments
 (0)