Skip to content

Rollup of 11 pull requests #142604

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 29 commits into from
Closed
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
1e10dfc
Add all rustc_std_internal_symbol to symbols.o
bjorn3 May 8, 2025
2d2d70f
Remove dependency injection for the panic runtime
bjorn3 May 8, 2025
3a7ae67
Stop handling explicit dependencies on the panic runtime
bjorn3 May 8, 2025
f8d1bfa
Avoid exporting panic_unwind as stdlib cargo feature
bjorn3 May 8, 2025
6df5456
Make comment on activate_injected_dep a doc comment
bjorn3 May 9, 2025
0e1db54
Windows: Use anonymous pipes in Command
ChrisDenton Jun 14, 2025
3cb0cba
Handle win32 separator & prefixes for cygwin paths
Berrysoft Jun 1, 2025
32c0cb0
Add union with default field values case test
jieyouxu Jun 16, 2025
718df66
Two changes: Have BorrowError & BorrowMutError derive Debug and add
nealsid Jun 14, 2025
2fca05a
Rename BorrowFlag type to BorrowCounter
nealsid Jun 14, 2025
23e35c6
Add support for repetition to `proc_macro::quote`
moatom May 26, 2025
7cfc51b
Update books
rustbot Jun 16, 2025
8a7b50a
Fold unnecessary visit_struct_field_def in AstValidator
compiler-errors Jun 16, 2025
994794a
Handle same-crate macro for borrowck semicolon suggestion
Urgau Jun 16, 2025
7b29a5d
Revert overeager warning for misuse of `--print native-static-libs`
workingjubilee Jun 16, 2025
7859a37
explicitly set llvm_abiname option on existing ppc64 targets
ostylk Jun 11, 2025
9c1180b
indicate ppc64 elf abi in e_flags
ostylk Jun 11, 2025
2dd9cc1
Reject union default field values
jieyouxu Jun 16, 2025
3b9ae23
Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=wesleywiser…
jhpratt Jun 17, 2025
e698e9c
Rollup merge of #141608 - moatom:proc_macro-140238, r=dtolnay
jhpratt Jun 17, 2025
39a0bdc
Rollup merge of #141864 - Berrysoft:cygwin-path, r=ChrisDenton
jhpratt Jun 17, 2025
ad7c50f
Rollup merge of #142216 - nealsid:refcell-logging, r=tgross35
jhpratt Jun 17, 2025
9b267ea
Rollup merge of #142517 - ChrisDenton:anon-pipe, r=Mark-Simulacrum
jhpratt Jun 17, 2025
78e2974
Rollup merge of #142570 - jieyouxu:disunion, r=estebank
jhpratt Jun 17, 2025
70320e7
Rollup merge of #142584 - Urgau:span-borrowck-139049, r=fmease
jhpratt Jun 17, 2025
7423763
Rollup merge of #142585 - rustbot:docs-update, r=ehuss
jhpratt Jun 17, 2025
ccd9b6a
Rollup merge of #142586 - compiler-errors:remove-visit-struct-field-d…
jhpratt Jun 17, 2025
0f50901
Rollup merge of #142595 - workingjubilee:revert-warning-138139, r=Chr…
jhpratt Jun 17, 2025
5d62529
Rollup merge of #142598 - ostylk:fix/ppc64_llvmabi, r=nikic,workingju…
jhpratt Jun 17, 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
2 changes: 2 additions & 0 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ ast_lowering_underscore_expr_lhs_assign =
in expressions, `_` can only be used on the left-hand side of an assignment
.label = `_` not allowed here

ast_lowering_union_default_field_values = unions cannot have default field values

ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
ast_lowering_unstable_inline_assembly_label_operand_with_outputs =
using both label and output operands for inline assembly is unstable
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,10 @@ pub(crate) struct UseConstGenericArg {
#[suggestion_part(code = "{other_args}")]
pub call_args: Span,
}

#[derive(Diagnostic)]
#[diag(ast_lowering_union_default_field_values)]
pub(crate) struct UnionWithDefault {
#[primary_span]
pub span: Span,
}
42 changes: 32 additions & 10 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use tracing::instrument;

