Skip to content

Commit 5a68900

Browse files
committed
Auto merge of #144520 - jhpratt:rollup-40b9kge, r=jhpratt
Rollup of 13 pull requests Successful merges: - #144359 (add codegen test for variadics) - #144379 (test using multiple c-variadic ABIs in the same program) - #144383 (disable cfg.has_reliable_f128 on amdgcn) - #144409 (Stop compilation early if macro expansion failed) - #144422 (library/windows_targets: Fix macro expansion error in 'link' macro) - #144429 (Enable outline-atomics for aarch64-unknown-linux-musl) - #144430 (tests: aarch64-outline-atomics: Remove hardcoded target) - #144445 (Fix `./x check bootstrap` (again)) - #144453 (canonicalize build root in `tests/run-make/linker-warning`) - #144464 (Only run bootstrap tests in `x test` on CI) - #144470 (clif: Don't set the `compiler-builtins-no-f16-f128` feature) - #144480 (Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen") - #144495 (bump cargo_metadata) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 283a074 + a510f44 commit 5a68900

File tree

59 files changed

+640
-425
lines changed

Some content is hidden

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

59 files changed

+640
-425
lines changed

Cargo.lock

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -441,20 +441,6 @@ dependencies = [
441441
"thiserror 1.0.69",
442442
]
443443

444-
[[package]]
445-
name = "cargo_metadata"
446-
version = "0.19.2"
447-
source = "registry+https://github.com/rust-lang/crates.io-index"
448-
checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba"
449-
dependencies = [
450-
"camino",
451-
"cargo-platform 0.1.9",
452-
"semver",
453-
"serde",
454-
"serde_json",
455-
"thiserror 2.0.12",
456-
]
457-
458444
[[package]]
459445
name = "cargo_metadata"
460446
version = "0.21.0"
@@ -1364,7 +1350,7 @@ version = "0.1.0"
13641350
dependencies = [
13651351
"anyhow",
13661352
"askama",
1367-
"cargo_metadata 0.18.1",
1353+
"cargo_metadata 0.21.0",
13681354
"serde",
13691355
"serde_json",
13701356
"thiserror 1.0.69",
@@ -5370,7 +5356,7 @@ name = "tidy"
53705356
version = "0.1.0"
53715357
dependencies = [
53725358
"build_helper",
5373-
"cargo_metadata 0.19.2",
5359+
"cargo_metadata 0.21.0",
53745360
"fluent-syntax",
53755361
"ignore",
53765362
"miropt-test-tools",

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ impl Coords {
3939
/// or other expansions), and if it does happen then skipping a span or function is
4040
/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
4141
pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
42-
if span.is_empty() {
43-
debug_assert!(false, "can't make coords from empty span: {span:?}");
44-
return None;
45-
}
42+
let span = ensure_non_empty_span(source_map, span)?;
4643

4744
let lo = span.lo();
4845
let hi = span.hi();
@@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
7370
})
7471
}
7572

73+
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
74+
if !span.is_empty() {
75+
return Some(span);
76+
}
77+
78+
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
79+
source_map
80+
.span_to_source(span, |src, start, end| try {
81+
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
82+
// but in this case we have specifically checked that the character
83+
// we're skipping over is one of two specific ASCII characters, so
84+
// adjusting by exactly 1 byte is correct.
85+
if src.as_bytes().get(end).copied() == Some(b'{') {
86+
Some(span.with_hi(span.hi() + BytePos(1)))
87+
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
88+
Some(span.with_lo(span.lo() - BytePos(1)))
89+
} else {
90+
None
91+
}
92+
})
93+
.ok()?
94+
}
95+
7696
/// If `llvm-cov` sees a source region that is improperly ordered (end < start),
7797
/// it will immediately exit with a fatal error. To prevent that from happening,
7898
/// discard regions that are improperly ordered, or might be interpreted in a

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
405405
("mips64" | "mips64r6", _) => false,
406406
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
407407
("nvptx64", _) => false,
408+
// Unsupported https://github.com/llvm/llvm-project/issues/121122
409+
("amdgpu", _) => false,
408410
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
409411
// list at <https://github.com/rust-lang/rust/issues/116909>)
410412
("powerpc" | "powerpc64", _) => false,

compiler/rustc_expand/src/base.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ pub struct ExtCtxt<'a> {
12241224
pub(super) expanded_inert_attrs: MarkedAttrs,
12251225
/// `-Zmacro-stats` data.
12261226
pub macro_stats: FxHashMap<(Symbol, MacroKind), MacroStat>,
1227+
pub nb_macro_errors: usize,
12271228
}
12281229

12291230
impl<'a> ExtCtxt<'a> {
@@ -1254,6 +1255,7 @@ impl<'a> ExtCtxt<'a> {
12541255
expanded_inert_attrs: MarkedAttrs::new(),
12551256
buffered_early_lint: vec![],
12561257
macro_stats: Default::default(),
1258+
nb_macro_errors: 0,
12571259
}
12581260
}
12591261

@@ -1315,6 +1317,12 @@ impl<'a> ExtCtxt<'a> {
13151317
self.current_expansion.id.expansion_cause()
13161318
}
13171319

