Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
842c087
Fix requires_lto targets needing lto set in cargo
Flakebi Dec 29, 2025
2c79213
field representing types: remove explicit `Send` and `Sync` impls
BennoLossin Apr 21, 2026
59f18c2
field representing types: implement Debug through reflection
BennoLossin Apr 21, 2026
f3719b1
field representing types: implement Default
BennoLossin Apr 21, 2026
104914e
field representing types: implement Hash, Eq & Ord
BennoLossin Apr 21, 2026
ca700ed
field representing types: test all implemented traits
BennoLossin Apr 21, 2026
a041a76
field representing types: add test for unsized types
BennoLossin Apr 21, 2026
4abc28f
`<Take as Read>::read_buf`: Clarify local variable name.
briansmith Apr 22, 2026
71076f2
`<Take as Read>::read_buf`: Eliminate unneeded local variables.
briansmith Apr 22, 2026
c716ce5
`<Take as Read>::read_buf`: Clarify safety comments and naming.
briansmith Apr 22, 2026
3a0a14f
`<Take as Read>::read_buf`: Don't initialize `buf` if it was already …
briansmith Apr 22, 2026
1a8d8ae
NVPTX: Drop support for old hw and old ISAs
kjetilkjeka Feb 1, 2026
5e00484
Avoid misleading closure return type note
chenyukang Apr 25, 2026
4fc64f4
Add boxing suggestions for `impl Trait` return type mismatches
Unique-Usman Apr 23, 2026
163aedc
Convert attribute `FinalizeFn` to fn pointer
JonathanBrouwer Apr 26, 2026
a677828
Add boxing suggestions for return expressions in `impl Trait` functions
Unique-Usman Apr 26, 2026
a7330f4
rustc_attr_parsing: use a `try {}` in `or_malformed`
scrabsha Apr 26, 2026
d9e227e
Fix broken logic in `incremental_verify_ich_failed`
jyn514 Apr 26, 2026
7151184
Add some debugging to `rustc_session` filename handling
jyn514 Apr 26, 2026
1fba868
Rollup merge of #149624 - Flakebi:fix-lto, r=bjorn3
JonathanBrouwer Apr 26, 2026
cb0b87c
Rollup merge of #152443 - kjetilkjeka:nvptx_drop_support_old_hw_and_i…
JonathanBrouwer Apr 26, 2026
dede06a
Rollup merge of #155317 - briansmith:b/take-opt, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
fa57a92
Rollup merge of #155588 - BennoLossin:frt-traits, r=Mark-Simulacrum
JonathanBrouwer Apr 26, 2026
615bd57
Rollup merge of #155682 - Unique-Usman:ua/box-impl, r=mejrs
JonathanBrouwer Apr 26, 2026
bb2fef2
Rollup merge of #155770 - chenyukang:yukang-fix-155670-closure-return…
JonathanBrouwer Apr 26, 2026
f537a4a
Rollup merge of #155818 - JonathanBrouwer:finalize-fn-ptr, r=mejrs
JonathanBrouwer Apr 26, 2026
d4d5439
Rollup merge of #155829 - scrabsha:push-kwlqypwmnpul, r=mejrs
JonathanBrouwer Apr 26, 2026
7e3404a
Rollup merge of #155835 - jyn514:jyn/verify-ich-diagnostics, r=wesley…
JonathanBrouwer Apr 26, 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
8 changes: 5 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ fn parse_directive_items<'p, S: Stage>(
}}

