Skip to content

Rollup of 7 pull requests #143762

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 39 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2953787
DRAFT: Add an aarch64-msvc build running on ARM64 Windows
dpaoliello Apr 28, 2025
e101e38
std_detect: Tidying of slice length
a4lg Jun 29, 2025
bb2d169
use `is_multiple_of` to check if an addr is aligned
folkertdev Jul 5, 2025
e8d9e80
Add empty rust-version file
Kobzol Jun 26, 2025
f697f81
Add josh synchronization scripts
Kobzol Jun 26, 2025
8ae4e6a
Update stabilization version of certain x86 intrinsics to 1.89
Amanieu Jun 30, 2025
e46d220
Use simd_extract! macro instead of calling simd_extract directly
clarfonthey Jun 30, 2025
600497f
Mark `avx` broadcast intrinsics as safe
okaneco Jun 23, 2025
b535003
Remove std-detect dev dependency in core_arch
Kobzol Jul 4, 2025
816f029
Update README.md
kilavvy Jun 29, 2025
8600192
Add config files for `rustc-josh-sync`
Kobzol Jul 4, 2025
ce73251
Prepare for merging from rust-lang/rust
Kobzol Jul 4, 2025
1bc289d
std_detect: RISC-V Linux: Ergonomic querying with `riscv_hwprobe`
a4lg Jun 29, 2025
fddd05b
some clippy fixes
hkBst Jul 6, 2025
658b5c8
Use `simd_funnel_sh{l,r}` and `simd_round_ties_even` to remove uses o…
sayantn Jul 7, 2025
a95bd00
Remove custom josh-sync scripts
Kobzol Jul 8, 2025
07d5fbb
Update README with link to `josh-sync`
Kobzol Jul 8, 2025
82126a6
fix whitespace in `aarch64.spec.yml`
folkertdev Jul 8, 2025
323c646
remote intermediate assignment
folkertdev Jul 8, 2025
92701fe
shorten array literals
folkertdev Jul 8, 2025
061a941
remove unneeded cast
folkertdev Jul 8, 2025
701d222
Reset rust-version
Kobzol Jul 8, 2025
3c9297c
Prepare for merging from rust-lang/rust
Kobzol Jul 8, 2025
bdead41
Merge ref '040e2f8b9ff2' from rust-lang/rust
Kobzol Jul 8, 2025
a310bdd
Merge pull request #1853 from Kobzol/pull-fixed
Amanieu Jul 8, 2025
3e675f4
Fix `--skip-std-check-if-no-download-rustc`
Kobzol Jul 9, 2025
84eeca2
Make some "safe" llvm ops actually sound
oli-obk Jul 10, 2025
7632c55
extract single_import_can_define_name and finalize_glob_module_binding
b-naber Jul 10, 2025
7dfc3e9
Rework borrowing suggestions to use `Expr` instead of just `Span`
estebank Jul 10, 2025
0674eca
Make `Diag::multipart_suggestions` always verbose
estebank Jul 10, 2025
d692444
Update test
estebank Jul 10, 2025
341f12d
Properly track the depth when expanding free alias types
fmease Jul 10, 2025
6debe03
Rollup merge of #140136 - dpaoliello:arm64winci, r=Kobzol
tgross35 Jul 11, 2025
a5aff96
Rollup merge of #143642 - Kobzol:stdarch-push, r=Amanieu
tgross35 Jul 11, 2025
d1a5767
Rollup merge of #143707 - Kobzol:bootstrap-std-check, r=jieyouxu
tgross35 Jul 11, 2025
6e3d017
Rollup merge of #143722 - oli-obk:sound-llvm, r=dianqk
tgross35 Jul 11, 2025
44f40e9
Rollup merge of #143728 - LorrensP-2158466:refactor-resolve-extractio…
tgross35 Jul 11, 2025
58e5c26
Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errors
tgross35 Jul 11, 2025
3a1bb04
Rollup merge of #143744 - fmease:lta-expand-proper-depth, r=compiler-…
tgross35 Jul 11, 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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ jobs:
- name: show the current environment
run: src/ci/scripts/dump-environment.sh

