Skip to content

Commit b6a8c76

Browse files
committed
Auto merge of rust-lang#119662 - matthiaskrgr:rollup-ehofh5n, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#118194 (rustdoc: search for tuples and unit by type with `()`) - rust-lang#118781 (merge core_panic feature into panic_internals) - rust-lang#119486 (pass allow-{dirty,staged} to clippy) - rust-lang#119591 (rustc_mir_transform: Make DestinationPropagation stable for queries) - rust-lang#119595 (Fixed ambiguity in hint.rs) - rust-lang#119624 (rustc_span: More consistent span combination operations) - rust-lang#119653 (compiler: update Fuchsia sanitizer support.) - rust-lang#119655 (Remove ignore-stage1 that was added when changing error count msg) - rust-lang#119661 (Strip lld-wrapper binaries) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9212108 + 5f0f028 commit b6a8c76

File tree

66 files changed

+909
-235
lines changed

Some content is hidden

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

66 files changed

+909
-235
lines changed

Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ gimli.debug = 0
104104
miniz_oxide.debug = 0
105105
object.debug = 0
106106

107+
# These are very thin wrappers around executing lld with the right binary name.
108+
# Basically nothing within them can go wrong without having been explicitly logged anyway.
109+
# We ship these in every rustc tarball and even after compression they add up
110+
# to around 0.6MB of data every user needs to download (and 15MB on disk).
111+
[profile.release.package.lld-wrapper]
112+
debug = 0
113+
strip = true
114+
107115
[patch.crates-io]
108116
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
109117
# here

compiler/rustc_data_structures/src/fx.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub type StdEntry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
77
pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, BuildHasherDefault<FxHasher>>;
88
pub type FxIndexSet<V> = indexmap::IndexSet<V, BuildHasherDefault<FxHasher>>;
99
pub type IndexEntry<'a, K, V> = indexmap::map::Entry<'a, K, V>;
10+
pub type IndexOccupiedEntry<'a, K, V> = indexmap::map::OccupiedEntry<'a, K, V>;
1011