macro or_malformed($($code:tt)*) {{
let Some(ret) = (||{
Some($($code)*)
})() else {
let Some(ret) = (
try {
$($code)*
}
) else {
malformed!()
};
ret
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ pub(super) struct GroupTypeInnerAccept<S: Stage> {

pub(crate) type AcceptFn<S> =
Box<dyn for<'sess, 'a> Fn(&mut AcceptContext<'_, 'sess, S>, &ArgParser) + Send + Sync>;
pub(crate) type FinalizeFn<S> =
Box<dyn Send + Sync + Fn(&mut FinalizeContext<'_, '_, S>) -> Option<AttributeKind>>;
pub(crate) type FinalizeFn<S> = fn(&mut FinalizeContext<'_, '_, S>) -> Option<AttributeKind>;

macro_rules! attribute_parsers {
(
Expand Down Expand Up @@ -131,10 +130,10 @@ macro_rules! attribute_parsers {
}),
safety: <$names as crate::attributes::AttributeParser<$stage>>::SAFETY,
allowed_targets: <$names as crate::attributes::AttributeParser<$stage>>::ALLOWED_TARGETS,
finalizer: Box::new(|cx| {
finalizer: |cx| {
let state = STATE_OBJECT.take();
state.finalize(cx)
})
}
});
}
Entry::Occupied(_) => panic!("Attribute {path:?} has multiple accepters"),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
let mut attr_paths: Vec<RefPathParser<'_>> = Vec::new();
let mut early_parsed_state = EarlyParsedState::default();

let mut finalizers: Vec<&FinalizeFn<S>> = Vec::with_capacity(attrs.len());
let mut finalizers: Vec<FinalizeFn<S>> = Vec::with_capacity(attrs.len());

for attr in attrs {
// If we're only looking for a single attribute, skip all the ones we don't care about.
Expand Down Expand Up @@ -413,7 +413,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
};

(accept.accept_fn)(&mut cx, &args);
finalizers.push(&accept.finalizer);
finalizers.push(accept.finalizer);

if !matches!(cx.stage.should_emit(), ShouldEmit::Nothing) {
Self::check_target(&accept.allowed_targets, target, &mut cx);
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ fn print_target_cpus(sess: &Session, tm: &llvm::TargetMachine, out: &mut String)
};
let mut cpus = cpu_names
.lines()
.filter(|cpu_name| {
!sess.target.unsupported_cpus.contains(&std::borrow::Cow::Borrowed(*cpu_name))
})
.map(|cpu_name| Cpu { cpu_name, remark: make_remark(cpu_name) })
.collect::<VecDeque<_>>();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl ModuleConfig {
// `#![no_builtins]` is assumed to not participate in LTO and
// instead goes on to generate object code.
EmitObj::Bitcode
} else if need_bitcode_in_object(tcx) {
} else if need_bitcode_in_object(tcx) || sess.target.requires_lto {
EmitObj::ObjectCode(BitcodeSection::Full)
} else {
EmitObj::ObjectCode(BitcodeSection::None)
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
tcx.dcx().emit_fatal(errors::CpuRequired);
}

if let Some(target_cpu) = &tcx.sess.opts.cg.target_cpu
&& tcx.sess.target.unsupported_cpus.contains(&target_cpu.into())
{
// The target cpu is explicitly listed as an unsupported cpu
tcx.dcx().emit_fatal(errors::CpuUnsupported { target_cpu: target_cpu.clone() });
}

let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);

// Run the monomorphization collector and partition the collected items into
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ pub(crate) struct InsufficientVSCodeProduct;
#[diag("target requires explicitly specifying a cpu with `-C target-cpu`")]
pub(crate) struct CpuRequired;

#[derive(Diagnostic)]
#[diag("target cpu `{$target_cpu}` is known but unsupported")]
pub(crate) struct CpuUnsupported {
pub target_cpu: String,
}

#[derive(Diagnostic)]
#[diag("processing debug info with `dsymutil` failed: {$status}")]
#[note("{$output}")]
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,20 @@ pub fn target_spec_to_backend_features<'a>(
sess: &'a Session,
mut extend_backend_features: impl FnMut(&'a str, /* enable */ bool),
) {
// Compute implied features
let mut rust_features = vec![];

// This check handles SM versions that defaults (by LLVM) to unsupported (by Rust) PTX ISA versions.
// sm_70, sm_72 and sm_75 defaults to PTX ISA versions with major version 6, while sm_80 default to 7.0
if sess.target.arch == Arch::Nvptx64
&& matches!(
sess.opts.cg.target_cpu.as_deref(),
None | Some("sm_70") | Some("sm_72") | Some("sm_75")
)
{
rust_features.push((true, "ptx70"));
}

// Compute implied features
parse_rust_feature_list(
sess,
&sess.target.features,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,9 @@ impl<'tcx> CoerceMany<'tcx> {
// note in this case, since it would be incorrect.
&& let Some(fn_sig) = fcx.body_fn_sig()
&& fn_sig.output().is_ty_var()
&& fcx.ret_coercion.as_ref().is_some_and(|ret_coercion| {
fcx.resolve_vars_if_possible(ret_coercion.borrow().expected_ty()) == expected
})
{
err.span_note(sp, format!("return type inferred to be `{expected}` here"));
}
Expand Down
38 changes: 37 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::packed::Pu128;
use rustc_errors::{Applicability, Diag, MultiSpan, listify, msg};
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{
self as hir, Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind,
Expand All @@ -26,13 +27,14 @@ use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::{ExpnKind, Ident, MacroKind, Span, Spanned, Symbol, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::DefIdOrName;
use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use tracing::{debug, instrument};

use super::FnCtxt;
use crate::errors;
use crate::errors::{self, SuggestBoxingForReturnImplTrait};
use crate::fn_ctxt::rustc_span::BytePos;
use crate::method::probe;
use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
Expand Down Expand Up @@ -963,6 +965,40 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}

let trait_def_id = trait_ref.trait_ref.path.res.def_id();
if self.tcx.is_dyn_compatible(trait_def_id) {
err.subdiagnostic(SuggestBoxingForReturnImplTrait::ChangeReturnType {
start_sp: hir_ty.span.with_hi(hir_ty.span.lo() + BytePos(4)),
end_sp: hir_ty.span.shrink_to_hi(),
});

let body = self.tcx.hir_body_owned_by(fn_id);
let mut visitor = ReturnsVisitor::default();
visitor.visit_body(&body);

if !visitor.returns.is_empty() {
let starts: Vec<Span> = visitor
.returns
.iter()
.filter(|expr| expr.span.can_be_used_for_suggestions())
.map(|expr| expr.span.shrink_to_lo())
.collect();
let ends: Vec<Span> = visitor
.returns
.iter()
.filter(|expr| expr.span.can_be_used_for_suggestions())
.map(|expr| expr.span.shrink_to_hi())
.collect();

if !starts.is_empty() {
err.subdiagnostic(SuggestBoxingForReturnImplTrait::BoxReturnExpr {
starts,
ends,
});
}
}
}

self.try_suggest_return_impl_trait(err, expected, found, fn_id);
self.try_note_caller_chooses_ty_for_ty_param(err, expected, found);
return true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub(crate) struct Reentrant;
#[note(
"an ideal reproduction consists of the code before and some patch that then triggers the bug when applied and compiled again"
)]
#[note("as a workaround, you can run {$run_cmd} to allow your project to compile")]
#[note("as a workaround, you can {$run_cmd} to allow your project to compile")]
pub(crate) struct IncrementCompilation {
pub run_cmd: String,
pub dep_node: String,
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_middle/src/verify_ich.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::cell::Cell;

use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_session::utils::was_invoked_from_cargo;
use tracing::instrument;

use crate::dep_graph::{DepGraphData, SerializedDepNodeIndex};
Expand Down Expand Up @@ -66,10 +68,10 @@ fn incremental_verify_ich_failed<'tcx>(
if old_in_panic {
tcx.dcx().emit_err(crate::error::Reentrant);
} else {
let run_cmd = if let Some(crate_name) = &tcx.sess.opts.crate_name {
format!("`cargo clean -p {crate_name}` or `cargo clean`")
let run_cmd = if was_invoked_from_cargo() {
format!("run `cargo clean -p {}` or `cargo clean`", tcx.crate_name(LOCAL_CRATE))
} else {
"`cargo clean`".to_string()
"clean your build cache".to_owned()
};

let dep_node = tcx.dep_graph.data().unwrap().prev_node_of(prev_index);
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ impl OutputFilenames {
}

pub fn interface_path(&self) -> PathBuf {
debug!("using crate_name={} for interface_path", self.crate_stem);
self.out_directory.join(format!("lib{}.rs", self.crate_stem))
}

Expand All @@ -1214,6 +1215,7 @@ impl OutputFilenames {
let extension = flavor.extension();
match flavor {
OutputType::Metadata => {
debug!("using crate_name={} for {extension}", self.crate_stem);
self.out_directory.join(format!("lib{}.{}", self.crate_stem, extension))
}
_ => self.with_directory_and_extension(&self.out_directory, extension),
Expand Down Expand Up @@ -1288,6 +1290,7 @@ impl OutputFilenames {
}

pub fn with_directory_and_extension(&self, directory: &Path, extension: &str) -> PathBuf {
debug!("using filestem={} for {extension}", self.filestem);
let mut path = directory.join(&self.filestem);
path.set_extension(extension);
path
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl Target {
forward!(asm_args);
forward!(cpu);
forward!(need_explicit_cpu);
forward!(unsupported_cpus);
forward!(features);
forward!(dynamic_linking);
forward_opt!(direct_access_external_data);
Expand Down Expand Up @@ -320,6 +321,7 @@ impl ToJson for Target {
target_option_val!(asm_args);
target_option_val!(cpu);
target_option_val!(need_explicit_cpu);
target_option_val!(unsupported_cpus);
target_option_val!(features);
target_option_val!(dynamic_linking);
target_option_val!(direct_access_external_data);
Expand Down Expand Up @@ -543,6 +545,7 @@ struct TargetSpecJson {
asm_args: Option<StaticCow<[StaticCow<str>]>>,
cpu: Option<StaticCow<str>>,
need_explicit_cpu: Option<bool>,
unsupported_cpus: Option<StaticCow<[StaticCow<str>]>>,
features: Option<StaticCow<str>>,
dynamic_linking: Option<bool>,
direct_access_external_data: Option<bool>,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,10 @@ pub struct TargetOptions {
/// Whether a cpu needs to be explicitly set.
/// Set to true if there is no default cpu. Defaults to false.
pub need_explicit_cpu: bool,
/// A list of CPUs that are provided by LLVM but are considered unsupported by Rust.
/// These CPUs are omitted from `--print target-cpus` output and will cause an error
/// if used with `-Ctarget-cpu`.
pub unsupported_cpus: StaticCow<[StaticCow<str>]>,
/// Default (Rust) target features to enable for this target. These features
/// overwrite `-Ctarget-cpu` but can be overwritten with `-Ctarget-features`.
/// Corresponds to `llc -mattr=$llvm_features` where `$llvm_features` is the
Expand Down Expand Up @@ -2818,6 +2822,7 @@ impl Default for TargetOptions {
asm_args: cvs![],
cpu: "generic".into(),
need_explicit_cpu: false,
unsupported_cpus: cvs![],
features: "".into(),
direct_access_external_data: None,
dynamic_linking: false,
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::spec::{
Arch, LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, Os, PanicStrategy, Target,
TargetMetadata, TargetOptions,
TargetMetadata, TargetOptions, cvs,
};

pub(crate) fn target() -> Target {
Expand All @@ -22,7 +22,13 @@ pub(crate) fn target() -> Target {
linker_flavor: LinkerFlavor::Llbc,

// With `ptx-linker` approach, it can be later overridden via link flags.
cpu: "sm_30".into(),
cpu: "sm_70".into(),

// No longer supported architectures
unsupported_cpus: cvs!(
"sm_20", "sm_21", "sm_30", "sm_32", "sm_35", "sm_37", "sm_50", "sm_52", "sm_53",
"sm_60", "sm_61", "sm_62"
),

// FIXME: create tests for the atomics.
max_atomic_width: Some(64),
Expand Down
28 changes: 2 additions & 26 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,19 +536,7 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[

const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("sm_20", Unstable(sym::nvptx_target_feature), &[]),
("sm_21", Unstable(sym::nvptx_target_feature), &["sm_20"]),
("sm_30", Unstable(sym::nvptx_target_feature), &["sm_21"]),
("sm_32", Unstable(sym::nvptx_target_feature), &["sm_30"]),
("sm_35", Unstable(sym::nvptx_target_feature), &["sm_32"]),
("sm_37", Unstable(sym::nvptx_target_feature), &["sm_35"]),
("sm_50", Unstable(sym::nvptx_target_feature), &["sm_37"]),
("sm_52", Unstable(sym::nvptx_target_feature), &["sm_50"]),
("sm_53", Unstable(sym::nvptx_target_feature), &["sm_52"]),
("sm_60", Unstable(sym::nvptx_target_feature), &["sm_53"]),
("sm_61", Unstable(sym::nvptx_target_feature), &["sm_60"]),
("sm_62", Unstable(sym::nvptx_target_feature), &["sm_61"]),
("sm_70", Unstable(sym::nvptx_target_feature), &["sm_62"]),
("sm_70", Unstable(sym::nvptx_target_feature), &[]),
("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]),
("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]),
("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]),
Expand All @@ -567,19 +555,7 @@ const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
// tidy-alphabetical-end
// tidy-alphabetical-start
("ptx32", Unstable(sym::nvptx_target_feature), &[]),
("ptx40", Unstable(sym::nvptx_target_feature), &["ptx32"]),
("ptx41", Unstable(sym::nvptx_target_feature), &["ptx40"]),
("ptx42", Unstable(sym::nvptx_target_feature), &["ptx41"]),
("ptx43", Unstable(sym::nvptx_target_feature), &["ptx42"]),
("ptx50", Unstable(sym::nvptx_target_feature), &["ptx43"]),
("ptx60", Unstable(sym::nvptx_target_feature), &["ptx50"]),
("ptx61", Unstable(sym::nvptx_target_feature), &["ptx60"]),
("ptx62", Unstable(sym::nvptx_target_feature), &["ptx61"]),
("ptx63", Unstable(sym::nvptx_target_feature), &["ptx62"]),
("ptx64", Unstable(sym::nvptx_target_feature), &["ptx63"]),
("ptx65", Unstable(sym::nvptx_target_feature), &["ptx64"]),
("ptx70", Unstable(sym::nvptx_target_feature), &["ptx65"]),
("ptx70", Unstable(sym::nvptx_target_feature), &[]),
("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]),
("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]),
("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]),
Expand Down
Loading
Loading