Skip to content

Rollup of 10 pull requests #144437

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 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b315e9a
clippy fix: rely on autoderef
hkBst Jul 4, 2025
05154af
docs: update documentation of core::mem::copy to include const on the…
SunkenPotato Jul 15, 2025
a9fd8d0
bootstrap: Move musl-root fallback out of sanity check
Gelbpunkt Jul 22, 2025
3d186ea
Fix tests/assembly-llvm/dwarf-mixed-versions-lto.rs test failure on r…
Jul 23, 2025
2e49c52
Fix tests/codegen-llvm/const-vector.rs test failure on riscv64
Jul 23, 2025
23fda60
RustWrapper: Suppress getNextNonDebugInfoInstruction
heiher Jul 23, 2025
e7441fb
Clippy fixup
Gelbpunkt Jul 23, 2025
78fc7c3
Suggest unwrapping when private method name is available in inner type
estebank Jul 23, 2025
60d6980
Inline some methods in rustc_span hygiene
xizheyin Jul 23, 2025
94c0cf8
Rename tests/ui/SUMMARY.md and update rustc dev guide on error-pattern
Oneirical Jul 23, 2025
97676e6
Allow setting `release-blog-post` label with rustbot
BoxyUwU Jul 24, 2025
6020170
Rollup merge of #143424 - hkBst:auto-deref, r=jhpratt
Kobzol Jul 25, 2025
334b2e7
Rollup merge of #143970 - SunkenPotato:update_mem_copy_docs, r=scottmcm
Kobzol Jul 25, 2025
2514055
Rollup merge of #144316 - Gelbpunkt:musl-libdir-bootstrap, r=Kobzol
Kobzol Jul 25, 2025
bc9f44b
Rollup merge of #144339 - CaiWeiran:dwarf-mixed-versions-lto_test, r=…
Kobzol Jul 25, 2025
a3741f7
Rollup merge of #144340 - Oneirical:uncertain-illusion, r=jieyouxu
Kobzol Jul 25, 2025
38066ad
Rollup merge of #144341 - CaiWeiran:const-vector_test, r=wesleywiser
Kobzol Jul 25, 2025
77fffaa
Rollup merge of #144352 - heiher:llvm-22, r=dianqk
Kobzol Jul 25, 2025
eb3222d
Rollup merge of #144376 - estebank:issue-143795, r=lcnr
Kobzol Jul 25, 2025
582aa96
Rollup merge of #144385 - xizheyin:macro-hygiene, r=petrochenkov
Kobzol Jul 25, 2025
1a8dff4
Rollup merge of #144424 - BoxyUwU:release_blog_post_unauthorized_user…
Kobzol Jul 25, 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
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(within_macro_span, "due to this macro variable");
}
self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true);
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name);
err.emit()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ extern "C" void LLVMRustPositionBefore(LLVMBuilderRef B, LLVMValueRef Instr) {

extern "C" void LLVMRustPositionAfter(LLVMBuilderRef B, LLVMValueRef Instr) {
if (auto I = dyn_cast<Instruction>(unwrap<Value>(Instr))) {
auto J = I->getNextNonDebugInstruction();
auto J = I->getNextNode();
unwrap(B)->SetInsertPoint(J);
}
}
Expand Down
16 changes: 16 additions & 0 deletions compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ impl ExpnId {

/// `expn_id.outer_expn_is_descendant_of(ctxt)` is equivalent to but faster than
/// `expn_id.is_descendant_of(ctxt.outer_expn())`.
#[inline]
pub fn outer_expn_is_descendant_of(self, ctxt: SyntaxContext) -> bool {
HygieneData::with(|data| data.is_descendant_of(self, data.outer_expn(ctxt)))
}
Expand Down Expand Up @@ -394,6 +395,7 @@ impl HygieneData {
}
}

#[inline]
fn with<R>(f: impl FnOnce(&mut HygieneData) -> R) -> R {
with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut()))
}
Expand All @@ -406,6 +408,7 @@ impl HygieneData {
}
}

#[inline]
fn local_expn_data(&self, expn_id: LocalExpnId) -> &ExpnData {
self.local_expn_data[expn_id].as_ref().expect("no expansion data for an expansion ID")
}
Expand Down Expand Up @@ -437,23 +440,28 @@ impl HygieneData {
}
}

#[inline]
fn normalize_to_macros_2_0(&self, ctxt: SyntaxContext) -> SyntaxContext {
self.syntax_context_data[ctxt.0 as usize].opaque
}

#[inline]
fn normalize_to_macro_rules(&self, ctxt: SyntaxContext) -> SyntaxContext {
self.syntax_context_data[ctxt.0 as usize].opaque_and_semiopaque
}

#[inline]
fn outer_expn(&self, ctxt: SyntaxContext) -> ExpnId {
self.syntax_context_data[ctxt.0 as usize].outer_expn
}

#[inline]
fn outer_mark(&self, ctxt: SyntaxContext) -> (ExpnId, Transparency) {
let data = &self.syntax_context_data[ctxt.0 as usize];
(data.outer_expn, data.outer_transparency)
}

