Skip to content

Rollup of 11 pull requests #144611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
54a4701
tests: Test line number in debuginfo for diverging function calls
Enselic Jul 16, 2025
66d2d16
Create two methods to fix `find_oldest_ancestor_in_same_ctxt`
xizheyin Jul 21, 2025
c89fe80
Rename extended rustc tool macros
Kobzol Jun 18, 2025
d1683e7
Add metadata to `Cargo` and `RustAnalyzer` tools
Kobzol Jul 22, 2025
ca66698
Cleanup `ensure_if_default` to not require `Option` output
Kobzol Jul 22, 2025
1783af7
Add step metadata to `RustAnalyzerProcMacroSrv`
Kobzol Jul 22, 2025
533a78d
Rename `Builder::rustdoc` to `Builder::rustdoc_for_compiler`
Kobzol Jul 22, 2025
7a5f9cb
Implement `RustcPrivateCompilers` to unify building of `rustc_private…
Kobzol Jul 22, 2025
d5ac269
Add step metadata and a few tests for `Doc` steps
Kobzol Jul 22, 2025
6fecbb9
Refactor `Rustdoc`
Kobzol Jul 22, 2025
006a9bd
Fix `ToolRustc` build with `download-rustc`
Kobzol Jul 22, 2025
acb2379
Add step metadata and a simple test for codegen backends
Kobzol Jul 22, 2025
efbaa77
Port codegen backends to `RustcPrivateCompilers`
Kobzol Jul 22, 2025
3f53fba
Rename `link_compiler` to `target_compiler`
Kobzol Jul 22, 2025
7bf4a1a
Appease Clippy
Kobzol Jul 22, 2025
e497abc
Add stabilization template and revise docs
Jan 23, 2025
857f46e
Address review feedback
nikomatsakis Jan 23, 2025
7547b15
Address review feedback
jieyouxu Jun 19, 2025
64604ad
Revise content on lang feature processes
traviscross Jul 23, 2025
9c99623
Merge PR: Stabilization template, docs
traviscross Jul 25, 2025
d12ecde
constify with_exposed_provenance
RalfJung Jul 27, 2025
72927f6
Ensure correct aligement of rustc_hir::Lifetime on platforms with low…
FractalFir Jul 27, 2025
8d82365
Prepare for merging from rust-lang/rust
invalid-email-address Jul 28, 2025
645b85e
Merge ref '2b5e239c6b86' from rust-lang/rust
invalid-email-address Jul 28, 2025
173926d
Remove `[T]::array_chunks(_mut)`
scottmcm Jul 1, 2025
466198c
Merge pull request #2519 from rust-lang/rustc-pull
tshepang Jul 28, 2025
66445e7
fix pauses
tshepang Jul 28, 2025
b707493
reword to avoid using a term used in a confusing manner, "error annot…
tshepang Jul 28, 2025
bfca77b
Merge pull request #2520 from rust-lang/tshepang/error-pattern
tshepang Jul 28, 2025
f29f073
add support for ./x check src/tools/linkchecker
pietroalbini Jul 13, 2025
c745614
bump linkchecker to edition 2024
pietroalbini Jul 13, 2025
984926e
add an argument parser to linkchecker
pietroalbini Jul 1, 2025
2b11851
Raw Pointers are Constant PatKinds too
BoxyUwU Jul 28, 2025
6693b39
add --link-targets-dir flag to linkchecker
pietroalbini Jul 1, 2025
68f08c5
Add `core::mem::DropGuard`
yoshuawuyts Jul 21, 2025
71920e2
fix `Atomic*::as_ptr` wording
usamoi Jul 28, 2025
b7c9530
Rollup merge of #143289 - scottmcm:remove-array-chunks, r=jhpratt
samueltardieu Jul 28, 2025
29ebedd
Rollup merge of #143883 - pietroalbini:pa-linkchecker-extra-target, r…
samueltardieu Jul 28, 2025
2510636
Rollup merge of #144034 - Enselic:diverging-function-call-debuginfo, …
samueltardieu Jul 28, 2025
908fe53
Rollup merge of #144236 - yoshuawuyts:drop-guard, r=Mark-Simulacrum
samueltardieu Jul 28, 2025
2af38f4
Rollup merge of #144268 - xizheyin:find-oldest-ancestor, r=jieyouxu
samueltardieu Jul 28, 2025
0746d33
Rollup merge of #144303 - Kobzol:bootstrap-tool-cleanup, r=jieyouxu
samueltardieu Jul 28, 2025
862b53b
Rollup merge of #144539 - RalfJung:const_with_exposed_provenance, r=o…
samueltardieu Jul 28, 2025
41dd434
Rollup merge of #144569 - tshepang:rdg-sync, r=Kobzol
samueltardieu Jul 28, 2025
800f948
Rollup merge of #144573 - BoxyUwU:patkind_constant_ptr_docs, r=lcnr
samueltardieu Jul 28, 2025
74a36fb
Rollup merge of #144578 - FractalFir:m68k_fix, r=compiler-errors
samueltardieu Jul 28, 2025
ca330e1
Rollup merge of #144582 - usamoi:docs, r=RalfJung
samueltardieu Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}
} else if let LocalInfo::BlockTailTemp(info) = local_decl.local_info() {
let sp = info.span.find_oldest_ancestor_in_same_ctxt();
let sp = info.span.find_ancestor_not_from_macro().unwrap_or(info.span);
if info.tail_result_is_ignored {
// #85581: If the first mutable borrow's scope contains
// the second borrow, this suggestion isn't helpful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ index 1e336bf..35e6f54 100644
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
#![cfg_attr(test, feature(cfg_select))]
#![feature(alloc_layout_extra)]
#![feature(array_chunks)]
#![feature(array_ptr_get)]
diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs
index b735957..ea728b6 100644
--- a/coretests/tests/atomic.rs
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ impl From<Ident> for LifetimeSyntax {
/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
/// — there's no way to "elide" these lifetimes.
#[derive(Debug, Copy, Clone, HashStable_Generic)]
// Raise the aligement to at least 4 bytes - this is relied on in other parts of the compiler(for pointer tagging):
// https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163
// Removing this `repr(4)` will cause the compiler to not build on platforms like `m68k` Linux, where the aligement of u32 and usize is only 2.
// Since `repr(align)` may only raise aligement, this has no effect on platforms where the aligement is already sufficient.
#[repr(align(4))]
pub struct Lifetime {
#[stable_hasher(ignore)]
pub hir_id: HirId,
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.macro_backtrace()
.any(|x| matches!(x.kind, ExpnKind::Macro(MacroKind::Attr | MacroKind::Derive, ..)))
{
let span = expr.span.find_oldest_ancestor_in_same_ctxt();
let span = expr
.span
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
.unwrap_or(expr.span);

let mut sugg = if self.precedence(expr) >= ExprPrecedence::Unambiguous {
vec![(span.shrink_to_hi(), ".into()".to_owned())]
Expand Down Expand Up @@ -2062,7 +2065,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None => sugg.to_string(),
};

let span = expr.span.find_oldest_ancestor_in_same_ctxt();
let span = expr
.span
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
.unwrap_or(expr.span);
err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders);
true
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
let mut op_warned = false;

if let Some(must_use_op) = must_use_op {
let span = expr.span.find_oldest_ancestor_in_same_ctxt();
let span = expr.span.find_ancestor_not_from_macro().unwrap_or(expr.span);
cx.emit_span_lint(
UNUSED_MUST_USE,
expr.span,
Expand Down Expand Up @@ -511,7 +511,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
);
}
MustUsePath::Def(span, def_id, reason) => {
let span = span.find_oldest_ancestor_in_same_ctxt();
let span = span.find_ancestor_not_from_macro().unwrap_or(*span);
cx.emit_span_lint(
UNUSED_MUST_USE,
span,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/thir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,8 @@ pub enum PatKind<'tcx> {
/// * integer, bool, char or float (represented as a valtree), which will be handled by
/// exhaustiveness to cover exactly its own value, similar to `&str`, but these values are
/// much simpler.
/// * raw pointers derived from integers, other raw pointers will have already resulted in an
// error.
/// * `String`, if `string_deref_patterns` is enabled.
Constant {
value: mir::Const<'tcx>,
Expand Down
82 changes: 46 additions & 36 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,17 @@ impl Span {
(!ctxt.is_root()).then(|| ctxt.outer_expn_data().call_site)
}

/// Walk down the expansion ancestors to find a span that's contained within `outer`.
/// Find the first ancestor span that's contained within `outer`.
///
/// The span returned by this method may have a different [`SyntaxContext`] as `outer`.
/// This method traverses the macro expansion ancestors until it finds the first span
/// that's contained within `outer`.
///
/// The span returned by this method may have a different [`SyntaxContext`] than `outer`.
/// If you need to extend the span, use [`find_ancestor_inside_same_ctxt`] instead,
/// because joining spans with different syntax contexts can create unexpected results.
///
/// This is used to find the span of the macro call when a parent expr span, i.e. `outer`, is known.
///
/// [`find_ancestor_inside_same_ctxt`]: Self::find_ancestor_inside_same_ctxt
pub fn find_ancestor_inside(mut self, outer: Span) -> Option<Span> {
while !outer.contains(self) {
Expand All @@ -730,8 +735,10 @@ impl Span {
Some(self)
}

/// Walk down the expansion ancestors to find a span with the same [`SyntaxContext`] as
/// `other`.
/// Find the first ancestor span with the same [`SyntaxContext`] as `other`.
///
/// This method traverses the macro expansion ancestors until it finds a span
/// that has the same [`SyntaxContext`] as `other`.
///
/// Like [`find_ancestor_inside_same_ctxt`], but specifically for when spans might not
/// overlap. Take care when using this, and prefer [`find_ancestor_inside`] or
Expand All @@ -747,9 +754,12 @@ impl Span {
Some(self)
}

/// Walk down the expansion ancestors to find a span that's contained within `outer` and
/// Find the first ancestor span that's contained within `outer` and
/// has the same [`SyntaxContext`] as `outer`.
///
/// This method traverses the macro expansion ancestors until it finds a span
/// that is both contained within `outer` and has the same [`SyntaxContext`] as `outer`.
///
/// This method is the combination of [`find_ancestor_inside`] and
/// [`find_ancestor_in_same_ctxt`] and should be preferred when extending the returned span.
/// If you do not need to modify the span, use [`find_ancestor_inside`] instead.
Expand All @@ -763,43 +773,43 @@ impl Span {
Some(self)
}

/// Recursively walk down the expansion ancestors to find the oldest ancestor span with the same
/// [`SyntaxContext`] the initial span.
/// Find the first ancestor span that does not come from an external macro.
///
/// This method is suitable for peeling through *local* macro expansions to find the "innermost"
/// span that is still local and shares the same [`SyntaxContext`]. For example, given
/// This method traverses the macro expansion ancestors until it finds a span
/// that is either from user-written code or from a local macro (defined in the current crate).
///
/// ```ignore (illustrative example, contains type error)
/// macro_rules! outer {
/// ($x: expr) => {
/// inner!($x)
/// }
/// }
/// External macros are those defined in dependencies or the standard library.
/// This method is useful for reporting errors in user-controllable code and avoiding
/// diagnostics inside external macros.
///
/// macro_rules! inner {
/// ($x: expr) => {
/// format!("error: {}", $x)
/// //~^ ERROR mismatched types
/// }
/// }
/// # See also
///
/// fn bar(x: &str) -> Result<(), Box<dyn std::error::Error>> {
/// Err(outer!(x))
/// }
/// ```
/// - [`Self::find_ancestor_not_from_macro`]
/// - [`Self::in_external_macro`]
pub fn find_ancestor_not_from_extern_macro(mut self, sm: &SourceMap) -> Option<Span> {
while self.in_external_macro(sm) {
self = self.parent_callsite()?;
}
Some(self)
}

