Skip to content

Rollup of 7 pull requests #145223

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

Merged
merged 14 commits into from
Aug 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3546,7 +3546,7 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu

for (f, s) in iter::zip(found.chars(), suggested.chars()) {
if f != s {
if f.to_lowercase().to_string() == s.to_lowercase().to_string() {
if f.eq_ignore_ascii_case(&s) {
// Check for case differences (any character that differs only in case)
if ascii_confusables.contains(&f) || ascii_confusables.contains(&s) {
has_case_diff = true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ fn expand_macro_attr(

if cx.trace_macros() {
let msg = format!(
"expanding `$[{name}({})] {}`",
"expanding `#[{name}({})] {}`",
pprust::tts_to_string(&args),
pprust::tts_to_string(&body),
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ fn main() {
println!("cargo:rustc-link-lib=kstat");
}

if (target.starts_with("arm") && !target.contains("freebsd")) && !target.contains("ohos")
if (target.starts_with("arm") && !target.contains("freebsd") && !target.contains("ohos"))
|| target.starts_with("mips-")
|| target.starts_with("mipsel-")
|| target.starts_with("powerpc-")
Expand Down
15 changes: 10 additions & 5 deletions library/std/src/sys/fs/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub struct OpenOptions {
attributes: u32,
share_mode: u32,
security_qos_flags: u32,
security_attributes: *mut c::SECURITY_ATTRIBUTES,
inherit_handle: bool,
}

#[derive(Clone, PartialEq, Eq, Debug)]
Expand Down Expand Up @@ -203,7 +203,7 @@ impl OpenOptions {
share_mode: c::FILE_SHARE_READ | c::FILE_SHARE_WRITE | c::FILE_SHARE_DELETE,
attributes: 0,
security_qos_flags: 0,
security_attributes: ptr::null_mut(),
inherit_handle: false,
}
}

Expand Down Expand Up @@ -243,8 +243,8 @@ impl OpenOptions {
// receive is `SECURITY_ANONYMOUS = 0x0`, which we can't check for later on.
self.security_qos_flags = flags | c::SECURITY_SQOS_PRESENT;
}
pub fn security_attributes(&mut self, attrs: *mut c::SECURITY_ATTRIBUTES) {
self.security_attributes = attrs;
pub fn inherit_handle(&mut self, inherit: bool) {
self.inherit_handle = inherit;
}

fn get_access_mode(&self) -> io::Result<u32> {
Expand Down Expand Up @@ -307,12 +307,17 @@ impl File {

fn open_native(path: &WCStr, opts: &OpenOptions) -> io::Result<File> {
let creation = opts.get_creation_mode()?;
let sa = c::SECURITY_ATTRIBUTES {
nLength: size_of::<c::SECURITY_ATTRIBUTES>() as u32,
lpSecurityDescriptor: ptr::null_mut(),
bInheritHandle: opts.inherit_handle as c::BOOL,
};
let handle = unsafe {
c::CreateFileW(
path.as_ptr(),
opts.get_access_mode()?,
opts.share_mode,
opts.security_attributes,
if opts.inherit_handle { &sa } else { ptr::null() },
creation,
opts.get_flags_and_attributes(),
ptr::null_mut(),
Expand Down
8 changes: 1 addition & 7 deletions library/std/src/sys/process/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,10 @@ impl Stdio {
// permissions as well as the ability to be inherited to child
// processes (as this is about to be inherited).
Stdio::Null => {
let size = size_of::<c::SECURITY_ATTRIBUTES>();
let mut sa = c::SECURITY_ATTRIBUTES {
nLength: size as u32,
lpSecurityDescriptor: ptr::null_mut(),
bInheritHandle: 1,
};
let mut opts = OpenOptions::new();
opts.read(stdio_id == c::STD_INPUT_HANDLE);
opts.write(stdio_id != c::STD_INPUT_HANDLE);
opts.security_attributes(&mut sa);
opts.inherit_handle(true);
File::open(Path::new(r"\\.\NUL"), &opts).map(|file| file.into_inner())
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ fn copy_src_dirs(
"llvm-project\\cmake",
"llvm-project/runtimes",
"llvm-project\\runtimes",
"llvm-project/third-party",
"llvm-project\\third-party",
];
if spath.contains("llvm-project")
&& !spath.ends_with("llvm-project")
Expand All @@ -933,6 +935,18 @@ fn copy_src_dirs(
return false;
}

// Keep only these third party libraries
const LLVM_THIRD_PARTY: &[&str] =
&["llvm-project/third-party/siphash", "llvm-project\\third-party\\siphash"];
if (spath.starts_with("llvm-project/third-party")
|| spath.starts_with("llvm-project\\third-party"))
&& !(spath.ends_with("llvm-project/third-party")
|| spath.ends_with("llvm-project\\third-party"))
&& !LLVM_THIRD_PARTY.iter().any(|path| spath.contains(path))
{
return false;
}

const LLVM_TEST: &[&str] = &["llvm-project/llvm/test", "llvm-project\\llvm\\test"];
if LLVM_TEST.iter().any(|path| spath.contains(path))
&& (spath.ends_with(".ll") || spath.ends_with(".td") || spath.ends_with(".s"))
Expand Down
19 changes: 19 additions & 0 deletions tests/codegen-llvm/issues/saturating-sub-index-139759.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test that calculating an index with saturating subtraction from an in-bounds
// index doesn't generate another bounds check.

//@ compile-flags: -Copt-level=3
//@ min-llvm-version: 21

#![crate_type = "lib"]

// CHECK-LABEL: @bounds_check_is_elided
#[no_mangle]
pub fn bounds_check_is_elided(s: &[i32], index: usize) -> i32 {
// CHECK-NOT: panic_bounds_check
if index < s.len() {
let lower_bound = index.saturating_sub(1);
s[lower_bound]
} else {
-1
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/23442
//@ check-pass
#![allow(dead_code)]
use std::marker::PhantomData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/91489
//@ check-pass

// regression test for #91489
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9725
struct A { foo: isize }

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0416]: identifier `foo` is bound more than once in the same pattern
--> $DIR/issue-9725.rs:4:18
--> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18
|
LL | let A { foo, foo } = A { foo: 3 };
| ^^^ used in a pattern more than once

error[E0025]: field `foo` bound multiple times in the pattern
--> $DIR/issue-9725.rs:4:18
--> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18
|
LL | let A { foo, foo } = A { foo: 3 };
| --- ^^^ multiple uses of `foo` in pattern
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9942
//@ run-pass

pub fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9129
//@ run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9951
//@ run-pass

#![allow(unused_variables)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: method `noop` is never used
--> $DIR/issue-9951.rs:6:6
--> $DIR/trait-object-coercion-distribution-9951.rs:7:6
|
LL | trait Bar {
| --- method in this trait
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/98299
use std::convert::TryFrom;

pub fn test_usage(p: ()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0284]: type annotations needed for `SmallCString<_>`
--> $DIR/issue-98299.rs:4:36
--> $DIR/try-from-with-const-genericsrs-98299.rs:5:36
|
LL | SmallCString::try_from(p).map(|cstr| cstr);
| ------------ ^^^^
| |
| type must be known at this point
|
note: required by a const generic parameter in `SmallCString`
--> $DIR/issue-98299.rs:10:25
--> $DIR/try-from-with-const-genericsrs-98299.rs:11:25
|
LL | pub struct SmallCString<const N: usize> {}
| ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString`
Expand All @@ -17,15 +17,15 @@ LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
| +++++++++++++++++

error[E0284]: type annotations needed for `SmallCString<_>`
--> $DIR/issue-98299.rs:4:36
--> $DIR/try-from-with-const-genericsrs-98299.rs:5:36
|
LL | SmallCString::try_from(p).map(|cstr| cstr);
| ------------ ^^^^
| |
| type must be known at this point
|
note: required for `SmallCString<_>` to implement `TryFrom<()>`
--> $DIR/issue-98299.rs:12:22
--> $DIR/try-from-with-const-genericsrs-98299.rs:13:22
|
LL | impl<const N: usize> TryFrom<()> for SmallCString<N> {
| -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Expand All @@ -37,15 +37,15 @@ LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
| +++++++++++++++++

error[E0284]: type annotations needed for `SmallCString<_>`
--> $DIR/issue-98299.rs:4:36
--> $DIR/try-from-with-const-genericsrs-98299.rs:5:36
|
LL | SmallCString::try_from(p).map(|cstr| cstr);
| ------------------------- ^^^^
| |
| type must be known at this point
|
note: required for `SmallCString<_>` to implement `TryFrom<()>`
--> $DIR/issue-98299.rs:12:22
--> $DIR/try-from-with-const-genericsrs-98299.rs:13:22
|
LL | impl<const N: usize> TryFrom<()> for SmallCString<N> {
| -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// https://github.com/rust-lang/rust/issues/9155
//@ run-pass
//@ aux-build:aux-9155.rs

extern crate aux_9155;

struct Baz;

pub fn main() {
aux_9155::Foo::new(Baz);
}
10 changes: 10 additions & 0 deletions tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// https://github.com/rust-lang/rust/issues/9906
//@ run-pass
//@ aux-build:aux-9906.rs

extern crate aux_9906 as testmod;

pub fn main() {
testmod::foo();
testmod::FooBar::new(1);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/22992
//@ run-pass

struct X { val: i32 }
Expand All @@ -6,7 +7,6 @@ impl std::ops::Deref for X {
fn deref(&self) -> &i32 { &self.val }
}


trait M { fn m(self); }
impl M for i32 { fn m(self) { println!("i32::m()"); } }
impl M for X { fn m(self) { println!("X::m()"); } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/25549
//@ run-pass
#![allow(unused_variables)]
struct Foo<'r>(&'r mut i32);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9243
//@ build-pass
#![allow(dead_code)]
// Regression test for issue 9243
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/53333
//@ run-pass
#![allow(unused_imports)]
//@ edition:2018
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9837
//@ run-pass
const C1: i32 = 0x12345678;
const C2: isize = C1 as i16 as isize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9814
// Verify that single-variant enums can't be de-referenced
// Regression test for issue #9814

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0614]: type `Foo` cannot be dereferenced
--> $DIR/issue-9814.rs:7:13
--> $DIR/single-variant-enum-deref-error-9814.rs:8:13
|
LL | let _ = *Foo::Bar(2);
| ^^^^^^^^^^^^ can't be dereferenced
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/3037
//@ run-pass
#![allow(dead_code)]
#![allow(non_camel_case_types)]
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/imports/pub-use-link-errors-9968.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://github.com/rust-lang/rust/issues/9968
//@ run-pass
//@ aux-build:aux-9968.rs

extern crate aux_9968 as lib;

use lib::{Trait, Struct};

pub fn main()
{
Struct::init().test();
}
11 changes: 0 additions & 11 deletions tests/ui/issues/issue-9155.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/issues/issue-9906.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/issues/issue-9968.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/21655
//@ run-pass

fn test(it: &mut dyn Iterator<Item=i32>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9259
//@ run-pass
#![allow(dead_code)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/29710
//@ check-pass
#![deny(unused_results)]
#![allow(dead_code)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9047
//@ run-pass
#![allow(unused_mut)]
#![allow(unused_variables)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/9110
//@ check-pass
#![allow(dead_code)]
#![allow(non_snake_case)]
Expand Down
Loading
Loading