use super::errors::{
InvalidAbi, InvalidAbiSuggestion, MisplacedRelaxTraitBound, TupleStructWithDefault,
UnionWithDefault,
};
use super::stability::{enabled_names, gate_unstable_abi};
use super::{
Expand Down Expand Up @@ -316,7 +317,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|this| {
this.arena.alloc_from_iter(
enum_definition.variants.iter().map(|x| this.lower_variant(x)),
enum_definition.variants.iter().map(|x| this.lower_variant(i, x)),
)
},
);
Expand All @@ -328,7 +329,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics,
id,
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|this| this.lower_variant_data(hir_id, struct_def),
|this| this.lower_variant_data(hir_id, i, struct_def),
);
hir::ItemKind::Struct(ident, generics, struct_def)
}
Expand All @@ -338,7 +339,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics,
id,
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|this| this.lower_variant_data(hir_id, vdata),
|this| this.lower_variant_data(hir_id, i, vdata),
);
hir::ItemKind::Union(ident, generics, vdata)
}
Expand Down Expand Up @@ -714,13 +715,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
}

fn lower_variant(&mut self, v: &Variant) -> hir::Variant<'hir> {
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> {
let hir_id = self.lower_node_id(v.id);
self.lower_attrs(hir_id, &v.attrs, v.span);
hir::Variant {
hir_id,
def_id: self.local_def_id(v.id),
data: self.lower_variant_data(hir_id, &v.data),
data: self.lower_variant_data(hir_id, item_kind, &v.data),
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const_to_anon_const(e)),
ident: self.lower_ident(v.ident),
span: self.lower_span(v.span),
Expand All @@ -730,15 +731,36 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_variant_data(
&mut self,
parent_id: hir::HirId,
item_kind: &ItemKind,
vdata: &VariantData,
) -> hir::VariantData<'hir> {
match vdata {
VariantData::Struct { fields, recovered } => hir::VariantData::Struct {
fields: self
VariantData::Struct { fields, recovered } => {
let fields = self
.arena
.alloc_from_iter(fields.iter().enumerate().map(|f| self.lower_field_def(f))),
recovered: *recovered,
},
.alloc_from_iter(fields.iter().enumerate().map(|f| self.lower_field_def(f)));

if let ItemKind::Union(..) = item_kind {
for field in &fields[..] {
if let Some(default) = field.default {
// Unions cannot derive `Default`, and it's not clear how to use default
// field values of unions if that was supported. Therefore, blanket reject
// trying to use field values with unions.
if self.tcx.features().default_field_values() {
self.dcx().emit_err(UnionWithDefault { span: default.span });
} else {
let _ = self.dcx().span_delayed_bug(
default.span,
"expected union default field values feature gate error but none \
was produced",
);
}
}
}
}

hir::VariantData::Struct { fields, recovered: *recovered }
}
VariantData::Tuple(fields, id) => {
let ctor_id = self.lower_node_id(*id);
self.alias_attrs(ctor_id, parent_id);
Expand Down
20 changes: 2 additions & 18 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,6 @@ impl<'a> AstValidator<'a> {
}
}

fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
if let Some(ref ident) = field.ident
&& ident.name == kw::Underscore
{
self.visit_vis(&field.vis);
self.visit_ident(ident);
self.visit_ty_common(&field.ty);
self.walk_ty(&field.ty);
walk_list!(self, visit_attribute, &field.attrs);
} else {
self.visit_field_def(field);
}
}

fn dcx(&self) -> DiagCtxtHandle<'a> {
self.sess.dcx()
}
Expand Down Expand Up @@ -1135,8 +1121,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
VariantData::Struct { fields, .. } => {
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
self.visit_generics(generics);
// Permit `Anon{Struct,Union}` as field type.
walk_list!(self, visit_struct_field_def, fields);
walk_list!(self, visit_field_def, fields);
}
_ => visit::walk_item(self, item),
},
Expand All @@ -1148,8 +1133,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
VariantData::Struct { fields, .. } => {
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
self.visit_generics(generics);
// Permit `Anon{Struct,Union}` as field type.
walk_list!(self, visit_struct_field_def, fields);
walk_list!(self, visit_field_def, fields);
}
_ => visit::walk_item(self, item),
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}
} else if let LocalInfo::BlockTailTemp(info) = local_decl.local_info() {
let sp = info
.span
.find_ancestor_in_same_ctxt(local_decl.source_info.span)
.unwrap_or(info.span);
let sp = info.span.find_oldest_ancestor_in_same_ctxt();
if info.tail_result_is_ignored {
// #85581: If the first mutable borrow's scope contains
// the second borrow, this suggestion isn't helpful.
Expand Down
19 changes: 0 additions & 19 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,6 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
}
}

fn check_link_info_print_request(sess: &Session, crate_types: &[CrateType]) {
let print_native_static_libs =
sess.opts.prints.iter().any(|p| p.kind == PrintKind::NativeStaticLibs);
let has_staticlib = crate_types.iter().any(|ct| *ct == CrateType::Staticlib);
if print_native_static_libs {
if !has_staticlib {
sess.dcx()
.warn(format!("cannot output linkage information without staticlib crate-type"));
sess.dcx()
.note(format!("consider `--crate-type staticlib` to print linkage information"));
} else if !sess.opts.output_types.should_link() {
sess.dcx()
.warn(format!("cannot output linkage information when --emit link is not passed"));
}
}
}