/// Find the first ancestor span that does not come from any macro expansion.
///
/// if provided the initial span of `outer!(x)` inside `bar`, this method will recurse
/// the parent callsites until we reach `format!("error: {}", $x)`, at which point it is the
/// oldest ancestor span that is both still local and shares the same [`SyntaxContext`] as the
/// initial span.
pub fn find_oldest_ancestor_in_same_ctxt(self) -> Span {
let mut cur = self;
while cur.eq_ctxt(self)
&& let Some(parent_callsite) = cur.parent_callsite()
{
cur = parent_callsite;
/// This method traverses the macro expansion ancestors until it finds a span
/// that originates from user-written code rather than any macro-generated code.
///
/// This method is useful for reporting errors at the exact location users wrote code
/// and providing suggestions at directly editable locations.
///
/// # See also
///
/// - [`Self::find_ancestor_not_from_extern_macro`]
/// - [`Span::from_expansion`]
pub fn find_ancestor_not_from_macro(mut self) -> Option<Span> {
while self.from_expansion() {
self = self.parent_callsite()?;
}
cur
Some(self)
}

/// Edition of the crate from which this span came.
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
// tidy-alphabetical-start
#![feature(alloc_layout_extra)]
#![feature(allocator_api)]
#![feature(array_chunks)]
#![feature(array_into_iter_constructors)]
#![feature(array_windows)]
#![feature(ascii_char)]
Expand Down
4 changes: 0 additions & 4 deletions library/alloc/src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ use core::cmp::Ordering::{self, Less};
use core::mem::MaybeUninit;
#[cfg(not(no_global_oom_handling))]
use core::ptr;
#[unstable(feature = "array_chunks", issue = "74985")]
pub use core::slice::ArrayChunks;
#[unstable(feature = "array_chunks", issue = "74985")]
pub use core::slice::ArrayChunksMut;
#[unstable(feature = "array_windows", issue = "75027")]
pub use core::slice::ArrayWindows;
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
Expand Down
24 changes: 12 additions & 12 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,12 @@ impl String {
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "str_from_utf16_endian", issue = "116258")]
pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error> {
if v.len() % 2 != 0 {
let (chunks, []) = v.as_chunks::<2>() else {
return Err(FromUtf16Error(()));
}
};
match (cfg!(target_endian = "little"), unsafe { v.align_to::<u16>() }) {
(true, ([], v, [])) => Self::from_utf16(v),
_ => char::decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes))
_ => char::decode_utf16(chunks.iter().copied().map(u16::from_le_bytes))
.collect::<Result<_, _>>()
.map_err(|_| FromUtf16Error(())),
}
Expand Down Expand Up @@ -830,11 +830,11 @@ impl String {
(true, ([], v, [])) => Self::from_utf16_lossy(v),
(true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}",
_ => {
let mut iter = v.array_chunks::<2>();
let string = char::decode_utf16(iter.by_ref().copied().map(u16::from_le_bytes))
let (chunks, remainder) = v.as_chunks::<2>();
let string = char::decode_utf16(chunks.iter().copied().map(u16::from_le_bytes))
.map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
.collect();
if iter.remainder().is_empty() { string } else { string + "\u{FFFD}" }
if remainder.is_empty() { string } else { string + "\u{FFFD}" }
}
}
}
Expand Down Expand Up @@ -862,12 +862,12 @@ impl String {
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "str_from_utf16_endian", issue = "116258")]
pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error> {
if v.len() % 2 != 0 {
let (chunks, []) = v.as_chunks::<2>() else {
return Err(FromUtf16Error(()));
}
};
match (cfg!(target_endian = "big"), unsafe { v.align_to::<u16>() }) {
(true, ([], v, [])) => Self::from_utf16(v),
_ => char::decode_utf16(v.array_chunks::<2>().copied().map(u16::from_be_bytes))
_ => char::decode_utf16(chunks.iter().copied().map(u16::from_be_bytes))
.collect::<Result<_, _>>()
.map_err(|_| FromUtf16Error(())),
}
Expand Down Expand Up @@ -905,11 +905,11 @@ impl String {
(true, ([], v, [])) => Self::from_utf16_lossy(v),
(true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}",
_ => {
let mut iter = v.array_chunks::<2>();
let string = char::decode_utf16(iter.by_ref().copied().map(u16::from_be_bytes))
let (chunks, remainder) = v.as_chunks::<2>();
let string = char::decode_utf16(chunks.iter().copied().map(u16::from_be_bytes))
.map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
.collect();
if iter.remainder().is_empty() { string } else { string + "\u{FFFD}" }
if remainder.is_empty() { string } else { string + "\u{FFFD}" }
}
}
}
Expand Down
Loading