Skip to content

Commit 56fda15

Browse files
committed
Auto merge of #159437 - JonathanBrouwer:rollup-6Vo34je, r=<try>
Rollup of 16 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
2 parents 4a9d536 + a97a4d9 commit 56fda15

127 files changed

Lines changed: 1276 additions & 391 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use rustc_codegen_ssa::{CompiledModules, CrateInfo, TargetConfig, back};
4242
use rustc_log::tracing::info;
4343
use rustc_middle::dep_graph::WorkProductMap;
4444
use rustc_session::Session;
45-
use rustc_session::config::OutputFilenames;
45+
use rustc_session::config::{NATIVE_CPU, OutputFilenames};
4646
use rustc_span::{Symbol, sym};
4747
use rustc_target::spec::{Arch, CfgAbi, Env, Os};
4848

@@ -341,7 +341,7 @@ fn build_isa(sess: &Session, jit: bool) -> Arc<dyn TargetIsa + 'static> {
341341
let flags = settings::Flags::new(flags_builder);
342342

343343
let isa_builder = match sess.opts.cg.target_cpu.as_deref() {
344-
Some("native") => cranelift_native::builder_with_options(true).unwrap(),
344+
Some(NATIVE_CPU) => cranelift_native::builder_with_options(true).unwrap(),
345345
Some(value) => {
346346
let mut builder =
347347
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {

compiler/rustc_codegen_gcc/src/gcc_util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use gccjit::Context;
33
use rustc_codegen_ssa::target_features;
44
use rustc_data_structures::smallvec::{SmallVec, smallvec};
55
use rustc_session::Session;
6+
use rustc_session::config::NATIVE_CPU;
67
use rustc_target::spec::Arch;
78

89
fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
@@ -115,7 +116,7 @@ fn arch_to_gcc(name: &str) -> &str {
115116
}
116117

117118
fn handle_native(name: &str) -> &str {
118-
if name != "native" {
119+
if name != NATIVE_CPU {
119120
return arch_to_gcc(name);
120121
}
121122

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
1414
use rustc_fs_util::path_to_c_string;
1515
use rustc_middle::bug;
1616
use rustc_session::Session;
17-
use rustc_session::config::{PrintKind, PrintRequest};
17+
use rustc_session::config::{NATIVE_CPU, PrintKind, PrintRequest};
1818
use rustc_target::spec::{
1919
Arch, CfgAbi, Env, MergeFunctions, Os, PanicStrategy, SmallDataThresholdSupport,
2020
};
@@ -514,10 +514,12 @@ fn print_target_cpus(sess: &Session, tm: &llvm::TargetMachine, out: &mut String)
514514

515515
// Only print the "native" entry when host and target are the same arch,
516516
// since otherwise it could be wrong or misleading.
517-
if sess.host.arch == sess.target.arch {
517+
// Also do not print it if `requires_consistent_cpu` is set, because in this case
518+
// "native" would be rejected.
519+
if sess.host.arch == sess.target.arch && !sess.target.requires_consistent_cpu {
518520
let host = get_host_cpu_name();
519521
cpus.push_front(Cpu {
520-
cpu_name: "native",
522+
cpu_name: NATIVE_CPU,
521523
remark: format!(" - Select the CPU of the current host (currently {host})."),
522524
});
523525
}
@@ -612,7 +614,7 @@ fn get_host_cpu_name() -> &'static str {
612614
/// LLVM. Otherwise, the string is returned as-is.
613615
fn handle_native(cpu_name: &str) -> &str {
614616
match cpu_name {
615-
"native" => get_host_cpu_name(),
617+
NATIVE_CPU => get_host_cpu_name(),
616618
_ => cpu_name,
617619
}
618620
}
@@ -666,7 +668,7 @@ pub(crate) fn global_llvm_features(sess: &Session, only_base_features: bool) ->
666668

667669
// -Ctarget-cpu=native
668670
match sess.opts.cg.target_cpu {
669-
Some(ref s) if s == "native" => {
671+
Some(ref s) if s == NATIVE_CPU => {
670672
// We have already figured out the actual CPU name with `LLVMRustGetHostCPUName` and set
671673
// that for LLVM, so the features implied by that CPU name will be available everywhere.
672674
// However, that is not sufficient: e.g. `skylake` alone is not sufficient to tell if

compiler/rustc_index/src/bit_set.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,11 +1287,22 @@ impl<'a, T: Idx> Iterator for MixedBitIter<'a, T> {
12871287
///
12881288
/// All operations that involve an element will panic if the element is equal
12891289
/// to or greater than the domain size.
1290-
#[derive(Clone, Debug, PartialEq)]
1290+
#[derive(Debug, PartialEq)]
12911291
pub struct GrowableBitSet<T: Idx> {
12921292
bit_set: DenseBitSet<T>,
12931293
}
12941294

1295+
// Manually implemented to forward `clone_from`, and to avoid the `T: Clone` bound.
1296+
impl<T: Idx> Clone for GrowableBitSet<T> {
1297+
fn clone(&self) -> Self {
1298+
Self { bit_set: self.bit_set.clone() }
1299+
}
1300+
1301+
fn clone_from(&mut self, source: &Self) {
1302+
self.bit_set.clone_from(&source.bit_set);
1303+
}
1304+
}
1305+
12951306
impl<T: Idx> Default for GrowableBitSet<T> {
12961307
fn default() -> Self {
12971308
GrowableBitSet::new_empty()

compiler/rustc_interface/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub(crate) struct TempsDirError;
8484
pub(crate) struct OutDirError;
8585

8686
#[derive(Diagnostic)]
87-
#[diag("failed to write file {$path}: {$error}\"")]
87+
#[diag("failed to write file {$path}: {$error}")]
8888
pub(crate) struct FailedWritingFile<'a> {
8989
pub path: &'a Path,
9090
pub error: io::Error,

compiler/rustc_interface/src/passes.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,11 @@ pub fn write_interface<'tcx>(tcx: TyCtxt<'tcx>) {
881881
&tcx.sess.psess.attr_id_generator,
882882
);
883883
let export_output = tcx.output_filenames(()).interface_path();
884-
let mut file = fs::File::create_buffered(export_output).unwrap();
885-
if let Err(err) = write!(file, "{}", krate) {
886-
tcx.dcx().fatal(format!("error writing interface file: {}", err));
884+
let mut file = fs::File::create_buffered(&export_output).unwrap_or_else(|error| {
885+
tcx.dcx().emit_fatal(diagnostics::FailedWritingFile { path: &export_output, error })
886+
});
887+
if let Err(error) = write!(file, "{}", krate) {
888+
tcx.dcx().emit_fatal(diagnostics::FailedWritingFile { path: &export_output, error });
887889
}
888890
}
889891

compiler/rustc_lint/src/late.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
198198
}
199199

200200
fn visit_variant_data(&mut self, s: &'tcx hir::VariantData<'tcx>) {
201-
lint_callback!(self, check_struct_def, s);
202201
hir_visit::walk_struct_def(self, s);
203202
}
204203

compiler/rustc_lint/src/nonstandard_style.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
211211

212212
declare_lint! {
213213
/// The `non_snake_case` lint detects variables, methods, functions,
214-
/// lifetime parameters and modules that don't have snake case names.
214+
/// lifetime parameters, named fields and modules that don't have snake case names.
215215
///
216216
/// ### Example
217217
///
@@ -452,10 +452,8 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
452452
}
453453
}
454454

455-
fn check_struct_def(&mut self, cx: &LateContext<'_>, s: &hir::VariantData<'_>) {
456-
for sf in s.fields() {
457-
self.check_snake_case(cx, "structure field", &sf.ident);
458-
}
455+
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
456+
self.check_snake_case(cx, "structure field", &field.ident);
459457
}
460458
}
461459

compiler/rustc_lint/src/passes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ macro_rules! late_lint_methods {
3737
fn check_trait_item(a: &'tcx rustc_hir::TraitItem<'tcx>);
3838
fn check_impl_item(a: &'tcx rustc_hir::ImplItem<'tcx>);
3939
fn check_impl_item_post(a: &'tcx rustc_hir::ImplItem<'tcx>);
40-
fn check_struct_def(a: &'tcx rustc_hir::VariantData<'tcx>);
4140
fn check_field_def(a: &'tcx rustc_hir::FieldDef<'tcx>);
4241
fn check_variant(a: &'tcx rustc_hir::Variant<'tcx>);
4342
fn check_path(a: &rustc_hir::Path<'tcx>, b: rustc_hir::HirId);

compiler/rustc_metadata/src/creader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ impl CStore {
380380
flag_name,
381381
flag_name_prefixed,
382382
extern_value: extern_value.to_string(),
383+
has_extern_value: !extern_value.is_empty(),
383384
})
384385
}
385386
(Some(local_value), None) => {
@@ -390,6 +391,7 @@ impl CStore {
390391
flag_name,
391392
flag_name_prefixed,
392393
local_value: local_value.to_string(),
394+
has_local_value: !local_value.is_empty(),
393395
})
394396
}
395397
(None, None) => panic!("Incorrect target modifiers report_diff(None, None)"),

0 commit comments

Comments
 (0)