#[inline]
fn parent_ctxt(&self, ctxt: SyntaxContext) -> SyntaxContext {
self.syntax_context_data[ctxt.0 as usize].parent
}
Expand Down Expand Up @@ -718,11 +726,13 @@ impl SyntaxContext {
SyntaxContext(raw as u32)
}

#[inline]
fn from_usize(raw: usize) -> SyntaxContext {
SyntaxContext(u32::try_from(raw).unwrap())
}

/// Extend a syntax context with a given expansion and transparency.
#[inline]
pub fn apply_mark(self, expn_id: ExpnId, transparency: Transparency) -> SyntaxContext {
HygieneData::with(|data| data.apply_mark(self, expn_id, transparency))
}
Expand All @@ -743,10 +753,12 @@ impl SyntaxContext {
/// of g (call it g1), calling remove_mark will result in the SyntaxContext for the
/// invocation of f that created g1.
/// Returns the mark that was removed.
#[inline]
pub fn remove_mark(&mut self) -> ExpnId {
HygieneData::with(|data| data.remove_mark(self).0)
}

#[inline]
pub fn marks(self) -> Vec<(ExpnId, Transparency)> {
HygieneData::with(|data| data.marks(self))
}
Expand Down Expand Up @@ -776,11 +788,13 @@ impl SyntaxContext {
/// ```
/// This returns the expansion whose definition scope we use to privacy check the resolution,
/// or `None` if we privacy check as usual (i.e., not w.r.t. a macro definition scope).
#[inline]
pub fn adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
HygieneData::with(|data| data.adjust(self, expn_id))
}

/// Like `SyntaxContext::adjust`, but also normalizes `self` to macros 2.0.
#[inline]
pub(crate) fn normalize_to_macros_2_0_and_adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
HygieneData::with(|data| {
*self = data.normalize_to_macros_2_0(*self);
Expand Down Expand Up @@ -901,10 +915,12 @@ impl SyntaxContext {
HygieneData::with(|data| data.outer_mark(self))
}

#[inline]
pub(crate) fn dollar_crate_name(self) -> Symbol {
HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name)
}

#[inline]
pub fn edition(self) -> Edition {
HygieneData::with(|data| data.expn_data(data.outer_expn(self)).edition)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ where
}
}

#[inline]
pub fn with_session_globals<R, F>(f: F) -> R
where
F: FnOnce(&SessionGlobals) -> R,
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,20 @@ impl<T: ?Sized> BorrowMut<T> for T {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Borrow<T> for &T {
fn borrow(&self) -> &T {
&**self
self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Borrow<T> for &mut T {
fn borrow(&self) -> &T {
&**self
self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> BorrowMut<T> for &mut T {
fn borrow_mut(&mut self) -> &mut T {
&mut **self
self
}
}
2 changes: 1 addition & 1 deletion library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ mod impls {
#[inline(always)]
#[rustc_diagnostic_item = "noop_method_clone"]
fn clone(&self) -> Self {
*self
self
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ pub fn drop<T>(_x: T) {}
///
/// This function is not magic; it is literally defined as
/// ```
/// pub fn copy<T: Copy>(x: &T) -> T { *x }
/// pub const fn copy<T: Copy>(x: &T) -> T { *x }
/// ```
///
/// It is useful when you want to pass a function pointer to a combinator, rather than defining a new closure.
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<T: ?Sized> const Deref for &T {

#[rustc_diagnostic_item = "noop_method_deref"]
fn deref(&self) -> &T {
*self
self
}
}

Expand All @@ -171,7 +171,7 @@ impl<T: ?Sized> const Deref for &mut T {
type Target = T;

fn deref(&self) -> &T {
*self
self
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ pub trait DerefMut: ~const Deref + PointeeSized {
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
impl<T: ?Sized> const DerefMut for &mut T {
fn deref_mut(&mut self) -> &mut T {
*self
self
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ than building it.

// Make sure musl-root is valid.
if target.contains("musl") && !target.contains("unikraft") {
// If this is a native target (host is also musl) and no musl-root is given,
// fall back to the system toolchain in /usr before giving up
if build.musl_root(*target).is_none() && build.config.is_host_target(*target) {
let target = build.config.target_config.entry(*target).or_default();
target.musl_root = Some("/usr".into());
}
match build.musl_libdir(*target) {
Some(libdir) => {
if fs::metadata(libdir.join("libc.a")).is_err() {
Expand Down
26 changes: 18 additions & 8 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,23 +1329,33 @@ impl Build {
}
}

/// Returns the "musl root" for this `target`, if defined
/// Returns the "musl root" for this `target`, if defined.
///
/// If this is a native target (host is also musl) and no musl-root is given,
/// it falls back to the system toolchain in /usr.
fn musl_root(&self, target: TargetSelection) -> Option<&Path> {
self.config
let configured_root = self
.config
.target_config
.get(&target)
.and_then(|t| t.musl_root.as_ref())
.or(self.config.musl_root.as_ref())
.map(|p| &**p)
.map(|p| &**p);

if self.config.is_host_target(target) && configured_root.is_none() {
Some(Path::new("/usr"))
} else {
configured_root
}
}

/// Returns the "musl libdir" for this `target`.
fn musl_libdir(&self, target: TargetSelection) -> Option<PathBuf> {
let t = self.config.target_config.get(&target)?;
if let libdir @ Some(_) = &t.musl_libdir {
return libdir.clone();
}
self.musl_root(target).map(|root| root.join("lib"))
self.config
.target_config
.get(&target)
.and_then(|t| t.musl_libdir.clone())
.or_else(|| self.musl_root(target).map(|root| root.join("lib")))
}

/// Returns the `lib` directory for the WASI target specified, if
Expand Down
8 changes: 4 additions & 4 deletions src/doc/rustc-dev-guide/src/tests/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ fn main((ؼ

Use `//~?` to match an error without line information.
`//~?` is precise and will not match errors if their line information is available.
It should be preferred to using `error-pattern`, which is imprecise and non-exhaustive.
For tests wishing to match against compiler diagnostics, error annotations should
be preferred over //@ error-pattern, //@ error-pattern is imprecise and non-exhaustive.

```rust,ignore
//@ compile-flags: --print yyyy
Expand Down Expand Up @@ -347,8 +348,6 @@ fn main() {
}
```

Use of `error-pattern` is not recommended in general.

For strict testing of compile time output, try to use the line annotations `//~` as much as
possible, including `//~?` annotations for diagnostics without spans.

Expand All @@ -359,7 +358,8 @@ Some of the compiler messages can stay uncovered by annotations in this mode.

For checking runtime output, `//@ check-run-results` may be preferable.

Only use `error-pattern` if none of the above works.
Only use `error-pattern` if none of the above works, such as when finding a
specific string pattern in a runtime panic output.

Line annotations `//~` and `error-pattern` are compatible and can be used in the same test.

Expand Down
7 changes: 4 additions & 3 deletions tests/assembly-llvm/dwarf-mixed-versions-lto.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This test ensures that if LTO occurs between crates with different DWARF versions, we
// will choose the highest DWARF version for the final binary. This matches Clang's behavior.
// Note: `.2byte` directive is used on MIPS.
// Note: `.half` directive is used on RISC-V.

//@ only-linux
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
Expand All @@ -15,6 +16,6 @@ fn main() {
}

// CHECK: .section .debug_info
// CHECK-NOT: {{\.(short|hword|2byte)}} 2
// CHECK-NOT: {{\.(short|hword|2byte)}} 4
// CHECK: {{\.(short|hword|2byte)}} 5
// CHECK-NOT: {{\.(short|hword|2byte|half)}} 2
// CHECK-NOT: {{\.(short|hword|2byte|half)}} 4
// CHECK: {{\.(short|hword|2byte|half)}} 5
2 changes: 2 additions & 0 deletions tests/codegen-llvm/const-vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![feature(arm_target_feature)]
#![feature(mips_target_feature)]
#![allow(non_camel_case_types)]
#![feature(riscv_target_feature)]

#[path = "../auxiliary/minisimd.rs"]
mod minisimd;
Expand Down Expand Up @@ -42,6 +43,7 @@ extern "unadjusted" {
#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))]
#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))]
#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))]
#[cfg_attr(target_arch = "riscv64", target_feature(enable = "v"))]
pub fn do_call() {
unsafe {
// CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64>
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/ui/suggestions/enum-method-probe.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ fn test_option_in_unit_return() {
//~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
}

fn test_option_private_method() {
let res: Option<_> = Some(vec![1, 2, 3]);
res.expect("REASON").len();
//~^ ERROR method `len` is private
//~| HELP consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`
}

fn main() {}
7 changes: 7 additions & 0 deletions tests/ui/suggestions/enum-method-probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ fn test_option_in_unit_return() {
//~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
}

fn test_option_private_method() {
let res: Option<_> = Some(vec![1, 2, 3]);
res.len();
//~^ ERROR method `len` is private
//~| HELP consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`
}

fn main() {}
21 changes: 19 additions & 2 deletions tests/ui/suggestions/enum-method-probe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ help: consider using `Option::expect` to unwrap the `Foo` value, panicking if th
LL | res.expect("REASON").get();
| +++++++++++++++++

error: aborting due to 6 previous errors
error[E0624]: method `len` is private
--> $DIR/enum-method-probe.rs:61:9
|
LL | res.len();
| ^^^ private method
--> $SRC_DIR/core/src/option.rs:LL:COL
|
= note: private method defined here
|
note: the method `len` exists on the type `Vec<{integer}>`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`
|
LL | res.expect("REASON").len();
| +++++++++++++++++

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0599`.
Some errors have detailed explanations: E0599, E0624.
For more information about an error, try `rustc --explain E0599`.
1 change: 1 addition & 0 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ allow-unauthenticated = [
"llvm-*",
"needs-fcp",
"relnotes",
"release-blog-post",
"requires-*",
"regression-*",
"rla-*",
Expand Down