Skip to content

Commit 6346613

Browse files
committed
Auto merge of rust-lang#121845 - matthiaskrgr:rollup-7q4bzuc, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#119199 (Add arm64ec-pc-windows-msvc target) - rust-lang#121416 (Improve error messages for generics with default parameters) - rust-lang#121475 (Add tidy check for .stderr/.stdout files for non-existent test revisions) - rust-lang#121736 (Remove `Mutex::unlock` Function) - rust-lang#121744 (Stop using Bubble in coherence and instead emulate it with an intercrte check) - rust-lang#121784 (Make the success arms of `if lhs || rhs` meet up in a separate block) - rust-lang#121818 (CFI: Remove unused `typeid_for_fnsig`) - rust-lang#121819 (Handle stashing of delayed bugs) - rust-lang#121828 (Remove unused fluent messages) - rust-lang#121831 (Fix typo in comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b0696a5 + 516e844 commit 6346613

File tree

70 files changed

+566
-864
lines changed

Some content is hidden

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

70 files changed

+566
-864
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ version = "0.1.0"
447447

448448
[[package]]
449449
name = "cc"
450-
version = "1.0.79"
450+
version = "1.0.88"
451451
source = "registry+https://github.com/rust-lang/crates.io-index"
452-
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
452+
checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc"
453453

454454
[[package]]
455455
name = "cfg-if"

compiler/rustc_builtin_macros/messages.ftl

-6
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ builtin_macros_requires_cfg_pattern =
221221
macro requires a cfg-pattern as an argument
222222
.label = cfg-pattern required
223223
224-
builtin_macros_should_panic = functions using `#[should_panic]` must return `()`
225-
226-
builtin_macros_test_arg_non_lifetime = functions used as tests can not have any non-lifetime generic parameters
227-
228-
builtin_macros_test_args = functions used as tests can not have any arguments
229-
230224
builtin_macros_test_bad_fn = {$kind} functions cannot be used for tests
231225
.label = `{$kind}` because of this
232226

