Skip to content

Commit 781e41e

Browse files
committed
Auto merge of #145031 - tgross35:rollup-xy21d76, r=tgross35
Rollup of 7 pull requests Successful merges: - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143807 (Pass -Werror when building the LLVM wrapper) - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny) - #144601 (Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`) - #144682 (Stabilize `strict_overflow_ops`) - #145026 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 61cb1e9 + bed8472 commit 781e41e

File tree

35 files changed

+532
-184
lines changed

35 files changed

+532
-184
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
262262
// Filter out features that are not supported by the current LLVM version
263263
("aarch64", "fpmr") => None, // only existed in 18
264264
("arm", "fp16") => Some(LLVMFeature::new("fullfp16")),
265+
// NVPTX targets added in LLVM 20
266+
("nvptx64", "sm_100") if get_version().0 < 20 => None,
267+
("nvptx64", "sm_100a") if get_version().0 < 20 => None,
268+
("nvptx64", "sm_101") if get_version().0 < 20 => None,
269+
("nvptx64", "sm_101a") if get_version().0 < 20 => None,
270+
("nvptx64", "sm_120") if get_version().0 < 20 => None,
271+
("nvptx64", "sm_120a") if get_version().0 < 20 => None,
272+
("nvptx64", "ptx86") if get_version().0 < 20 => None,
273+
("nvptx64", "ptx87") if get_version().0 < 20 => None,
265274
// Filter out features that are not supported by the current LLVM version
266275
("loongarch64", "div32" | "lam-bh" | "lamcas" | "ld-seq-sa" | "scq")
267276
if get_version().0 < 20 =>
@@ -324,15 +333,12 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
324333
///
325334
/// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled outside codegen.
326335
pub(crate) fn target_config(sess: &Session) -> TargetConfig {
327-
// Add base features for the target.
328-
// We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below.
329-
// The reason is that if LLVM considers a feature implied but we do not, we don't want that to
330-
// show up in `cfg`. That way, `cfg` is entirely under our control -- except for the handling of
331-
// the target CPU, that is still expanded to target features (with all their implied features)
332-
// by LLVM.
333336
let target_machine = create_informational_target_machine(sess, true);
334337

335338
let (unstable_target_features, target_features) = cfg_target_feature(sess, |feature| {
339+
// This closure determines whether the target CPU has the feature according to LLVM. We do
340+
// *not* consider the `-Ctarget-feature`s here, as that will be handled later in
341+
// `cfg_target_feature`.
336342
if let Some(feat) = to_llvm_features(sess, feature) {
337343
// All the LLVM features this expands to must be enabled.
338344
for llvm_feature in feat {

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ fn parse_rust_feature_flag<'a>(
197197
/// 2nd component of the return value, respectively).
198198
///
199199
/// `target_base_has_feature` should check whether the given feature (a Rust feature name!) is
200-
/// enabled in the "base" target machine, i.e., without applying `-Ctarget-feature`.
200+
/// enabled in the "base" target machine, i.e., without applying `-Ctarget-feature`. Note that LLVM
201+
/// may consider features to be implied that we do not and vice-versa. We want `cfg` to be entirely
202+
/// consistent with Rust feature implications, and thus only consult LLVM to expand the target CPU
203+
/// to target features.
201204
///
202205
/// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled elsewhere.
203206
pub fn cfg_target_feature(
@@ -211,7 +214,15 @@ pub fn cfg_target_feature(
211214
.rust_target_features()
212215
.iter()
213216
.filter(|(feature, _, _)| target_base_has_feature(feature))
214-
.map(|(feature, _, _)| Symbol::intern(feature))
217+
.flat_map(|(base_feature, _, _)| {
218+
// Expand the direct base feature into all transitively-implied features. Note that we
219+
// cannot simply use the `implied` field of the tuple since that only contains
220+
// directly-implied features.
221+
//
222+
// Iteration order is irrelevant because we're collecting into an `UnordSet`.
223+
#[allow(rustc::potential_query_instability)]
224+
sess.target.implied_target_features(base_feature).into_iter().map(|f| Symbol::intern(f))
225+
})
215226
.collect();
216227

217228
// Add enabled and remove disabled features.

compiler/rustc_const_eval/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
4+
#![cfg_attr(bootstrap, feature(strict_overflow_ops))]
45
#![doc(rust_logo)]
56
#![feature(array_try_map)]
67
#![feature(assert_matches)]
@@ -10,7 +11,6 @@
1011
#![feature(never_type)]
1112
#![feature(rustdoc_internals)]
1213
#![feature(slice_ptr_get)]
13-
#![feature(strict_overflow_ops)]
1414
#![feature(trait_alias)]
1515
#![feature(try_blocks)]
1616
#![feature(unqualified_local_imports)]

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ declare_features! (
327327
(unstable, m68k_target_feature, "1.85.0", Some(134328)),
328328
(unstable, mips_target_feature, "1.27.0", Some(44839)),
329329
(unstable, movrs_target_feature, "1.88.0", Some(137976)),
330+
(unstable, nvptx_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
330331
(unstable, powerpc_target_feature, "1.27.0", Some(44839)),
331332
(unstable, prfchw_target_feature, "1.78.0", Some(44839)),
332333
(unstable, riscv_target_feature, "1.45.0", Some(44839)),

compiler/rustc_lint/src/lifetime_syntax.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ fn emit_mismatch_diagnostic<'tcx>(
434434
lints::MismatchedLifetimeSyntaxesSuggestion::Mixed {
435435
implicit_suggestions,
436436
explicit_anonymous_suggestions,
437-
tool_only: false,
437+
optional_alternative: false,
438438
}
439439
});
440440

@@ -455,7 +455,10 @@ fn emit_mismatch_diagnostic<'tcx>(
455455
let implicit_suggestion = should_suggest_implicit.then(|| {
456456
let suggestions = make_implicit_suggestions(&suggest_change_to_implicit);
457457

458-
lints::MismatchedLifetimeSyntaxesSuggestion::Implicit { suggestions, tool_only: false }
458+
lints::MismatchedLifetimeSyntaxesSuggestion::Implicit {
459+
suggestions,
460+
optional_alternative: false,
461+
}
459462
});
460463

461464
tracing::debug!(
@@ -508,7 +511,7 @@ fn build_mismatch_suggestion(
508511
lints::MismatchedLifetimeSyntaxesSuggestion::Explicit {
509512
lifetime_name,
510513
suggestions,
511-
tool_only: false,
514+
optional_alternative: false,
512515
}
513516
}
514517

compiler/rustc_lint/src/lints.rs

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,7 +3292,7 @@ impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for MismatchedLifetimeSynta
32923292
diag.subdiagnostic(s);
32933293

32943294
for mut s in suggestions {
3295-
s.make_tool_only();
3295+
s.make_optional_alternative();
32963296
diag.subdiagnostic(s);
32973297
}
32983298
}
@@ -3303,56 +3303,74 @@ impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for MismatchedLifetimeSynta
33033303
pub(crate) enum MismatchedLifetimeSyntaxesSuggestion {
33043304
Implicit {
33053305
suggestions: Vec<Span>,
3306-
tool_only: bool,
3306+
optional_alternative: bool,
33073307
},
33083308

33093309
Mixed {
33103310
implicit_suggestions: Vec<Span>,
33113311
explicit_anonymous_suggestions: Vec<(Span, String)>,
3312-
tool_only: bool,
3312+
optional_alternative: bool,
33133313
},
33143314

33153315
Explicit {
33163316
lifetime_name: String,
33173317
suggestions: Vec<(Span, String)>,
3318-
tool_only: bool,
3318+
optional_alternative: bool,
33193319
},
33203320
}
33213321

33223322
impl MismatchedLifetimeSyntaxesSuggestion {
3323-
fn make_tool_only(&mut self) {
3323+
fn make_optional_alternative(&mut self) {
33243324
use MismatchedLifetimeSyntaxesSuggestion::*;
33253325

3326-
let tool_only = match self {
3327-
Implicit { tool_only, .. } | Mixed { tool_only, .. } | Explicit { tool_only, .. } => {
3328-
tool_only
3329-
}
3326+
let optional_alternative = match self {
3327+
Implicit { optional_alternative, .. }
3328+
| Mixed { optional_alternative, .. }
3329+
| Explicit { optional_alternative, .. } => optional_alternative,
33303330
};
33313331

3332-
*tool_only = true;
3332+
*optional_alternative = true;
33333333
}
33343334
}
33353335

33363336
impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
33373337
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
33383338
use MismatchedLifetimeSyntaxesSuggestion::*;
33393339

3340-
let style = |tool_only| {
3341-
if tool_only { SuggestionStyle::CompletelyHidden } else { SuggestionStyle::ShowAlways }
3340+
let style = |optional_alternative| {
3341+
if optional_alternative {
3342+
SuggestionStyle::CompletelyHidden
3343+
} else {
3344+
SuggestionStyle::ShowAlways
3345+
}
3346+
};
3347+
3348+
let applicability = |optional_alternative| {
3349+
// `cargo fix` can't handle more than one fix for the same issue,
3350+
// so hide alternative suggestions from it by marking them as maybe-incorrect
3351+
if optional_alternative {
3352+
Applicability::MaybeIncorrect
3353+
} else {
3354+
Applicability::MachineApplicable
3355+
}
33423356
};
33433357

33443358
match self {
3345-
Implicit { suggestions, tool_only } => {
3359+
Implicit { suggestions, optional_alternative } => {
33463360
let suggestions = suggestions.into_iter().map(|s| (s, String::new())).collect();
33473361
diag.multipart_suggestion_with_style(
33483362
fluent::lint_mismatched_lifetime_syntaxes_suggestion_implicit,
33493363
suggestions,
3350-
Applicability::MaybeIncorrect,
3351-
style(tool_only),
3364+
applicability(optional_alternative),
3365+
style(optional_alternative),
33523366
);
33533367
}
33543368

3355-
Mixed { implicit_suggestions, explicit_anonymous_suggestions, tool_only } => {
3369+
Mixed {
3370+
implicit_suggestions,
3371+
explicit_anonymous_suggestions,
3372+
optional_alternative,
3373+
} => {
33563374
let message = if implicit_suggestions.is_empty() {
33573375
fluent::lint_mismatched_lifetime_syntaxes_suggestion_mixed_only_paths
33583376
} else {
@@ -3368,12 +3386,12 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
33683386
diag.multipart_suggestion_with_style(
33693387
message,
33703388
suggestions,
3371-
Applicability::MaybeIncorrect,
3372-
style(tool_only),
3389+
applicability(optional_alternative),
3390+
style(optional_alternative),
33733391
);
33743392
}
33753393

3376-
Explicit { lifetime_name, suggestions, tool_only } => {
3394+
Explicit { lifetime_name, suggestions, optional_alternative } => {
33773395
diag.arg("lifetime_name", lifetime_name);
33783396
let msg = diag.eagerly_translate(
33793397
fluent::lint_mismatched_lifetime_syntaxes_suggestion_explicit,
@@ -3382,8 +3400,8 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
33823400
diag.multipart_suggestion_with_style(
33833401
msg,
33843402
suggestions,
3385-
Applicability::MaybeIncorrect,
3386-
style(tool_only),
3403+
applicability(optional_alternative),
3404+
style(optional_alternative),
33873405
);
33883406
}
33893407
}

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,7 @@ declare_lint! {
28392839
/// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
28402840
/// [future-incompatible]: ../index.md#future-incompatible-lints
28412841
pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2842-
Warn,
2842+
Deny,
28432843
"trailing semicolon in macro body used as expression",
28442844
@future_incompatible = FutureIncompatibleInfo {
28452845
reason: FutureIncompatibilityReason::FutureReleaseError,

compiler/rustc_llvm/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ fn main() {
171171
let cxxflags = output(&mut cmd);
172172
let mut cfg = cc::Build::new();
173173
cfg.warnings(false);
174+
175+
// Prevent critical warnings when we're compiling from rust-lang/rust CI
176+
if std::env::var_os("CI").is_some() {
177+
cfg.warnings_into_errors(true);
178+
}
174179
for flag in cxxflags.split_whitespace() {
175180
// Ignore flags like `-m64` when we're doing a cross build
176181
if is_crossed && flag.starts_with("-m") {

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ symbols! {
15121512
not,
15131513
notable_trait,
15141514
note,
1515+
nvptx_target_feature,
15151516
object_safe_for_dispatch,
15161517
of,
15171518
off,

compiler/rustc_target/src/target_features.rs

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,71 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
517517
// tidy-alphabetical-end
518518
];
519519

520+
const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
521+
// tidy-alphabetical-start
522+
("sm_20", Unstable(sym::nvptx_target_feature), &[]),
523+
("sm_21", Unstable(sym::nvptx_target_feature), &["sm_20"]),
524+
("sm_30", Unstable(sym::nvptx_target_feature), &["sm_21"]),
525+
("sm_32", Unstable(sym::nvptx_target_feature), &["sm_30"]),
526+
("sm_35", Unstable(sym::nvptx_target_feature), &["sm_32"]),
527+
("sm_37", Unstable(sym::nvptx_target_feature), &["sm_35"]),
528+
("sm_50", Unstable(sym::nvptx_target_feature), &["sm_37"]),
529+
("sm_52", Unstable(sym::nvptx_target_feature), &["sm_50"]),
530+
("sm_53", Unstable(sym::nvptx_target_feature), &["sm_52"]),
531+
("sm_60", Unstable(sym::nvptx_target_feature), &["sm_53"]),
532+
("sm_61", Unstable(sym::nvptx_target_feature), &["sm_60"]),
533+
("sm_62", Unstable(sym::nvptx_target_feature), &["sm_61"]),
534+
("sm_70", Unstable(sym::nvptx_target_feature), &["sm_62"]),
535+
("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
536+
("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
537+
("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
538+
("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]),
539+
("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]),
540+
("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]),
541+
("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]),
542+
("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]),
543+
// tidy-alphabetical-end
544+
// tidy-alphabetical-start
545+
("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]),
546+
("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
547+
("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]),
548+
("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
549+
("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]),
550+
("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
551+
// tidy-alphabetical-end
552+
// tidy-alphabetical-start
553+
("ptx32", Unstable(sym::nvptx_target_feature), &[]),
554+
("ptx40", Unstable(sym::nvptx_target_feature), &["ptx32"]),
555+
("ptx41", Unstable(sym::nvptx_target_feature), &["ptx40"]),
556+
("ptx42", Unstable(sym::nvptx_target_feature), &["ptx41"]),
557+
("ptx43", Unstable(sym::nvptx_target_feature), &["ptx42"]),
558+
("ptx50", Unstable(sym::nvptx_target_feature), &["ptx43"]),
559+
("ptx60", Unstable(sym::nvptx_target_feature), &["ptx50"]),
560+
("ptx61", Unstable(sym::nvptx_target_feature), &["ptx60"]),
561+
("ptx62", Unstable(sym::nvptx_target_feature), &["ptx61"]),
562+
("ptx63", Unstable(sym::nvptx_target_feature), &["ptx62"]),
563+
("ptx64", Unstable(sym::nvptx_target_feature), &["ptx63"]),
564+
("ptx65", Unstable(sym::nvptx_target_feature), &["ptx64"]),
565+
("ptx70", Unstable(sym::nvptx_target_feature), &["ptx65"]),
566+
("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
567+
("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
568+
("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
569+
("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]),
570+
("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]),
571+
("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]),
572+
("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]),
573+
("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]),
574+
("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]),
575+
("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]),
576+
("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]),
577+
("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]),
578+
("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]),
579+
("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]),
580+
("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]),
581+
("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]),
582+
// tidy-alphabetical-end
583+
];
584+
520585
static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
521586
// tidy-alphabetical-start
522587
("a", Stable, &["zaamo", "zalrsc"]),
@@ -782,6 +847,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
782847
.chain(HEXAGON_FEATURES.iter())
783848
.chain(POWERPC_FEATURES.iter())
784849
.chain(MIPS_FEATURES.iter())
850+
.chain(NVPTX_FEATURES.iter())
785851
.chain(RISCV_FEATURES.iter())
786852
.chain(WASM_FEATURES.iter())
787853
.chain(BPF_FEATURES.iter())
@@ -847,6 +913,7 @@ impl Target {
847913
"x86" | "x86_64" => X86_FEATURES,
848914
"hexagon" => HEXAGON_FEATURES,
849915
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES,
916+
"nvptx64" => NVPTX_FEATURES,
850917
"powerpc" | "powerpc64" => POWERPC_FEATURES,
851918
"riscv32" | "riscv64" => RISCV_FEATURES,
852919
"wasm32" | "wasm64" => WASM_FEATURES,
@@ -873,7 +940,7 @@ impl Target {
873940
"sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI,
874941
"hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI,
875942
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI,
876-
"bpf" | "m68k" => &[], // no vector ABI
943+
"nvptx64" | "bpf" | "m68k" => &[], // no vector ABI
877944
"csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI,
878945
// FIXME: for some tier3 targets, we are overly cautious and always give warnings
879946
// when passing args in vector registers.

0 commit comments

Comments
 (0)