Skip to content

Rollup of 11 pull requests #143888

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 29 commits into from
Jul 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8d0e0c6
interpret/allocation: expose init + write_wildcards on a range
nia-e Jul 8, 2025
889582e
Check assoc consts and tys later like assoc fns
mu001999 Jul 6, 2025
e681d1a
constify `From` and `Into`
oli-obk Jul 11, 2025
3fe3edb
Add --compile-time-deps argument for x check
bjorn3 Jul 11, 2025
34426dc
Fix fallback for CI_JOB_NAME
nikic Jul 11, 2025
87958ad
Avoid building C++ for rustc_llvm with --compile-time-deps
bjorn3 Jul 11, 2025
ae1075b
Update description for flag
bjorn3 Jul 11, 2025
3751e13
slice: Mark `rotate_left`, `rotate_right` unstably const
okaneco Jul 6, 2025
73edfe7
clippy: fix test filtering when TESTNAME is empty
RalfJung Jul 12, 2025
acbbc18
fix span for deferred command execution
Shourya742 Jul 12, 2025
57ee3f2
add span to streaming command execution flow
Shourya742 Jul 12, 2025
ccc302b
Move --compile-time-deps
bjorn3 Jul 12, 2025
10bec8f
Add change_tracker.rs entry
bjorn3 Jul 12, 2025
9ed5378
replace binding and shadowed_glob on NameResolution with non_glob_bin…
b-naber Jul 11, 2025
a9a238b
explicitly drop span_guard in wait_for_output
Shourya742 Jul 12, 2025
e3fc6e5
merge source and target bindings into single field
LorrensP-2158466 Jul 9, 2025
47b8a32
moved tests
Kivooeo Jul 1, 2025
9893470
cleaned up some tests
Kivooeo Jul 1, 2025
b56880c
Rollup merge of #143301 - Kivooeo:tf26, r=tgross35
matthiaskrgr Jul 13, 2025
7e0721b
Rollup merge of #143519 - mu001999-contrib:dead-code/impl-items, r=pe…
matthiaskrgr Jul 13, 2025
061bd28
Rollup merge of #143554 - okaneco:const_slice_rotate, r=Amanieu,tgross35
matthiaskrgr Jul 13, 2025
762b314
Rollup merge of #143634 - nia-e:init-and-wildcards, r=RalfJung
matthiaskrgr Jul 13, 2025
acbf5e4
Rollup merge of #143685 - LorrensP-2158466:merge-import-bindings, r=p…
matthiaskrgr Jul 13, 2025
dcdb35a
Rollup merge of #143734 - LorrensP-2158466:refactor-resolve-resolutio…
matthiaskrgr Jul 13, 2025
ccd6d6c
Rollup merge of #143774 - oli-obk:const_from, r=fee1-dead
matthiaskrgr Jul 13, 2025
b4b00c7
Rollup merge of #143785 - bjorn3:faster_ra_build_script_build, r=Kobzol
matthiaskrgr Jul 13, 2025
ee1595c
Rollup merge of #143786 - nikic:ci-job-name-fallback, r=marcoieni
matthiaskrgr Jul 13, 2025
5284c84
Rollup merge of #143825 - RalfJung:clippy-test-filter, r=llogiq
matthiaskrgr Jul 13, 2025
3ff549f
Rollup merge of #143826 - Shourya742:2025-07-12-fix-command-trace, r=…
matthiaskrgr Jul 13, 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/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ features = ['unprefixed_malloc_on_supported_platforms']

[features]
# tidy-alphabetical-start
check_only = ['rustc_driver_impl/check_only']
jemalloc = ['dep:tikv-jemalloc-sys']
llvm = ['rustc_driver_impl/llvm']
max_level_info = ['rustc_driver_impl/max_level_info']
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ serde_json = "1"
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
# tidy-alphabetical-end

[features]
check_only = ["rustc_llvm/check_only"]
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
dest_alloc
.write_uninit(&tcx, dest_range)
.map_err(|e| e.to_interp_error(dest_alloc_id))?;
// We can forget about the provenance, this is all not initialized anyway.
// `write_uninit` also resets the provenance, so we are done.
return interp_ok(());
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ctrlc = "3.4.4"