1320+
/// This method increases the internal macro errors count and then call `trace_macros_diag`.
1321+
pub fn macro_error_and_trace_macros_diag(&mut self) {
1322+
self.nb_macro_errors += 1;
1323+
self.trace_macros_diag();
1324+
}
1325+
13181326
pub fn trace_macros_diag(&mut self) {
13191327
for (span, notes) in self.expansions.iter() {
13201328
let mut db = self.dcx().create_note(errors::TraceMacro { span: *span });

compiler/rustc_expand/src/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
693693
crate_name: self.cx.ecfg.crate_name,
694694
});
695695

696-
self.cx.trace_macros_diag();
696+
self.cx.macro_error_and_trace_macros_diag();
697697
guar
698698
}
699699

@@ -707,7 +707,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
707707
) -> ErrorGuaranteed {
708708
let guar =
709709
self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path });
710-
self.cx.trace_macros_diag();
710+
self.cx.macro_error_and_trace_macros_diag();
711711
guar
712712
}
713713

@@ -1048,7 +1048,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
10481048
}
10491049
annotate_err_with_kind(&mut err, kind, span);
10501050
let guar = err.emit();
1051-
self.cx.trace_macros_diag();
1051+
self.cx.macro_error_and_trace_macros_diag();
10521052
kind.dummy(span, guar)
10531053
}
10541054
}

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ enum EofMatcherPositions {
299299
}
300300

301301
/// Represents the possible results of an attempted parse.
302+
#[derive(Debug)]
302303
pub(crate) enum ParseResult<T, F> {
303304
/// Parsed successfully.
304305
Success(T),

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn expand_macro<'cx>(
280280
// Retry and emit a better error.
281281
let (span, guar) =
282282
diagnostics::failed_to_match_macro(cx.psess(), sp, def_span, name, arg, rules);
283-
cx.trace_macros_diag();
283+
cx.macro_error_and_trace_macros_diag();
284284
DummyResult::any(span, guar)
285285
}
286286
}

compiler/rustc_interface/src/passes.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ fn configure_and_expand(
208208
// Expand macros now!
209209
let krate = sess.time("expand_crate", || ecx.monotonic_expander().expand_crate(krate));
210210

211+
if ecx.nb_macro_errors > 0 {
212+
sess.dcx().abort_if_errors();
213+
}
214+
211215
// The rest is error reporting and stats
212216

213217
sess.psess.buffered_lints.with_lock(|buffered_lints: &mut Vec<BufferedEarlyLint>| {

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use rustc_data_structures::fx::FxHashSet;
22
use rustc_middle::mir;
33
use rustc_middle::ty::TyCtxt;
4-
use rustc_span::source_map::SourceMap;
5-
use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span};
4+
use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span};
65
use tracing::instrument;
76

87
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph};
@@ -84,18 +83,8 @@ pub(super) fn extract_refined_covspans<'tcx>(
8483
// Discard any span that overlaps with a hole.
8584
discard_spans_overlapping_holes(&mut covspans, &holes);
8685

87-
// Discard spans that overlap in unwanted ways.
86+
// Perform more refinement steps after holes have been dealt with.
8887
let mut covspans = remove_unwanted_overlapping_spans(covspans);
89-
90-
// For all empty spans, either enlarge them to be non-empty, or discard them.
91-
let source_map = tcx.sess.source_map();
92-
covspans.retain_mut(|covspan| {
93-
let Some(span) = ensure_non_empty_span(source_map, covspan.span) else { return false };
94-
covspan.span = span;
95-
true
96-
});
97-
98-
// Merge covspans that can be merged.
9988
covspans.dedup_by(|b, a| a.merge_if_eligible(b));
10089

10190
code_mappings.extend(covspans.into_iter().map(|Covspan { span, bcb }| {
@@ -241,26 +230,3 @@ fn compare_spans(a: Span, b: Span) -> std::cmp::Ordering {
241230
// - Both have the same start and span A extends further right
242231
.then_with(|| Ord::cmp(&a.hi(), &b.hi()).reverse())
243232
}
244-
245-
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
246-
if !span.is_empty() {
247-
return Some(span);
248-
}
249-
250-
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
251-
source_map
252-
.span_to_source(span, |src, start, end| try {
253-
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
254-
// but in this case we have specifically checked that the character
255-
// we're skipping over is one of two specific ASCII characters, so
256-
// adjusting by exactly 1 byte is correct.
257-
if src.as_bytes().get(end).copied() == Some(b'{') {
258-
Some(span.with_hi(span.hi() + BytePos(1)))
259-
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
260-
Some(span.with_lo(span.lo() - BytePos(1)))
261-
} else {
262-
None
263-
}
264-
})
265-
.ok()?
266-
}

compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
let mut base = base::linux_musl::opts();
77
base.max_atomic_width = Some(128);
88
base.supports_xray = true;
9-
base.features = "+v8a".into();
9+
base.features = "+v8a,+outline-atomics".into();
1010
base.stack_probes = StackProbeType::Inline;
1111
base.supported_sanitizers = SanitizerSet::ADDRESS
1212
| SanitizerSet::CFI

0 commit comments

Comments
 (0)