1112
#[macro_export]
1213
macro_rules! define_id_collections {

compiler/rustc_mir_transform/src/dest_prop.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@
131131
//! [attempt 2]: https://github.com/rust-lang/rust/pull/71003
132132
//! [attempt 3]: https://github.com/rust-lang/rust/pull/72632
133133
134-
use std::collections::hash_map::{Entry, OccupiedEntry};
135-
136134
use crate::MirPass;
137-
use rustc_data_structures::fx::FxHashMap;
135+
use rustc_data_structures::fx::{FxIndexMap, IndexEntry, IndexOccupiedEntry};
138136
use rustc_index::bit_set::BitSet;
139137
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
140138
use rustc_middle::mir::HasLocalDecls;
@@ -211,7 +209,7 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
211209
let mut merged_locals: BitSet<Local> = BitSet::new_empty(body.local_decls.len());
212210

213211
// This is the set of merges we will apply this round. It is a subset of the candidates.
214-
let mut merges = FxHashMap::default();
212+
let mut merges = FxIndexMap::default();
215213

216214
for (src, candidates) in candidates.c.iter() {
217215
if merged_locals.contains(*src) {
@@ -250,8 +248,8 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
250248
/// frequently. Everything with a `&'alloc` lifetime points into here.
251249
#[derive(Default)]
252250
struct Allocations {
253-
candidates: FxHashMap<Local, Vec<Local>>,
254-
candidates_reverse: FxHashMap<Local, Vec<Local>>,
251+
candidates: FxIndexMap<Local, Vec<Local>>,
252+
candidates_reverse: FxIndexMap<Local, Vec<Local>>,
255253
write_info: WriteInfo,
256254
// PERF: Do this for `MaybeLiveLocals` allocations too.
257255
}
@@ -272,11 +270,11 @@ struct Candidates<'alloc> {
272270
///
273271
/// We will still report that we would like to merge `_1` and `_2` in an attempt to allow us to
274272
/// remove that assignment.
275-
c: &'alloc mut FxHashMap<Local, Vec<Local>>,
273+
c: &'alloc mut FxIndexMap<Local, Vec<Local>>,
276274
/// A reverse index of the `c` set; if the `c` set contains `a => Place { local: b, proj }`,
277275
/// then this contains `b => a`.
278276
// PERF: Possibly these should be `SmallVec`s?
279-
reverse: &'alloc mut FxHashMap<Local, Vec<Local>>,
277+
reverse: &'alloc mut FxIndexMap<Local, Vec<Local>>,
280278
}
281279

282280
//////////////////////////////////////////////////////////
@@ -287,7 +285,7 @@ struct Candidates<'alloc> {
287285
fn apply_merges<'tcx>(
288286
body: &mut Body<'tcx>,
289287
tcx: TyCtxt<'tcx>,
290-
merges: &FxHashMap<Local, Local>,
288+
merges: &FxIndexMap<Local, Local>,
291289
merged_locals: &BitSet<Local>,
292290
) {
293291
let mut merger = Merger { tcx, merges, merged_locals };
@@ -296,7 +294,7 @@ fn apply_merges<'tcx>(
296294

297295
struct Merger<'a, 'tcx> {
298296
tcx: TyCtxt<'tcx>,
299-
merges: &'a FxHashMap<Local, Local>,
297+
merges: &'a FxIndexMap<Local, Local>,
300298
merged_locals: &'a BitSet<Local>,
301299
}
302300

@@ -379,7 +377,7 @@ impl<'alloc> Candidates<'alloc> {
379377

380378
/// `vec_filter_candidates` but for an `Entry`
381379
fn entry_filter_candidates(
382-
mut entry: OccupiedEntry<'_, Local, Vec<Local>>,
380+
mut entry: IndexOccupiedEntry<'_, Local, Vec<Local>>,
383381
p: Local,
384382
f: impl FnMut(Local) -> CandidateFilter,
385383
at: Location,
@@ -399,7 +397,7 @@ impl<'alloc> Candidates<'alloc> {
399397
at: Location,
400398
) {
401399
// Cover the cases where `p` appears as a `src`
402-
if let Entry::Occupied(entry) = self.c.entry(p) {
400+
if let IndexEntry::Occupied(entry) = self.c.entry(p) {
403401
Self::entry_filter_candidates(entry, p, &mut f, at);
404402
}
405403
// And the cases where `p` appears as a `dest`
@@ -412,7 +410,7 @@ impl<'alloc> Candidates<'alloc> {
412410
if f(*src) == CandidateFilter::Keep {
413411
return true;
414412
}
415-
let Entry::Occupied(entry) = self.c.entry(*src) else {
413+
let IndexEntry::Occupied(entry) = self.c.entry(*src) else {
416414
return false;
417415
};
418416
Self::entry_filter_candidates(
@@ -721,8 +719,8 @@ fn places_to_candidate_pair<'tcx>(
721719
fn find_candidates<'alloc, 'tcx>(
722720
body: &Body<'tcx>,
723721
borrowed: &BitSet<Local>,
724-
candidates: &'alloc mut FxHashMap<Local, Vec<Local>>,
725-
candidates_reverse: &'alloc mut FxHashMap<Local, Vec<Local>>,
722+
candidates: &'alloc mut FxIndexMap<Local, Vec<Local>>,
723+
candidates_reverse: &'alloc mut FxIndexMap<Local, Vec<Local>>,
726724
) -> Candidates<'alloc> {
727725
candidates.clear();
728726
candidates_reverse.clear();
@@ -744,7 +742,7 @@ fn find_candidates<'alloc, 'tcx>(
744742

745743
struct FindAssignments<'a, 'alloc, 'tcx> {
746744
body: &'a Body<'tcx>,
747-
candidates: &'alloc mut FxHashMap<Local, Vec<Local>>,
745+
candidates: &'alloc mut FxIndexMap<Local, Vec<Local>>,
748746
borrowed: &'a BitSet<Local>,
749747
}
750748

compiler/rustc_parse/src/parser/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ impl<'a> Parser<'a> {
24892489
}
24902490
ExprKind::Block(_, None) => {
24912491
this.dcx().emit_err(errors::IfExpressionMissingCondition {
2492-
if_span: lo.shrink_to_hi(),
2492+
if_span: lo.with_neighbor(cond.span).shrink_to_hi(),
24932493
block_span: self.sess.source_map().start_point(cond_span),
24942494
});
24952495
std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi()))
@@ -3735,7 +3735,7 @@ impl<'a> Parser<'a> {
37353735
}
37363736

37373737
pub(crate) fn mk_expr(&self, span: Span, kind: ExprKind) -> P<Expr> {
3738-
P(Expr { kind, span, attrs: AttrVec::new(), id: DUMMY_NODE_ID, tokens: None })
3738+
self.mk_expr_with_attrs(span, kind, AttrVec::new())
37393739
}
37403740

37413741
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {

compiler/rustc_parse/src/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ impl<'a> Parser<'a> {
21182118
Applicability::MaybeIncorrect,
21192119
);
21202120
err.span_suggestion(
2121-
span.shrink_to_hi(),
2121+
span.with_neighbor(self.token.span).shrink_to_hi(),
21222122
"add a semicolon",
21232123
';',
21242124
Applicability::MaybeIncorrect,
@@ -2632,7 +2632,7 @@ impl<'a> Parser<'a> {
26322632

26332633
let is_name_required = match this.token.kind {
26342634
token::DotDotDot => false,
2635-
_ => req_name(this.token.span.edition()),
2635+
_ => req_name(this.token.span.with_neighbor(this.prev_token.span).edition()),
26362636
};
26372637
let (pat, ty) = if is_name_required || this.is_named_param() {
26382638
debug!("parse_param_general parse_pat (is_name_required:{})", is_name_required);

compiler/rustc_span/src/hygiene.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -852,21 +852,6 @@ impl fmt::Debug for SyntaxContext {
852852
}
853853

854854
impl Span {
855-
/// Creates a fresh expansion with given properties.
856-
/// Expansions are normally created by macros, but in some cases expansions are created for
857-
/// other compiler-generated code to set per-span properties like allowed unstable features.
858-
/// The returned span belongs to the created expansion and has the new properties,
859-
/// but its location is inherited from the current span.
860-
pub fn fresh_expansion(self, expn_id: LocalExpnId) -> Span {
861-
HygieneData::with(|data| {
862-
self.with_ctxt(data.apply_mark(
863-
self.ctxt(),
864-
expn_id.to_expn_id(),
865-
Transparency::Transparent,
866-
))
867-
})
868-
}
869-
870855
/// Reuses the span but adds information like the kind of the desugaring and features that are
871856
/// allowed inside this span.
872857
pub fn mark_with_reason(
@@ -881,7 +866,7 @@ impl Span {
881866
..ExpnData::default(ExpnKind::Desugaring(reason), self, edition, None, None)
882867
};
883868
let expn_id = LocalExpnId::fresh(expn_data, ctx);
884-
self.fresh_expansion(expn_id)
869+
self.apply_mark(expn_id.to_expn_id(), Transparency::Transparent)
885870
}
886871
}
887872

compiler/rustc_span/src/lib.rs

+47-49
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,39 @@ impl Span {
825825
)
826826
}
827827

828+
/// Prepare two spans to a combine operation like `to` or `between`.
829+
/// FIXME: consider using declarative macro metavariable spans for the given spans if they are
830+
/// better suitable for combining (#119412).
831+
fn prepare_to_combine(
832+
a_orig: Span,
833+
b_orig: Span,
834+
) -> Result<(SpanData, SpanData, Option<LocalDefId>), Span> {
835+
let (a, b) = (a_orig.data(), b_orig.data());
836+
837+
if a.ctxt != b.ctxt {
838+
// Context mismatches usually happen when procedural macros combine spans copied from
839+
// the macro input with spans produced by the macro (`Span::*_site`).
840+
// In that case we consider the combined span to be produced by the macro and return
841+
// the original macro-produced span as the result.
842+
// Otherwise we just fall back to returning the first span.
843+
// Combining locations typically doesn't make sense in case of context mismatches.
844+
// `is_root` here is a fast path optimization.
845+
let a_is_callsite = a.ctxt.is_root() || a.ctxt == b.span().source_callsite().ctxt();
846+
return Err(if a_is_callsite { b_orig } else { a_orig });
847+
}
848+
849+
let parent = if a.parent == b.parent { a.parent } else { None };
850+
Ok((a, b, parent))
851+
}
852+
853+
/// This span, but in a larger context, may switch to the metavariable span if suitable.
854+
pub fn with_neighbor(self, neighbor: Span) -> Span {
855+
match Span::prepare_to_combine(self, neighbor) {
856+
Ok((this, ..)) => Span::new(this.lo, this.hi, this.ctxt, this.parent),
857+
Err(_) => self,
858+
}
859+
}
860+
828861
/// Returns a `Span` that would enclose both `self` and `end`.
829862
///
830863
/// Note that this can also be used to extend the span "backwards":
@@ -836,26 +869,12 @@ impl Span {
836869
/// ^^^^^^^^^^^^^^^^^^^^
837870
/// ```
838871
pub fn to(self, end: Span) -> Span {
839-
let span_data = self.data();
840-
let end_data = end.data();
841-
// FIXME(jseyfried): `self.ctxt` should always equal `end.ctxt` here (cf. issue #23480).
842-
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
843-
// have an incomplete span than a completely nonsensical one.
844-
if span_data.ctxt != end_data.ctxt {
845-
if span_data.ctxt.is_root() {
846-
return end;
847-
} else if end_data.ctxt.is_root() {
848-
return self;
872+
match Span::prepare_to_combine(self, end) {
873+
Ok((from, to, parent)) => {
874+
Span::new(cmp::min(from.lo, to.lo), cmp::max(from.hi, to.hi), from.ctxt, parent)
849875
}
850-
// Both spans fall within a macro.
851-
// FIXME(estebank): check if it is the *same* macro.
876+
Err(fallback) => fallback,
852877
}
853-
Span::new(
854-
cmp::min(span_data.lo, end_data.lo),
855-
cmp::max(span_data.hi, end_data.hi),
856-
if span_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
857-
if span_data.parent == end_data.parent { span_data.parent } else { None },
858-
)
859878
}
860879

861880
/// Returns a `Span` between the end of `self` to the beginning of `end`.
@@ -866,14 +885,12 @@ impl Span {
866885
/// ^^^^^^^^^^^^^
867886
/// ```
868887
pub fn between(self, end: Span) -> Span {
869-
let span = self.data();
870-
let end = end.data();
871-
Span::new(
872-
span.hi,
873-
end.lo,
874-
if end.ctxt.is_root() { end.ctxt } else { span.ctxt },
875-
if span.parent == end.parent { span.parent } else { None },
876-
)
888+
match Span::prepare_to_combine(self, end) {
889+
Ok((from, to, parent)) => {
890+
Span::new(cmp::min(from.hi, to.hi), cmp::max(from.lo, to.lo), from.ctxt, parent)
891+
}
892+
Err(fallback) => fallback,
893+
}
877894
}
878895

879896
/// Returns a `Span` from the beginning of `self` until the beginning of `end`.
@@ -884,31 +901,12 @@ impl Span {
884901
/// ^^^^^^^^^^^^^^^^^
885902
/// ```
886903
pub fn until(self, end: Span) -> Span {
887-
// Most of this function's body is copied from `to`.
888-
// We can't just do `self.to(end.shrink_to_lo())`,
889-
// because to also does some magic where it uses min/max so
890-
// it can handle overlapping spans. Some advanced mis-use of
891-
// `until` with different ctxts makes this visible.
892-
let span_data = self.data();
893-
let end_data = end.data();
894-
// FIXME(jseyfried): `self.ctxt` should always equal `end.ctxt` here (cf. issue #23480).
895-
// Return the macro span on its own to avoid weird diagnostic output. It is preferable to
896-
// have an incomplete span than a completely nonsensical one.
897-
if span_data.ctxt != end_data.ctxt {
898-
if span_data.ctxt.is_root() {
899-
return end;
900-
} else if end_data.ctxt.is_root() {
901-
return self;
904+
match Span::prepare_to_combine(self, end) {
905+
Ok((from, to, parent)) => {
906+
Span::new(cmp::min(from.lo, to.lo), cmp::max(from.lo, to.lo), from.ctxt, parent)
902907
}
903-
// Both spans fall within a macro.
904-
// FIXME(estebank): check if it is the *same* macro.
908+
Err(fallback) => fallback,
905909
}
906-
Span::new(
907-
span_data.lo,
908-
end_data.lo,
909-
if end_data.ctxt.is_root() { end_data.ctxt } else { span_data.ctxt },
910-
if span_data.parent == end_data.parent { span_data.parent } else { None },
911-
)
912910
}
913911

914912
pub fn from_inner(self, inner: InnerSpan) -> Span {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ pub fn target() -> Target {
66
base.plt_by_default = false;
77
base.max_atomic_width = Some(64);
88
base.stack_probes = StackProbeType::Inline;
9-
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI;
9+
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK;
10+
base.supports_xray = true;
1011

1112
Target {
1213
llvm_target: "x86_64-unknown-fuchsia".into(),

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
#![feature(const_size_of_val)]
121121
#![feature(const_waker)]
122122
#![feature(core_intrinsics)]
123-
#![feature(core_panic)]
124123
#![feature(deprecated_suggestion)]
125124
#![feature(dispatch_from_dyn)]
126125
#![feature(error_generic_member_access)]
@@ -139,6 +138,7 @@
139138
#![feature(maybe_uninit_slice)]
140139
#![feature(maybe_uninit_uninit_array)]
141140
#![feature(maybe_uninit_uninit_array_transpose)]
141+
#![feature(panic_internals)]
142142
#![feature(pattern)]
143143
#![feature(ptr_internals)]
144144
#![feature(ptr_metadata)]

library/core/src/hint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub fn spin_loop() {
287287
///
288288
/// The compiler could theoretically make optimizations like the following:
289289
///
290-
/// - `needle` and `haystack` are always the same, move the call to `contains` outside the loop and
290+
/// - The `needle` and `haystack` do not change, move the call to `contains` outside the loop and
291291
/// delete the loop
292292
/// - Inline `contains`
293293
/// - `needle` and `haystack` have values known at compile time, `contains` is always true. Remove

library/core/src/intrinsics/mir.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
//! ```rust
6666
//! #![feature(core_intrinsics, custom_mir)]
6767
//! #![allow(internal_features)]
68+
//! #![allow(unused_assignments)]
6869
//!
6970
//! use core::intrinsics::mir::*;
7071
//!

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
#![feature(const_unicode_case_lookup)]
168168
#![feature(const_unsafecell_get_mut)]
169169
#![feature(const_waker)]
170-
#![feature(core_panic)]
171170
#![feature(coverage_attribute)]
172171
#![feature(duration_consts_float)]
173172
#![feature(internal_impls_macro)]
@@ -179,6 +178,7 @@
179178
#![feature(non_null_convenience)]
180179
#![feature(offset_of)]
181180
#![feature(offset_of_enum)]
181+
#![feature(panic_internals)]
182182
#![feature(ptr_alignment_type)]
183183
#![feature(ptr_metadata)]
184184
#![feature(set_ptr_value)]

0 commit comments

Comments
 (0)