- name: install rust
run: src/ci/scripts/install-rust.sh

- name: install awscli
run: src/ci/scripts/install-awscli.sh

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ fn create_msvc_imps(
.filter_map(|val| {
// Exclude some symbols that we know are not Rust symbols.
let name = llvm::get_value_name(val);
if ignored(name) { None } else { Some((val, name)) }
if ignored(&name) { None } else { Some((val, name)) }
})
.map(move |(val, name)| {
let mut imp_name = prefix.as_bytes().to_vec();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/builder/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn generate_enzyme_call<'ll>(
// add outer_fn name to ad_name to make it unique, in case users apply autodiff to multiple
// functions. Unwrap will only panic, if LLVM gave us an invalid string.
let name = llvm::get_value_name(outer_fn);
let outer_fn_name = std::str::from_utf8(name).unwrap();
let outer_fn_name = std::str::from_utf8(&name).unwrap();
ad_name.push_str(outer_fn_name);

// Let us assume the user wrote the following function square:
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl<'ll> CodegenCx<'ll, '_> {
// specific rules on what can be cast. So instead of adding a new way to
// generate static initializers that match the static's type, we picked
// the easier option and retroactively change the type of the static item itself.
let name = llvm::get_value_name(g).to_vec();
let name = llvm::get_value_name(g);
llvm::set_value_name(g, b"");

let linkage = llvm::get_linkage(g);
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_codegen_llvm/src/llvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub(crate) fn SetFunctionCallConv(fn_: &Value, cc: CallConv) {
// function.
// For more details on COMDAT sections see e.g., https://www.airs.com/blog/archives/52
pub(crate) fn SetUniqueComdat(llmod: &Module, val: &Value) {
let name_buf = get_value_name(val).to_vec();
let name_buf = get_value_name(val);
let name =
CString::from_vec_with_nul(name_buf).or_else(|buf| CString::new(buf.into_bytes())).unwrap();
set_comdat(llmod, val, &name);
Expand Down Expand Up @@ -319,12 +319,14 @@ pub(crate) fn get_param(llfn: &Value, index: c_uint) -> &Value {
}
}

/// Safe wrapper for `LLVMGetValueName2` into a byte slice
pub(crate) fn get_value_name(value: &Value) -> &[u8] {
/// Safe wrapper for `LLVMGetValueName2`
/// Needs to allocate the value, because `set_value_name` will invalidate
/// the pointer.
pub(crate) fn get_value_name(value: &Value) -> Vec<u8> {
unsafe {
let mut len = 0;
let data = LLVMGetValueName2(value, &mut len);
std::slice::from_raw_parts(data.cast(), len)
std::slice::from_raw_parts(data.cast(), len).to_vec()
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self.push_suggestion(CodeSuggestion {
substitutions,
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
style: SuggestionStyle::ShowCode,
style: SuggestionStyle::ShowAlways,
applicability,
});
self
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,11 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for FreeAliasTypeExpander<'tcx> {
}

self.depth += 1;
ensure_sufficient_stack(|| {
let ty = ensure_sufficient_stack(|| {
self.tcx.type_of(alias.def_id).instantiate(self.tcx, alias.args).fold_with(self)
})
});
self.depth -= 1;
ty
}

fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
Expand Down
261 changes: 143 additions & 118 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_span::{Ident, Span, kw, sym};
use tracing::{debug, instrument};

use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
use crate::imports::Import;
use crate::imports::{Import, NameResolution};
use crate::late::{ConstantHasGenerics, NoConstantGenericsReason, PathSource, Rib, RibKind};
use crate::macros::{MacroRulesScope, sub_namespace_match};
use crate::{
Expand All @@ -37,7 +37,7 @@ impl From<UsePrelude> for bool {
}
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone, Copy)]
enum Shadowing {
Restricted,
Unrestricted,
Expand Down Expand Up @@ -879,53 +879,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.into_iter()
.find_map(|binding| if binding == ignore_binding { None } else { binding });

if let Some(Finalize { path_span, report_private, used, root_span, .. }) = finalize {
let Some(binding) = binding else {
return Err((Determined, Weak::No));
};

if !self.is_accessible_from(binding.vis, parent_scope.module) {
if report_private {
self.privacy_errors.push(PrivacyError {
ident,
binding,
dedup_span: path_span,
outermost_res: None,
parent_scope: *parent_scope,
single_nested: path_span != root_span,
});
} else {
return Err((Determined, Weak::No));
}
}

// Forbid expanded shadowing to avoid time travel.
if let Some(shadowed_glob) = resolution.shadowed_glob
&& shadowing == Shadowing::Restricted
&& binding.expansion != LocalExpnId::ROOT
&& binding.res() != shadowed_glob.res()
{
self.ambiguity_errors.push(AmbiguityError {
kind: AmbiguityKind::GlobVsExpanded,
ident,
b1: binding,
b2: shadowed_glob,
warning: false,
misc1: AmbiguityErrorMisc::None,
misc2: AmbiguityErrorMisc::None,
});
}

if shadowing == Shadowing::Unrestricted
&& binding.expansion != LocalExpnId::ROOT
&& let NameBindingKind::Import { import, .. } = binding.kind
&& matches!(import.kind, ImportKind::MacroExport)
{
self.macro_expanded_macro_export_errors.insert((path_span, binding.span));
}

self.record_use(ident, binding, used);
return Ok(binding);
if let Some(finalize) = finalize {
return self.finalize_module_binding(
ident,
binding,
resolution.shadowed_glob,
parent_scope,
finalize,
shadowing,
);
}

let check_usable = |this: &mut Self, binding: NameBinding<'ra>| {
Expand All @@ -944,75 +906,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

// Check if one of single imports can still define the name,
// if it can then our result is not determined and can be invalidated.
for single_import in &resolution.single_imports {
if ignore_import == Some(*single_import) {
// This branch handles a cycle in single imports.
//
// For example:
// ```
// use a::b;
// use b as a;
// ```
// 1. Record `use a::b` as the `ignore_import` and attempt to locate `a` in the
// current module.
// 2. Encounter the import `use b as a`, which is a `single_import` for `a`,
// and try to find `b` in the current module.
// 3. Re-encounter the `use a::b` import since it's a `single_import` of `b`.
// This leads to entering this branch.
continue;
}
if !self.is_accessible_from(single_import.vis, parent_scope.module) {
continue;
}
if let Some(ignored) = ignore_binding
&& let NameBindingKind::Import { import, .. } = ignored.kind
&& import == *single_import
{
// Ignore not just the binding itself, but if it has a shadowed_glob,
// ignore that, too, because this loop is supposed to only process
// named imports.
continue;
}

let Some(module) = single_import.imported_module.get() else {
return Err((Undetermined, Weak::No));
};
let ImportKind::Single { source, target, target_bindings, .. } = &single_import.kind
else {
unreachable!();
};
if source != target {
// This branch allows the binding to be defined or updated later if the target name
// can hide the source.
if target_bindings.iter().all(|binding| binding.get().is_none()) {
// None of the target bindings are available, so we can't determine
// if this binding is correct or not.
// See more details in #124840
return Err((Undetermined, Weak::No));
} else if target_bindings[ns].get().is_none() && binding.is_some() {
// `binding.is_some()` avoids the condition where the binding
// truly doesn't exist in this namespace and should return `Err(Determined)`.
return Err((Undetermined, Weak::No));
}
}

match self.resolve_ident_in_module(
module,
*source,
ns,
&single_import.parent_scope,
None,
ignore_binding,
ignore_import,
) {
Err((Determined, _)) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, single_import.parent_scope.module) =>
{
continue;
}
Ok(_) | Err((Undetermined, _)) => return Err((Undetermined, Weak::No)),
}
if self.single_import_can_define_name(
&resolution,
binding,
ns,
ignore_import,
ignore_binding,
parent_scope,
) {
return Err((Undetermined, Weak::No));
}

// So we have a resolution that's from a glob import. This resolution is determined
Expand Down Expand Up @@ -1101,6 +1003,129 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
Err((Determined, Weak::No))
}

fn finalize_module_binding(
&mut self,
ident: Ident,
binding: Option<NameBinding<'ra>>,
shadowed_glob: Option<NameBinding<'ra>>,
parent_scope: &ParentScope<'ra>,
finalize: Finalize,
shadowing: Shadowing,
) -> Result<NameBinding<'ra>, (Determinacy, Weak)> {
let Finalize { path_span, report_private, used, root_span, .. } = finalize;

let Some(binding) = binding else {
return Err((Determined, Weak::No));
};

if !self.is_accessible_from(binding.vis, parent_scope.module) {
if report_private {
self.privacy_errors.push(PrivacyError {
ident,
binding,
dedup_span: path_span,
outermost_res: None,
parent_scope: *parent_scope,
single_nested: path_span != root_span,
});
} else {
return Err((Determined, Weak::No));
}
}

// Forbid expanded shadowing to avoid time travel.
if let Some(shadowed_glob) = shadowed_glob
&& shadowing == Shadowing::Restricted
&& binding.expansion != LocalExpnId::ROOT
&& binding.res() != shadowed_glob.res()
{
self.ambiguity_errors.push(AmbiguityError {
kind: AmbiguityKind::GlobVsExpanded,
ident,
b1: binding,
b2: shadowed_glob,
warning: false,
misc1: AmbiguityErrorMisc::None,
misc2: AmbiguityErrorMisc::None,
});
}

if shadowing == Shadowing::Unrestricted
&& binding.expansion != LocalExpnId::ROOT
&& let NameBindingKind::Import { import, .. } = binding.kind
&& matches!(import.kind, ImportKind::MacroExport)
{
self.macro_expanded_macro_export_errors.insert((path_span, binding.span));
}

self.record_use(ident, binding, used);
return Ok(binding);
}

// Checks if a single import can define the `Ident` corresponding to `binding`.
// This is used to check whether we can definitively accept a glob as a resolution.
fn single_import_can_define_name(
&mut self,
resolution: &NameResolution<'ra>,
binding: Option<NameBinding<'ra>>,
ns: Namespace,
ignore_import: Option<Import<'ra>>,
ignore_binding: Option<NameBinding<'ra>>,
parent_scope: &ParentScope<'ra>,
) -> bool {
for single_import in &resolution.single_imports {
if ignore_import == Some(*single_import) {
continue;
}
if !self.is_accessible_from(single_import.vis, parent_scope.module) {
continue;
}
if let Some(ignored) = ignore_binding
&& let NameBindingKind::Import { import, .. } = ignored.kind
&& import == *single_import
{
continue;
}

let Some(module) = single_import.imported_module.get() else {
return true;
};
let ImportKind::Single { source, target, target_bindings, .. } = &single_import.kind
else {
unreachable!();
};
if source != target {
if target_bindings.iter().all(|binding| binding.get().is_none()) {
return true;
} else if target_bindings[ns].get().is_none() && binding.is_some() {
return true;
}
}

match self.resolve_ident_in_module(
module,
*source,
ns,
&single_import.parent_scope,
None,
ignore_binding,
ignore_import,
) {
Err((Determined, _)) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, single_import.parent_scope.module) =>
{
continue;
}
Ok(_) | Err((Undetermined, _)) => {
return true;
}
}
}

false
}

/// Validate a local resolution (from ribs).
#[instrument(level = "debug", skip(self, all_ribs))]
fn validate_res_from_ribs(
Expand Down
Loading
Loading