[features]
# tidy-alphabetical-start
check_only = ['rustc_interface/check_only']
llvm = ['rustc_interface/llvm']
max_level_info = ['rustc_log/max_level_info']
rustc_randomized_layouts = [
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ rustc_abi = { path = "../rustc_abi" }

[features]
# tidy-alphabetical-start
check_only = ['rustc_codegen_llvm?/check_only']
llvm = ['dep:rustc_codegen_llvm']
# tidy-alphabetical-end
4 changes: 4 additions & 0 deletions compiler/rustc_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ libc = "0.2.73"
# pinned `cc` in `rustc_codegen_ssa` if you update `cc` here.
cc = "=1.2.16"
# tidy-alphabetical-end

[features]
# Used by ./x.py check --compile-time-deps to skip building C++ code
check_only = []
4 changes: 4 additions & 0 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ fn output(cmd: &mut Command) -> String {
}

fn main() {
if cfg!(feature = "check_only") {
return;
}

for component in REQUIRED_COMPONENTS.iter().chain(OPTIONAL_COMPONENTS.iter()) {
println!("cargo:rustc-check-cfg=cfg(llvm_component,values(\"{component}\"))");
}
Expand Down
33 changes: 15 additions & 18 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub struct Allocation<Prov: Provenance = CtfeProvenance, Extra = (), Bytes = Box
/// at the given offset.
provenance: ProvenanceMap<Prov>,
/// Denotes which part of this allocation is initialized.
///
/// Invariant: the uninitialized parts have no provenance.
init_mask: InitMask,
/// The alignment of the allocation to detect unaligned reads.
/// (`Align` guarantees that this is a power of two.)
Expand Down Expand Up @@ -796,24 +798,19 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
Ok(())
}

/// Initialize all previously uninitialized bytes in the entire allocation, and set
/// provenance of everything to `Wildcard`. Before calling this, make sure all
/// provenance in this allocation is exposed!
pub fn prepare_for_native_access(&mut self) {
let full_range = AllocRange { start: Size::ZERO, size: Size::from_bytes(self.len()) };
// Overwrite uninitialized bytes with 0, to ensure we don't leak whatever their value happens to be.
for chunk in self.init_mask.range_as_init_chunks(full_range) {
if !chunk.is_init() {
let uninit_bytes = &mut self.bytes
[chunk.range().start.bytes_usize()..chunk.range().end.bytes_usize()];
uninit_bytes.fill(0);
}
}
// Mark everything as initialized now.
self.mark_init(full_range, true);

// Set provenance of all bytes to wildcard.
self.provenance.write_wildcards(self.len());
/// Mark all bytes in the given range as initialised and reset the provenance
/// to wildcards. This entirely breaks the normal mechanisms for tracking
/// initialisation and is only provided for Miri operating in native-lib
/// mode. UB will be missed if the underlying bytes were not actually written to.
///
/// If `range` is `None`, defaults to performing this on the whole allocation.
pub fn process_native_write(&mut self, cx: &impl HasDataLayout, range: Option<AllocRange>) {
let range = range.unwrap_or_else(|| AllocRange {
start: Size::ZERO,
size: Size::from_bytes(self.len()),
});
self.mark_init(range, true);
self.provenance.write_wildcards(cx, range);
}

/// Remove all provenance in the given memory range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,37 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
Ok(())
}

/// Overwrites all provenance in the allocation with wildcard provenance.
/// Overwrites all provenance in the given range with wildcard provenance.
/// Pointers partially overwritten will have their provenances preserved
/// bytewise on their remaining bytes.
///
/// Provided for usage in Miri and panics otherwise.
pub fn write_wildcards(&mut self, alloc_size: usize) {
pub fn write_wildcards(&mut self, cx: &impl HasDataLayout, range: AllocRange) {
assert!(
Prov::OFFSET_IS_ADDR,
"writing wildcard provenance is not supported when `OFFSET_IS_ADDR` is false"
);
let wildcard = Prov::WILDCARD.unwrap();

// Remove all pointer provenances, then write wildcards into the whole byte range.
self.ptrs.clear();
let last = Size::from_bytes(alloc_size);
let bytes = self.bytes.get_or_insert_with(Box::default);
for offset in Size::ZERO..last {

// Remove pointer provenances that overlap with the range, then readd the edge ones bytewise.
let ptr_range = Self::adjusted_range_ptrs(range, cx);
let ptrs = self.ptrs.range(ptr_range.clone());
if let Some((offset, prov)) = ptrs.first() {
for byte_ofs in *offset..range.start {
bytes.insert(byte_ofs, *prov);
}
}
if let Some((offset, prov)) = ptrs.last() {
for byte_ofs in range.end()..*offset + cx.data_layout().pointer_size() {
bytes.insert(byte_ofs, *prov);
}
}
self.ptrs.remove_range(ptr_range);

// Overwrite bytewise provenance.
for offset in range.start..range.end() {
bytes.insert(offset, wildcard);
}
}
Expand Down
70 changes: 46 additions & 24 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_hir::{self as hir, ImplItem, ImplItemKind, Node, PatKind, QPath, TyKin
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::privacy::Level;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::ty::{self, AssocTag, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::DEAD_CODE;
use rustc_session::lint::{self, LintExpectationId};
Expand Down Expand Up @@ -115,7 +115,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {

fn handle_res(&mut self, res: Res) {
match res {
Res::Def(DefKind::Const | DefKind::AssocConst | DefKind::TyAlias, def_id) => {
Res::Def(
DefKind::Const | DefKind::AssocConst | DefKind::AssocTy | DefKind::TyAlias,
def_id,
) => {
self.check_def_id(def_id);
}
_ if self.in_pat => {}
Expand Down Expand Up @@ -482,7 +485,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
) -> bool {
let trait_def_id = match self.tcx.def_kind(local_def_id) {
// assoc impl items of traits are live if the corresponding trait items are live
DefKind::AssocFn => self
DefKind::AssocConst | DefKind::AssocTy | DefKind::AssocFn => self
.tcx
.associated_item(local_def_id)
.trait_item_def_id
Expand Down Expand Up @@ -647,6 +650,31 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {

self.in_pat = in_pat;
}

fn visit_trait_ref(&mut self, t: &'tcx hir::TraitRef<'tcx>) {
if let Some(trait_def_id) = t.path.res.opt_def_id()
&& let Some(segment) = t.path.segments.last()
&& let Some(args) = segment.args
{
for constraint in args.constraints {
if let Some(local_def_id) = self
.tcx
.associated_items(trait_def_id)
.find_by_ident_and_kind(
self.tcx,
constraint.ident,
AssocTag::Const,
trait_def_id,
)
.and_then(|item| item.def_id.as_local())
{
self.worklist.push((local_def_id, ComesFromAllowExpect::No));
}
}
}

intravisit::walk_trait_ref(self, t);
}
}

fn has_allow_dead_code_or_lang_attr(
Expand Down Expand Up @@ -744,18 +772,12 @@ fn check_item<'tcx>(
{
worklist.push((local_def_id, comes_from_allow));
} else if of_trait {
// FIXME: This condition can be removed
// if we support dead check for assoc consts and tys.
if !matches!(tcx.def_kind(local_def_id), DefKind::AssocFn) {
worklist.push((local_def_id, ComesFromAllowExpect::No));
} else {
// We only care about associated items of traits,
// because they cannot be visited directly,
// so we later mark them as live if their corresponding traits
// or trait items and self types are both live,
// but inherent associated items can be visited and marked directly.
unsolved_items.push((id, local_def_id));
}
// We only care about associated items of traits,
// because they cannot be visited directly,
// so we later mark them as live if their corresponding traits
// or trait items and self types are both live,
// but inherent associated items can be visited and marked directly.
unsolved_items.push((id, local_def_id));
}
}
}
Expand Down Expand Up @@ -791,15 +813,14 @@ fn check_trait_item(
worklist: &mut Vec<(LocalDefId, ComesFromAllowExpect)>,
id: hir::TraitItemId,
) {
use hir::TraitItemKind::{Const, Fn};
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) {
let trait_item = tcx.hir_trait_item(id);
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(..))
&& let Some(comes_from_allow) =
has_allow_dead_code_or_lang_attr(tcx, trait_item.owner_id.def_id)
{
worklist.push((trait_item.owner_id.def_id, comes_from_allow));
}
use hir::TraitItemKind::{Const, Fn, Type};

let trait_item = tcx.hir_trait_item(id);
if matches!(trait_item.kind, Const(_, Some(_)) | Type(_, Some(_)) | Fn(..))
&& let Some(comes_from_allow) =
has_allow_dead_code_or_lang_attr(tcx, trait_item.owner_id.def_id)
{
worklist.push((trait_item.owner_id.def_id, comes_from_allow));
}
}

Expand Down Expand Up @@ -1163,6 +1184,7 @@ impl<'tcx> DeadVisitor<'tcx> {
}
match self.tcx.def_kind(def_id) {
DefKind::AssocConst
| DefKind::AssocTy
| DefKind::AssocFn
| DefKind::Fn
| DefKind::Static { .. }
Expand Down
18 changes: 4 additions & 14 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ use crate::def_collector::collect_definitions;
use crate::imports::{ImportData, ImportKind};
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
use crate::{
BindingKey, Determinacy, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind,
ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult,
ResolutionError, Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError,
errors,
BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot,
NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult, ResolutionError,
Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError, errors,
};

type Res = def::Res<NodeId>;
Expand Down Expand Up @@ -620,16 +619,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
let kind = ImportKind::Single {
source: source.ident,
target: ident,
source_bindings: PerNS {
type_ns: Cell::new(Err(Determinacy::Undetermined)),
value_ns: Cell::new(Err(Determinacy::Undetermined)),
macro_ns: Cell::new(Err(Determinacy::Undetermined)),
},
target_bindings: PerNS {
type_ns: Cell::new(None),
value_ns: Cell::new(None),
macro_ns: Cell::new(None),
},
bindings: Default::default(),
type_ns_only,
nested,
id,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ impl Resolver<'_, '_> {
for (_key, resolution) in self.resolutions(*module).borrow().iter() {
let resolution = resolution.borrow();

if let Some(binding) = resolution.binding
if let Some(binding) = resolution.best_binding()
&& let NameBindingKind::Import { import, .. } = binding.kind
&& let ImportKind::Single { id, .. } = import.kind
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|(key, name_resolution)| {
if key.ns == TypeNS
&& key.ident == ident
&& let Some(binding) = name_resolution.borrow().binding
&& let Some(binding) = name_resolution.borrow().best_binding()
{
match binding.res() {
// No disambiguation needed if the identically named item we
Expand Down Expand Up @@ -1494,7 +1494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return None;
};
for (_, resolution) in this.resolutions(m).borrow().iter() {
let Some(binding) = resolution.borrow().binding else {
let Some(binding) = resolution.borrow().best_binding() else {
continue;
};
let Res::Def(DefKind::Macro(MacroKind::Derive | MacroKind::Attr), def_id) =
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// binding if it exists. What we really want here is having two separate scopes in
// a module - one for non-globs and one for globs, but until that's done use this
// hack to avoid inconsistent resolution ICEs during import validation.
let binding = [resolution.binding, resolution.shadowed_glob]
let binding = [resolution.non_glob_binding, resolution.glob_binding]
.into_iter()
.find_map(|binding| if binding == ignore_binding { None } else { binding });

if let Some(finalize) = finalize {
return self.finalize_module_binding(
ident,
binding,
resolution.shadowed_glob,
if resolution.non_glob_binding.is_some() { resolution.glob_binding } else { None },
parent_scope,
finalize,
shadowing,
Expand Down Expand Up @@ -1090,14 +1090,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let Some(module) = single_import.imported_module.get() else {
return true;
};
let ImportKind::Single { source, target, target_bindings, .. } = &single_import.kind
else {
let ImportKind::Single { source, target, bindings, .. } = &single_import.kind else {
unreachable!();
};
if source != target {
if target_bindings.iter().all(|binding| binding.get().is_none()) {
if bindings.iter().all(|binding| binding.get().binding().is_none()) {
return true;
} else if target_bindings[ns].get().is_none() && binding.is_some() {
} else if bindings[ns].get().binding().is_none() && binding.is_some() {
return true;
}
}
Expand Down
Loading
Loading