compiler/rustc_codegen_llvm/src/back/archive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType {
5555
"x86_64" => LLVMMachineType::AMD64,
5656
"x86" => LLVMMachineType::I386,
5757
"aarch64" => LLVMMachineType::ARM64,
58+
"arm64ec" => LLVMMachineType::ARM64EC,
5859
"arm" => LLVMMachineType::ARM,
5960
_ => panic!("unsupported cpu type {cpu}"),
6061
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub enum LLVMMachineType {
5656
AMD64 = 0x8664,
5757
I386 = 0x14c,
5858
ARM64 = 0xaa64,
59+
ARM64EC = 0xa641,
5960
ARM = 0x01c0,
6061
}
6162

compiler/rustc_codegen_llvm/src/llvm_util.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
204204
// which might lead to failures if the oldest tested / supported LLVM version
205205
// doesn't yet support the relevant intrinsics
206206
pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
207-
let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch };
207+
let arch = if sess.target.arch == "x86_64" {
208+
"x86"
209+
} else if sess.target.arch == "arm64ec" {
210+
"aarch64"
211+
} else {
212+
&*sess.target.arch
213+
};
208214
match (arch, s) {
209215
("x86", "sse4.2") => {
210216
LLVMFeature::with_dependency("sse4.2", TargetFeatureFoldStrength::EnableOnly("crc32"))

compiler/rustc_codegen_llvm/src/va_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
266266
// Generic x86
267267
"x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
268268
// Windows AArch64
269-
"aarch64" if target.is_like_windows => {
269+
"aarch64" | "arm64ec" if target.is_like_windows => {
270270
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
271271
}
272272
// macOS / iOS AArch64

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
# tidy-alphabetical-start
88
ar_archive_writer = "0.1.5"
99
bitflags = "2.4.1"
10-
cc = "1.0.69"
10+
cc = "1.0.88"
1111
itertools = "0.11"
1212
jobserver = "0.1.28"
1313
pathdiff = "0.2.0"

compiler/rustc_codegen_ssa/src/back/metadata.rs

+28-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::path::Path;
88
use object::write::{self, StandardSegment, Symbol, SymbolSection};
99
use object::{
1010
elf, pe, xcoff, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection,
11-
ObjectSymbol, SectionFlags, SectionKind, SymbolFlags, SymbolKind, SymbolScope,
11+
ObjectSymbol, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope,
1212
};
1313

1414
use rustc_data_structures::memmap::Mmap;
@@ -182,37 +182,40 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
182182
Endian::Little => Endianness::Little,
183183
Endian::Big => Endianness::Big,
184184
};
185-
let architecture = match &sess.target.arch[..] {
186-
"arm" => Architecture::Arm,
187-
"aarch64" => {
185+
let (architecture, sub_architecture) = match &sess.target.arch[..] {
186+
"arm" => (Architecture::Arm, None),
187+
"aarch64" => (
188188
if sess.target.pointer_width == 32 {
189189
Architecture::Aarch64_Ilp32
190190
} else {
191191
Architecture::Aarch64
192-
}
193-
}
194-
"x86" => Architecture::I386,
195-
"s390x" => Architecture::S390x,
196-
"mips" | "mips32r6" => Architecture::Mips,
197-
"mips64" | "mips64r6" => Architecture::Mips64,
198-
"x86_64" => {
192+
},
193+
None,
194+
),
195+
"x86" => (Architecture::I386, None),
196+
"s390x" => (Architecture::S390x, None),
197+
"mips" | "mips32r6" => (Architecture::Mips, None),
198+
"mips64" | "mips64r6" => (Architecture::Mips64, None),
199+
"x86_64" => (
199200
if sess.target.pointer_width == 32 {
200201
Architecture::X86_64_X32
201202
} else {
202203
Architecture::X86_64
203-
}
204-
}
205-
"powerpc" => Architecture::PowerPc,
206-
"powerpc64" => Architecture::PowerPc64,
207-
"riscv32" => Architecture::Riscv32,
208-
"riscv64" => Architecture::Riscv64,
209-
"sparc64" => Architecture::Sparc64,
210-
"avr" => Architecture::Avr,
211-
"msp430" => Architecture::Msp430,
212-
"hexagon" => Architecture::Hexagon,
213-
"bpf" => Architecture::Bpf,
214-
"loongarch64" => Architecture::LoongArch64,
215-
"csky" => Architecture::Csky,
204+
},
205+
None,
206+
),
207+
"powerpc" => (Architecture::PowerPc, None),
208+
"powerpc64" => (Architecture::PowerPc64, None),
209+
"riscv32" => (Architecture::Riscv32, None),
210+
"riscv64" => (Architecture::Riscv64, None),
211+
"sparc64" => (Architecture::Sparc64, None),
212+
"avr" => (Architecture::Avr, None),
213+
"msp430" => (Architecture::Msp430, None),
214+
"hexagon" => (Architecture::Hexagon, None),
215+
"bpf" => (Architecture::Bpf, None),
216+
"loongarch64" => (Architecture::LoongArch64, None),
217+
"csky" => (Architecture::Csky, None),
218+
"arm64ec" => (Architecture::Aarch64, Some(SubArchitecture::Arm64EC)),
216219
// Unsupported architecture.
217220
_ => return None,
218221
};
@@ -227,6 +230,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
227230
};
228231

