Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0ef4e11
style: Clarify nullary call and `()` no-break rule applies past max w…
ajasad25 May 22, 2026
33f5959
Remove unused functions in `value_analysis.rs`
nnethercote Apr 29, 2026
bdf8d76
Reduce more visibilities
nnethercote May 1, 2026
d2bb772
Note irrefutable while let in loop type errors
anoshyn May 27, 2026
cfbe6af
Fix tupled closure signature in AsyncFn arg mismatch diagnostic
cijiugechu May 28, 2026
e731b4e
Allow two object files for a single CGU in CompiledModule
bjorn3 May 27, 2026
686c8c9
Expanded tests for &x -> &mut x suggestions
nullie May 29, 2026
9bef677
Fixed &x -> &mut x suggestions for pattern matching
nullie May 29, 2026
4f1630d
Move `compute_object_lifetime_bound` into submodule `dyn_trait`
fmease May 29, 2026
a866e42
Rename `AmbiguousAssocItem` to `AmbiguityBetweenVariantAndAssocItem` …
fmease May 29, 2026
fd36a80
Move distractingly lengthy error reporting code into new `report_ambi…
fmease May 29, 2026
4fe62be
Address irrefutable while let diagnostic review
anoshyn May 29, 2026
ad7cda0
Use `trait_object_dummy_self` more & heavily fix+update related docs
fmease Mar 6, 2026
57393b7
Label irrefutable while let pattern diagnostic
anoshyn May 29, 2026
6906879
Rollup merge of #157027 - fmease:hirtylo-mv-things, r=nnethercote
JonathanBrouwer May 30, 2026
7817883
Rollup merge of #157051 - bjorn3:lto_refactors20, r=saethlin
JonathanBrouwer May 30, 2026
15c53d4
Rollup merge of #153497 - fmease:trait-obj-dummy-self-improvs, r=John…
JonathanBrouwer May 30, 2026
aeaa134
Rollup merge of #155638 - cijiugechu:fix-asyncfn-e0631-diagnostic, r=…
JonathanBrouwer May 30, 2026
dd0956e
Rollup merge of #156826 - ajasad25:style-never-break-empty-parens-152…
JonathanBrouwer May 30, 2026
f6a5279
Rollup merge of #157004 - nnethercote:value_analysis-visibility, r=cj…
JonathanBrouwer May 30, 2026
455ecb5
Rollup merge of #157032 - nullie:borrowck-deref-pattern-mut-suggestio…
JonathanBrouwer May 30, 2026
c9583e0
Rollup merge of #157033 - anoshyn:issue-116572-irrefutable-while-let-…
JonathanBrouwer May 30, 2026
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
75 changes: 36 additions & 39 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4023,63 +4023,60 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
&& decl.can_be_made_mutable()
{
let mut is_for_loop = false;
let mut is_ref_pattern = false;
let mut is_immut_ref_pattern = false;
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
opt_match_place: Some((_, match_span)),
..
})) = *decl.local_info()
{
if matches!(match_span.desugaring_kind(), Some(DesugaringKind::ForLoop)) {
is_for_loop = true;
}

if let Some(body) = self.infcx.tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
struct RefPatternFinder<'tcx> {
tcx: TyCtxt<'tcx>,
binding_span: Span,
is_ref_pattern: bool,
}
if let Some(body) = self.infcx.tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
struct RefPatternFinder<'tcx> {
tcx: TyCtxt<'tcx>,
binding_span: Span,
is_immut_ref_pattern: bool,
}

impl<'tcx> Visitor<'tcx> for RefPatternFinder<'tcx> {
type NestedFilter = OnlyBodies;
impl<'tcx> Visitor<'tcx> for RefPatternFinder<'tcx> {
type NestedFilter = OnlyBodies;

fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx
}
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx
}

fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
if !self.is_ref_pattern
&& let hir::PatKind::Binding(_, _, ident, _) = pat.kind
&& ident.span == self.binding_span
{
self.is_ref_pattern =
self.tcx.hir_parent_iter(pat.hir_id).any(|(_, node)| {
matches!(
node,
hir::Node::Pat(hir::Pat {
kind: hir::PatKind::Ref(..),
..
})
)
});
}
hir::intravisit::walk_pat(self, pat);
fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
if !self.is_immut_ref_pattern
&& let hir::PatKind::Binding(_, _, ident, _) = pat.kind
&& ident.span == self.binding_span
&& matches!(
self.tcx.parent_hir_node(pat.hir_id),
hir::Node::Pat(hir::Pat {
kind: hir::PatKind::Ref(_, _, hir::Mutability::Not),
..
})
)
{
self.is_immut_ref_pattern = true;
}
hir::intravisit::walk_pat(self, pat);
}
}

let mut finder = RefPatternFinder {
tcx: self.infcx.tcx,
binding_span: decl.source_info.span,
is_ref_pattern: false,
};
let mut finder = RefPatternFinder {
tcx: self.infcx.tcx,
binding_span: decl.source_info.span,
is_immut_ref_pattern: false,
};

finder.visit_body(body);
is_ref_pattern = finder.is_ref_pattern;
}
finder.visit_body(body);
is_immut_ref_pattern = finder.is_immut_ref_pattern;
}
}

let (span, message) = if is_for_loop
&& is_ref_pattern
let (span, message) = if is_immut_ref_pattern
&& let Ok(binding_name) =
self.infcx.tcx.sess.source_map().span_to_snippet(decl.source_info.span)
{
Expand Down
66 changes: 22 additions & 44 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ fn disable_incr_cache() -> bool {
}

struct ModuleCodegenResult {
module_regular: CompiledModule,
module_global_asm: Option<CompiledModule>,
module: CompiledModule,
existing_work_product: Option<(WorkProductId, WorkProduct)>,
}

Expand Down Expand Up @@ -80,29 +79,25 @@ impl OngoingCodegen {
Ok(module_codegen_result) => module_codegen_result,
Err(err) => sess.dcx().fatal(err),
};
let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } =
module_codegen_result;
let ModuleCodegenResult { module, existing_work_product } = module_codegen_result;

if let Some((work_product_id, work_product)) = existing_work_product {
work_products.insert(work_product_id, work_product);
} else {
let work_product = if disable_incr_cache {
None
} else if let Some(module_global_asm) = &module_global_asm {
} else if let Some(global_asm_object) = &module.global_asm_object {
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
sess,
&module_regular.name,
&[
("o", module_regular.object.as_ref().unwrap()),
("asm.o", module_global_asm.object.as_ref().unwrap()),
],
&module.name,
&[("o", module.object.as_ref().unwrap()), ("asm.o", global_asm_object)],
&[],
)
} else {
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
sess,
&module_regular.name,
&[("o", module_regular.object.as_ref().unwrap())],
&module.name,
&[("o", module.object.as_ref().unwrap())],
&[],
)
};
Expand All @@ -111,10 +106,7 @@ impl OngoingCodegen {
}
}

modules.push(module_regular);
if let Some(module_global_asm) = module_global_asm {
modules.push(module_global_asm);
}
modules.push(module);
}

self.concurrency_limiter.finished();
Expand Down Expand Up @@ -163,29 +155,17 @@ fn emit_cgu(
debug.emit(&mut product);
}

let module_regular = emit_module(
let module = emit_module(
output_filenames,
prof,
product.object,
ModuleKind::Regular,
name.clone(),
global_asm_object_file,
producer,
)?;

Ok(ModuleCodegenResult {
module_regular,
module_global_asm: global_asm_object_file.map(|global_asm_object_file| CompiledModule {
name: format!("{name}.asm"),
kind: ModuleKind::Regular,
object: Some(global_asm_object_file),
dwarf_object: None,
bytecode: None,
assembly: None,
llvm_ir: None,
links_from_incr_cache: Vec::new(),
}),
existing_work_product: None,
})
Ok(ModuleCodegenResult { module, existing_work_product: None })
}

fn emit_module(
Expand All @@ -194,6 +174,7 @@ fn emit_module(
mut object: cranelift_object::object::write::Object<'_>,
kind: ModuleKind,
name: String,
global_asm_object: Option<PathBuf>,
producer_str: &str,
) -> Result<CompiledModule, String> {
if object.format() == cranelift_object::object::BinaryFormat::Elf {
Expand Down Expand Up @@ -235,6 +216,7 @@ fn emit_module(
name,
kind,
object: Some(tmp_file),
global_asm_object,
dwarf_object: None,
bytecode: None,
assembly: None,
Expand Down Expand Up @@ -265,7 +247,7 @@ fn reuse_workproduct_for_cgu(
}

let obj_out_global_asm =
crate::global_asm::add_file_stem_postfix(obj_out_regular.clone(), ".asm");
tcx.output_filenames(()).temp_path_ext_for_cgu("asm.o", cgu.name().as_str());
let source_file_global_asm = if let Some(asm_o) = work_product.saved_files.get("asm.o") {
let source_file_global_asm = rustc_incremental::in_incr_comp_dir_sess(tcx.sess, asm_o);
if let Err(err) = rustc_fs_util::link_or_copy(&source_file_global_asm, &obj_out_global_asm)
Expand All @@ -283,26 +265,21 @@ fn reuse_workproduct_for_cgu(
};

Ok(ModuleCodegenResult {
module_regular: CompiledModule {
module: CompiledModule {
name: cgu.name().to_string(),
kind: ModuleKind::Regular,
object: Some(obj_out_regular),
global_asm_object: source_file_global_asm.as_ref().map(|_| obj_out_global_asm),
dwarf_object: None,
bytecode: None,
assembly: None,
llvm_ir: None,
links_from_incr_cache: vec![source_file_regular],
links_from_incr_cache: if let Some(source_file_global_asm) = source_file_global_asm {
vec![source_file_regular, source_file_global_asm]
} else {
vec![source_file_regular]
},
},
module_global_asm: source_file_global_asm.map(|source_file| CompiledModule {
name: cgu.name().to_string(),
kind: ModuleKind::Regular,
object: Some(obj_out_global_asm),
dwarf_object: None,
bytecode: None,
assembly: None,
llvm_ir: None,
links_from_incr_cache: vec![source_file],
}),
existing_work_product: Some((cgu.work_product_id(), work_product)),
})
}
Expand Down Expand Up @@ -447,6 +424,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
product.object,
ModuleKind::Allocator,
"allocator_shim".to_owned(),
None,
&crate::debuginfo::producer(tcx.sess),
) {
Ok(allocator_module) => Some(allocator_module),
Expand Down
18 changes: 2 additions & 16 deletions compiler/rustc_codegen_cranelift/src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::layout::{
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers,
};
use rustc_session::config::{OutputFilenames, OutputType};
use rustc_session::config::OutputFilenames;
use rustc_target::asm::InlineAsmArch;

use crate::prelude::*;
Expand Down Expand Up @@ -198,10 +198,7 @@ pub(crate) fn compile_global_asm(
.join("\n");
global_asm.push('\n');

let global_asm_object_file = add_file_stem_postfix(
config.output_filenames.temp_path_for_cgu(OutputType::Object, cgu_name),
".asm",
);
let global_asm_object_file = config.output_filenames.temp_path_ext_for_cgu("asm.o", cgu_name);

// Assemble `global_asm`
if option_env!("CG_CLIF_FORCE_GNU_AS").is_some() {
Expand Down Expand Up @@ -271,14 +268,3 @@ pub(crate) fn compile_global_asm(

Ok(Some(global_asm_object_file))
}

pub(crate) fn add_file_stem_postfix(mut path: PathBuf, postfix: &str) -> PathBuf {
let mut new_filename = path.file_stem().unwrap().to_owned();
new_filename.push(postfix);
if let Some(extension) = path.extension() {
new_filename.push(".");
new_filename.push(extension);
}
path.set_file_name(new_filename);
path
}
Loading
Loading