/// Performs the linkage portion of the compilation phase. This will generate all
/// of the requested outputs for this compilation session.
pub fn link_binary(
Expand Down Expand Up @@ -208,8 +191,6 @@ pub fn link_binary(
}
}

check_link_info_print_request(sess, &codegen_results.crate_info.crate_types);

// Remove the temporary object file and metadata if we aren't saving temps.
sess.time("link_binary_remove_temps", || {
// If the user requests that temporaries are saved, don't delete any.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,7 @@ pub(crate) fn linked_symbols(
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum)
|| info.used
|| info.rustc_std_internal_symbol
{
symbols.push((
symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
};
e_flags
}
Architecture::PowerPc64 => {
const EF_PPC64_ABI_UNKNOWN: u32 = 0;
const EF_PPC64_ABI_ELF_V1: u32 = 1;
const EF_PPC64_ABI_ELF_V2: u32 = 2;

match sess.target.options.llvm_abiname.as_ref() {
// If the flags do not correctly indicate the ABI,
// linkers such as ld.lld assume that the ppc64 object files are always ELFv2
// which leads to broken binaries if ELFv1 is used for the object files.
"elfv1" => EF_PPC64_ABI_ELF_V1,
"elfv2" => EF_PPC64_ABI_ELF_V2,
"" if sess.target.options.binary_format.to_object() == BinaryFormat::Elf => {
bug!("No ABI specified for this PPC64 ELF target");
}
// Fall back
_ => EF_PPC64_ABI_UNKNOWN,
}
}
_ => 0,
}
}
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
|| used,
rustc_std_internal_symbol: codegen_attrs
.flags
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),
};
(def_id.to_def_id(), info)
})
Expand All @@ -143,6 +146,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
);
}
Expand Down Expand Up @@ -191,6 +195,7 @@ fn exported_symbols_provider_local<'tcx>(
level: info.level,
kind: SymbolExportKind::Text,
used: info.used,
rustc_std_internal_symbol: info.rustc_std_internal_symbol,
},
)
})
Expand All @@ -207,6 +212,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -229,6 +235,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: true,
},
));
}
Expand All @@ -243,6 +250,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: true,
},
))
}
Expand All @@ -262,6 +270,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
)
}));
Expand All @@ -287,6 +296,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: false,
rustc_std_internal_symbol: false,
},
)
}));
Expand All @@ -304,6 +314,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::C,
kind: SymbolExportKind::Data,
used: true,
rustc_std_internal_symbol: false,
},
));
}
Expand Down Expand Up @@ -379,6 +390,8 @@ fn exported_symbols_provider_local<'tcx>(
}
}

// Note: These all set rustc_std_internal_symbol to false as generic functions must not
// be marked with this attribute and we are only handling generic functions here.
match *mono_item {
MonoItem::Fn(Instance { def: InstanceKind::Item(def), args }) => {
let has_generics = args.non_erasable_generics().next().is_some();
Expand All @@ -394,6 +407,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -416,6 +430,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -432,6 +447,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand All @@ -442,6 +458,7 @@ fn exported_symbols_provider_local<'tcx>(
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: false,
},
));
}
Expand Down
22 changes: 1 addition & 21 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::time::{Duration, Instant};
use itertools::Itertools;
use rustc_abi::FIRST_VARIANT;
use rustc_ast as ast;
use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_name};
use rustc_ast::expand::allocator::AllocatorKind;
use rustc_attr_data_structures::OptimizeAttr;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
Expand Down Expand Up @@ -1039,26 +1039,6 @@ impl CrateInfo {
.collect::<Vec<_>>();
symbols.sort_unstable_by(|a, b| a.0.cmp(&b.0));
linked_symbols.extend(symbols);
if tcx.allocator_kind(()).is_some() {
// At least one crate needs a global allocator. This crate may be placed
// after the crate that defines it in the linker order, in which case some
// linkers return an error. By adding the global allocator shim methods to
// the linked_symbols list, linking the generated symbols.o will ensure that
// circular dependencies involving the global allocator don't lead to linker
// errors.
linked_symbols.extend(ALLOCATOR_METHODS.iter().map(|method| {
(
format!(
"{prefix}{}",
mangle_internal_symbol(
tcx,
global_fn_name(method.name).as_str()
)
),
SymbolExportKind::Text,
)
}));
}
});
}

Expand Down
Loading
Loading