229232
let mut file = write::Object::new(binary_format, architecture, endianness);
233+
file.set_sub_architecture(sub_architecture);
230234
if sess.target.is_like_osx {
231235
if macho_is_arm64e(&sess.target) {
232236
file.set_macho_cpu_subtype(object::macho::CPU_SUBTYPE_ARM64E);

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,10 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
563563
return undecorated;
564564
}
565565

566-
let x86 = match &target.arch[..] {
567-
"x86" => true,
568-
"x86_64" => false,
566+
let prefix = match &target.arch[..] {
567+
"x86" => Some('_'),
568+
"x86_64" => None,
569+
"arm64ec" => Some('#'),
569570
// Only x86/64 use symbol decorations.
570571
_ => return undecorated,
571572
};
@@ -602,8 +603,8 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
602603
Conv::X86Stdcall => ("_", "@"),
603604
Conv::X86VectorCall => ("", "@@"),
604605
_ => {
605-
if x86 {
606-
undecorated.insert(0, '_');
606+
if let Some(prefix) = prefix {
607+
undecorated.insert(0, prefix);
607608
}
608609
return undecorated;
609610
}

compiler/rustc_codegen_ssa/src/base.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,11 @@ impl CrateInfo {
907907
lang_items::required(tcx, l).then_some(name)
908908
})
909909
.collect();
910-
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };
910+
let prefix = match (target.is_like_windows, target.arch.as_ref()) {
911+
(true, "x86") => "_",
912+
(true, "arm64ec") => "#",
913+
_ => "",
914+
};
911915

912916
// This loop only adds new items to values of the hash map, so the order in which we
913917
// iterate over the values is not important.

compiler/rustc_errors/src/lib.rs

+32-18
Original file line numberDiff line numberDiff line change
@@ -712,33 +712,47 @@ impl DiagCtxt {
712712
/// Stashes a diagnostic for possible later improvement in a different,
713713
/// later stage of the compiler. Possible actions depend on the diagnostic
714714
/// level:
715+
/// - Level::Bug, Level:Fatal: not allowed, will trigger a panic.
715716
/// - Level::Error: immediately counted as an error that has occurred, because it
716717
/// is guaranteed to be emitted eventually. Can be later accessed with the
717718
/// provided `span` and `key` through
718719
/// [`DiagCtxt::try_steal_modify_and_emit_err`] or
719720
/// [`DiagCtxt::try_steal_replace_and_emit_err`]. These do not allow
720721
/// cancellation or downgrading of the error. Returns
721722
/// `Some(ErrorGuaranteed)`.
723+
/// - Level::DelayedBug: this does happen occasionally with errors that are
724+
/// downgraded to delayed bugs. It is not stashed, but immediately
725+
/// emitted as a delayed bug. This is because stashing it would cause it
726+
/// to be counted by `err_count` which we don't want. It doesn't matter
727+
/// that we cannot steal and improve it later, because it's not a
728+
/// user-facing error. Returns `Some(ErrorGuaranteed)` as is normal for
729+
/// delayed bugs.
722730
/// - Level::Warning and lower (i.e. !is_error()): can be accessed with the
723731
/// provided `span` and `key` through [`DiagCtxt::steal_non_err()`]. This
724732
/// allows cancelling and downgrading of the diagnostic. Returns `None`.
725-
/// - Others: not allowed, will trigger a panic.
726733
pub fn stash_diagnostic(
727734
&self,
728735
span: Span,
729736
key: StashKey,
730737
diag: DiagInner,
731738
) -> Option<ErrorGuaranteed> {
732-
let guar = if diag.level() == Level::Error {
733-
// This `unchecked_error_guaranteed` is valid. It is where the
734-
// `ErrorGuaranteed` for stashed errors originates. See
735-
// `DiagCtxtInner::drop`.
736-
#[allow(deprecated)]
737-
Some(ErrorGuaranteed::unchecked_error_guaranteed())
738-
} else if !diag.is_error() {
739-
None
740-
} else {
741-
self.span_bug(span, format!("invalid level in `stash_diagnostic`: {}", diag.level));
739+
let guar = match diag.level {
740+
Bug | Fatal => {
741+
self.span_bug(
742+
span,
743+
format!("invalid level in `stash_diagnostic`: {:?}", diag.level),
744+
);
745+
}
746+
Error => {
747+
// This `unchecked_error_guaranteed` is valid. It is where the
748+
// `ErrorGuaranteed` for stashed errors originates. See
749+
// `DiagCtxtInner::drop`.
750+
#[allow(deprecated)]
751+
Some(ErrorGuaranteed::unchecked_error_guaranteed())
752+
}
753+
DelayedBug => return self.inner.borrow_mut().emit_diagnostic(diag),
754+
ForceWarning(_) | Warning | Note | OnceNote | Help | OnceHelp | FailureNote | Allow
755+
| Expect(_) => None,
742756
};
743757

744758
// FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic
@@ -780,11 +794,11 @@ impl DiagCtxt {
780794
let err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
781795
err.map(|(err, guar)| {
782796
// The use of `::<ErrorGuaranteed>` is safe because level is `Level::Error`.
783-
assert_eq!(err.level, Level::Error);
797+
assert_eq!(err.level, Error);
784798
assert!(guar.is_some());
785799
let mut err = Diag::<ErrorGuaranteed>::new_diagnostic(self, err);
786800
modify_err(&mut err);
787-
assert_eq!(err.level, Level::Error);
801+
assert_eq!(err.level, Error);
788802
err.emit()
789803
})
790804
}
@@ -803,7 +817,7 @@ impl DiagCtxt {
803817
let old_err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
804818
match old_err {
805819
Some((old_err, guar)) => {
806-
assert_eq!(old_err.level, Level::Error);
820+
assert_eq!(old_err.level, Error);
807821
assert!(guar.is_some());
808822
// Because `old_err` has already been counted, it can only be
809823
// safely cancelled because the `new_err` supplants it.
@@ -1367,7 +1381,7 @@ impl DiagCtxtInner {
13671381
}
13681382

13691383
if diagnostic.has_future_breakage() {
1370-
// Future breakages aren't emitted if they're Level::Allow,
1384+
// Future breakages aren't emitted if they're `Level::Allow`,
13711385
// but they still need to be constructed and stashed below,
13721386
// so they'll trigger the must_produce_diag check.
13731387
self.suppressed_expected_diag = true;
@@ -1453,7 +1467,7 @@ impl DiagCtxtInner {
14531467
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
14541468
if already_emitted {
14551469
let msg = "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`";
1456-
diagnostic.sub(Level::Note, msg, MultiSpan::new());
1470+
diagnostic.sub(Note, msg, MultiSpan::new());
14571471
}
14581472

14591473
if is_error {
@@ -1623,7 +1637,7 @@ impl DiagCtxtInner {
16231637
bug.arg("level", bug.level);
16241638
let msg = crate::fluent_generated::errors_invalid_flushed_delayed_diagnostic_level;
16251639
let msg = self.eagerly_translate_for_subdiag(&bug, msg); // after the `arg` call
1626-
bug.sub(Level::Note, msg, bug.span.primary_span().unwrap().into());
1640+
bug.sub(Note, msg, bug.span.primary_span().unwrap().into());
16271641
}
16281642
bug.level = Bug;
16291643

@@ -1671,7 +1685,7 @@ impl DelayedDiagInner {
16711685
diag.arg("emitted_at", diag.emitted_at.clone());
16721686
diag.arg("note", self.note);
16731687
let msg = dcx.eagerly_translate_for_subdiag(&diag, msg); // after the `arg` calls
1674-
diag.sub(Level::Note, msg, diag.span.primary_span().unwrap_or(DUMMY_SP).into());
1688+
diag.sub(Note, msg, diag.span.primary_span().unwrap_or(DUMMY_SP).into());
16751689
diag
16761690
}
16771691
}

compiler/rustc_hir_analysis/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ hir_analysis_missing_one_of_trait_item = not all trait items implemented, missin
239239
.label = missing one of `{$missing_items_msg}` in implementation
240240
.note = required because of this annotation
241241
242-
hir_analysis_missing_tilde_const = missing `~const` qualifier for specialization
243-
244242
hir_analysis_missing_trait_item = not all trait items implemented, missing: `{$missing_items_msg}`
245243
.label = missing `{$missing_items_msg}` in implementation
246244

compiler/rustc_hir_analysis/src/astconv/lint.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_ast::TraitObjectSyntax;
2-
use rustc_errors::{codes::*, Diag, EmissionGuarantee, Level, StashKey};
2+
use rustc_errors::{codes::*, Diag, EmissionGuarantee, StashKey};
33
use rustc_hir as hir;
44
use rustc_hir::def::{DefKind, Res};
55
use rustc_lint_defs::{builtin::BARE_TRAIT_OBJECTS, Applicability};
@@ -237,15 +237,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
237237
}
238238
// check if the impl trait that we are considering is a impl of a local trait
239239
self.maybe_lint_blanket_trait_impl(self_ty, &mut diag);
240-
match diag.level() {
241-
Level::Error => {
242-
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
243-
}
244-
Level::DelayedBug => {
245-
diag.emit();
246-
}
247-
_ => unreachable!(),
248-
}
240+
diag.stash(self_ty.span, StashKey::TraitMissingMethod);
249241
} else {
250242
let msg = "trait objects without an explicit `dyn` are deprecated";
251243
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, msg, |lint| {

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,23 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12471247
(&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => {
12481248
let did1 = def1.did();
12491249
let did2 = def2.did();
1250-
let sub_no_defaults_1 =
1251-
self.tcx.generics_of(did1).own_args_no_defaults(self.tcx, sub1);
1252-
let sub_no_defaults_2 =
1253-
self.tcx.generics_of(did2).own_args_no_defaults(self.tcx, sub2);
1250+
1251+
let generics1 = self.tcx.generics_of(did1);
1252+
let generics2 = self.tcx.generics_of(did2);
1253+
1254+
let non_default_after_default = generics1
1255+
.check_concrete_type_after_default(self.tcx, sub1)
1256+
|| generics2.check_concrete_type_after_default(self.tcx, sub2);
1257+
let sub_no_defaults_1 = if non_default_after_default {
1258+
generics1.own_args(sub1)
1259+
} else {
1260+
generics1.own_args_no_defaults(self.tcx, sub1)
1261+
};
1262+
let sub_no_defaults_2 = if non_default_after_default {
1263+
generics2.own_args(sub2)
1264+
} else {
1265+
generics2.own_args_no_defaults(self.tcx, sub2)
1266+
};
12541267
let mut values = (DiagStyledString::new(), DiagStyledString::new());
12551268
let path1 = self.tcx.def_path_str(did1);
12561269
let path2 = self.tcx.def_path_str(did2);

0 commit comments

Comments
 (0)