Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3ae6901
rustc_target: callconv: powerpc64: Use the ABI set in target options …
Gelbpunkt Jan 13, 2026
168f324
rustc_target: spec: Ensure that a valid llvm_abiname value is set for…
Gelbpunkt Jan 13, 2026
c45a513
Fix ICE in const eval when using packed SIMD with non-power-of-two le…
enthropy7 Jan 25, 2026
ce4c17f
Simplify internals of `{Rc,Arc}::default`
alexcrichton Feb 13, 2026
a2699f0
Test(lib/win/proc): Skip `raw_attributes` doctest under Win7
PaulDance Oct 15, 2025
f067c75
fix typo in `carryless_mul` macro invocation
folkertdev Feb 17, 2026
6314bd7
fix(codegen): Use `body_codegen_attrs` for caller in `adjust_target_f…
TKanX Feb 19, 2026
034f7f0
test(codegen): Add regression test for issue #152340
TKanX Feb 19, 2026
c316bdf
don't use env with infer vars
lcnr Jan 29, 2026
642d9c4
modernize comments about typing modes
jdonszelmann Feb 19, 2026
fb811f8
Enable rust.remap-debuginfo in the dist profile
bjorn3 Feb 20, 2026
7df7485
Add build.rustdoc option to bootstrap config
blkerby Feb 20, 2026
6c6f586
Fix warnings in rs{begin,end}.rs files
mati865 Feb 19, 2026
d6ff921
Fixed ByteStr not padding within its Display trait when no specific a…
asder8215 Feb 19, 2026
bb2d55e
Add new `MultiSpan` methods: `push_primary_span`, `push_span_diag` an…
GuillaumeGomez Feb 21, 2026
36116e3
Create new `diag_lint_level` function, aiming to replace `lint_level`…
GuillaumeGomez Feb 21, 2026
4f23c48
Migrate `LinkerOutput` lint to `Diagnostic`
GuillaumeGomez Feb 21, 2026
223c253
remove unneeded reboxing
cyrgani Feb 21, 2026
45deeda
Rollup merge of #150468 - Gelbpunkt:rustc-target-callconv-spec-elf-ab…
jhpratt Feb 22, 2026
3191032
Rollup merge of #151628 - enthropy7:fix-simd-const-eval-ice, r=RalfJung
jhpratt Feb 22, 2026
c3adf8c
Rollup merge of #151871 - jdonszelmann:no-env-with-infer-vars, r=BoxyUwU
jhpratt Feb 22, 2026
fa77755
Rollup merge of #152591 - alexcrichton:simplify-rc-arc-default, r=joboet
jhpratt Feb 22, 2026
55725e6
Rollup merge of #152865 - asder8215:path_display, r=joboet
jhpratt Feb 22, 2026
4ebfb2d
Rollup merge of #152908 - bjorn3:dist_profile_remap_debuginfo, r=Kobzol
jhpratt Feb 22, 2026
87306a9
Rollup merge of #152705 - PaulDance:patches/skip-raw_attributes-docte…
jhpratt Feb 22, 2026
49fee8e
Rollup merge of #152767 - folkertdev:clmul-rhs-lhs, r=joboet
jhpratt Feb 22, 2026
3dd938a
Rollup merge of #152837 - TKanX:bugfix/152340-codegen-fn-attrs-const-…
jhpratt Feb 22, 2026
f947d09
Rollup merge of #152871 - mati865:fix-rs-begin-end-warnings, r=joboet
jhpratt Feb 22, 2026
9176305
Rollup merge of #152921 - blkerby:bootstrap-rustdoc-config, r=Kobzol
jhpratt Feb 22, 2026
32e607f
Rollup merge of #152933 - GuillaumeGomez:start-migrating-lintdiag, r=…
jhpratt Feb 22, 2026
cd667c5
Rollup merge of #152937 - cyrgani:box-box, r=JonathanBrouwer
jhpratt Feb 22, 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
5 changes: 5 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@
# If you set this, you likely want to set `cargo` as well.
#build.rustc = "/path/to/rustc"

# Use this rustdoc binary as the stage0 snapshot rustdoc.
# If unspecified, then the binary "rustdoc" (with platform-specific extension, e.g. ".exe")
# in the same directory as "rustc" will be used.
#build.rustdoc = "/path/to/rustdoc"

# Instead of downloading the src/stage0 version of rustfmt specified,
# use this rustfmt binary instead as the stage0 snapshot rustfmt.
#build.rustfmt = "/path/to/rustfmt"
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4211,9 +4211,7 @@ impl ForeignItemKind {
impl From<ForeignItemKind> for ItemKind {
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
match foreign_item_kind {
ForeignItemKind::Static(box static_foreign_item) => {
ItemKind::Static(Box::new(static_foreign_item))
}
ForeignItemKind::Static(static_foreign_item) => ItemKind::Static(static_foreign_item),
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
ForeignItemKind::MacCall(a) => ItemKind::MacCall(a),
Expand All @@ -4226,7 +4224,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {

fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
Ok(match item_kind {
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
ItemKind::Static(static_item) => ForeignItemKind::Static(static_item),
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ use rustc_attr_parsing::eval_config_entry;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, LintDiagnostic};
use rustc_errors::DiagCtxtHandle;
use rustc_fs_util::{TempDirBuilder, fix_windows_verbatim_for_gcc, try_canonicalize};
use rustc_hir::attrs::NativeLibKind;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_macros::LintDiagnostic;
use rustc_macros::Diagnostic;
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
use rustc_metadata::{
EncodedMetadata, NativeLibSearchFallback, find_native_static_library,
walk_native_lib_search_dirs,
};
use rustc_middle::bug;
use rustc_middle::lint::lint_level;
use rustc_middle::lint::diag_lint_level;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
Expand Down Expand Up @@ -662,7 +662,7 @@ fn link_dwarf_object(sess: &Session, cg_results: &CodegenResults, executable_out
}
}

#[derive(LintDiagnostic)]
#[derive(Diagnostic)]
#[diag("{$inner}")]
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
/// end up with inconsistent languages within the same diagnostic.
Expand Down Expand Up @@ -938,9 +938,7 @@ fn link_natively(

let level = codegen_results.crate_info.lint_levels.linker_messages;
let lint = |msg| {
lint_level(sess, LINKER_MESSAGES, level, None, |diag| {
LinkerOutput { inner: msg }.decorate_lint(diag)
})
diag_lint_level(sess, LINKER_MESSAGES, level, None, LinkerOutput { inner: msg });
};

if !prog.stderr.is_empty() {
Expand Down
16 changes: 14 additions & 2 deletions compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use either::Either;
use rustc_abi::{BackendRepr, Endian};
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_apfloat::{Float, Round};
use rustc_data_structures::assert_matches;
use rustc_middle::mir::interpret::{InterpErrorKind, Pointer, UndefinedBehaviorInfo};
use rustc_middle::ty::{FloatTy, ScalarInt, SimdAlign};
use rustc_middle::{bug, err_ub_format, mir, span_bug, throw_unsup_format, ty};
Expand Down Expand Up @@ -838,7 +837,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
vector_layout: TyAndLayout<'tcx>,
alignment: SimdAlign,
) -> InterpResult<'tcx> {
assert_matches!(vector_layout.backend_repr, BackendRepr::SimdVector { .. });
// Packed SIMD types with non-power-of-two element counts use BackendRepr::Memory
// instead of BackendRepr::SimdVector. We need to handle both cases.
// FIXME: remove the BackendRepr::Memory case when SIMD vectors are always passed as BackendRepr::SimdVector.
assert!(vector_layout.ty.is_simd(), "check_simd_ptr_alignment called on non-SIMD type");
match vector_layout.backend_repr {
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => {}
_ => {
span_bug!(
self.cur_span(),
"SIMD type has unexpected backend_repr: {:?}",
vector_layout.backend_repr
);
}
}

let align = match alignment {
ty::SimdAlign::Unaligned => {
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,18 @@ impl MultiSpan {
MultiSpan { primary_spans: vec, span_labels: vec![] }
}

pub fn push_primary_span(&mut self, primary_span: Span) {
self.primary_spans.push(primary_span);
}

pub fn push_span_label(&mut self, span: Span, label: impl Into<DiagMessage>) {
self.span_labels.push((span, label.into()));
}

pub fn push_span_diag(&mut self, span: Span, diag: DiagMessage) {
self.span_labels.push((span, diag));
}

/// Selects the first primary span (if any).
pub fn primary_span(&self) -> Option<Span> {
self.primary_spans.first().cloned()
Expand Down Expand Up @@ -179,6 +187,11 @@ impl MultiSpan {
span_labels
}

/// Returns the span labels as contained by `MultiSpan`.
pub fn span_labels_raw(&self) -> &[(Span, DiagMessage)] {
&self.span_labels
}

/// Returns `true` if any of the span labels is displayable.
pub fn has_span_labels(&self) -> bool {
self.span_labels.iter().any(|(sp, _)| !sp.is_dummy())
Expand Down
204 changes: 203 additions & 1 deletion compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cmp;

use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_errors::{Diag, MultiSpan};
use rustc_errors::{Diag, Diagnostic, MultiSpan};
use rustc_hir::{HirId, ItemLocalId};
use rustc_lint_defs::EditionFcw;
use rustc_macros::{Decodable, Encodable, HashStable};
Expand Down Expand Up @@ -482,3 +482,205 @@ pub fn lint_level(
}
lint_level_impl(sess, lint, level, span, Box::new(decorate))
}

/// The innermost function for emitting lints implementing the [`trait@Diagnostic`] trait.
///
/// If you are looking to implement a lint, look for higher level functions,
/// for example:
///
/// - [`TyCtxt::emit_node_span_lint`]
/// - [`TyCtxt::node_span_lint`]
/// - [`TyCtxt::emit_node_lint`]
/// - [`TyCtxt::node_lint`]
/// - `LintContext::opt_span_lint`
///
/// This function will replace `lint_level` once all `LintDiagnostic` items have been migrated to
/// `Diagnostic`.
#[track_caller]
pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>(
sess: &'a Session,
lint: &'static Lint,
level: LevelAndSource,
span: Option<MultiSpan>,
decorate: D,
) {
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
// the "real" work.
#[track_caller]
fn diag_lint_level_impl<'a>(
sess: &'a Session,
lint: &'static Lint,
level: LevelAndSource,
span: Option<MultiSpan>,
decorate: Box<
dyn FnOnce(rustc_errors::DiagCtxtHandle<'a>, rustc_errors::Level) -> Diag<'a, ()> + 'a,
>,
) {
let LevelAndSource { level, lint_id, src } = level;

// Check for future incompatibility lints and issue a stronger warning.
let future_incompatible = lint.future_incompatible;

let has_future_breakage = future_incompatible.map_or(
// Default allow lints trigger too often for testing.
sess.opts.unstable_opts.future_incompat_test && lint.default_level != Level::Allow,
|incompat| incompat.report_in_deps,
);

// Convert lint level to error level.
let err_level = match level {
Level::Allow => {
if has_future_breakage {
rustc_errors::Level::Allow
} else {
return;
}
}
Level::Expect => {
// This case is special as we actually allow the lint itself in this context, but
// we can't return early like in the case for `Level::Allow` because we still
// need the lint diagnostic to be emitted to `rustc_error::DiagCtxtInner`.
//
// We can also not mark the lint expectation as fulfilled here right away, as it
// can still be cancelled in the decorate function. All of this means that we simply
// create a `Diag` and continue as we would for warnings.
rustc_errors::Level::Expect
}
Level::ForceWarn => rustc_errors::Level::ForceWarning,
Level::Warn => rustc_errors::Level::Warning,
Level::Deny | Level::Forbid => rustc_errors::Level::Error,
};
// Finally, run `decorate`. `decorate` can call `trimmed_path_str` (directly or indirectly),
// so we need to make sure when we do call `decorate` that the diagnostic is eventually
// emitted or we'll get a `must_produce_diag` ICE.
//
// When is a diagnostic *eventually* emitted? Well, that is determined by 2 factors:
// 1. If the corresponding `rustc_errors::Level` is beyond warning, i.e. `ForceWarning(_)`
// or `Error`, then the diagnostic will be emitted regardless of CLI options.
// 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by
// `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic
// will be emitted if `can_emit_warnings` is true.
let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings();

let disable_suggestions = if let Some(ref span) = span
// If this code originates in a foreign macro, aka something that this crate
// did not itself author, then it's likely that there's nothing this crate
// can do about it. We probably want to skip the lint entirely.
&& span.primary_spans().iter().any(|s| s.in_external_macro(sess.source_map()))
{
true
} else {
false
};

let mut err: Diag<'_, ()> = if !skip {
decorate(sess.dcx(), err_level)
} else {
Diag::new(sess.dcx(), err_level, "")
};
if let Some(span) = span
&& err.span.primary_span().is_none()
{
// We can't use `err.span()` because it overwrites the labels, so we need to do it manually.
for primary in span.primary_spans() {
err.span.push_primary_span(*primary);
}
for (label_span, label) in span.span_labels_raw() {
err.span.push_span_diag(*label_span, label.clone());
}
}
if let Some(lint_id) = lint_id {
err.lint_id(lint_id);
}

if disable_suggestions {
// Any suggestions made here are likely to be incorrect, so anything we
// emit shouldn't be automatically fixed by rustfix.
err.disable_suggestions();

// If this is a future incompatible that is not an edition fixing lint
// it'll become a hard error, so we have to emit *something*. Also,
// if this lint occurs in the expansion of a macro from an external crate,
// allow individual lints to opt-out from being reported.
let incompatible = future_incompatible.is_some_and(|f| f.reason.edition().is_none());

if !incompatible && !lint.report_in_external_macro {
err.cancel();

// Don't continue further, since we don't want to have
// `diag_span_note_once` called for a diagnostic that isn't emitted.
return;
}
}

err.is_lint(lint.name_lower(), has_future_breakage);
// Lint diagnostics that are covered by the expect level will not be emitted outside
// the compiler. It is therefore not necessary to add any information for the user.
// This will therefore directly call the decorate function which will in turn emit
// the diagnostic.
if let Level::Expect = level {
err.emit();
return;
}

if let Some(future_incompatible) = future_incompatible {
let explanation = match future_incompatible.reason {
FutureIncompatibilityReason::FutureReleaseError(_) => {
"this was previously accepted by the compiler but is being phased out; \
it will become a hard error in a future release!"
.to_owned()
}
FutureIncompatibilityReason::FutureReleaseSemanticsChange(_) => {
"this will change its meaning in a future release!".to_owned()
}
FutureIncompatibilityReason::EditionError(EditionFcw { edition, .. }) => {
let current_edition = sess.edition();
format!(
"this is accepted in the current edition (Rust {current_edition}) but is a hard error in Rust {edition}!"
)
}
FutureIncompatibilityReason::EditionSemanticsChange(EditionFcw {
edition, ..
}) => {
format!("this changes meaning in Rust {edition}")
}
FutureIncompatibilityReason::EditionAndFutureReleaseError(EditionFcw {
edition,
..
}) => {
format!(
"this was previously accepted by the compiler but is being phased out; \
it will become a hard error in Rust {edition} and in a future release in all editions!"
)
}
FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(
EditionFcw { edition, .. },
) => {
format!(
"this changes meaning in Rust {edition} and in a future release in all editions!"
)
}
FutureIncompatibilityReason::Custom(reason, _) => reason.to_owned(),
FutureIncompatibilityReason::Unreachable => unreachable!(),
};

if future_incompatible.explain_reason {
err.warn(explanation);
}

let citation =
format!("for more information, see {}", future_incompatible.reason.reference());
err.note(citation);
}

explain_lint_level_source(sess, lint, level, src, &mut err);
err.emit();
}
diag_lint_level_impl(
sess,
lint,
level,
span,
Box::new(move |dcx, level| decorate.into_diag(dcx, level)),
);
}
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,8 @@ impl<'tcx> TyCtxt<'tcx> {
caller: DefId,
) -> Option<ty::Binder<'tcx, ty::FnSig<'tcx>>> {
let fun_features = &self.codegen_fn_attrs(fun_def).target_features;
let callee_features = &self.codegen_fn_attrs(caller).target_features;
if self.is_target_feature_call_safe(&fun_features, &callee_features) {
let caller_features = &self.body_codegen_attrs(caller).target_features;
if self.is_target_feature_call_safe(&fun_features, &caller_features) {
return Some(fun_sig.map_bound(|sig| ty::FnSig { safety: hir::Safety::Safe, ..sig }));
}
None
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_target/src/callconv/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};

use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::spec::{Env, HasTargetSpec, Os};
use crate::spec::{Abi, HasTargetSpec, Os};

#[derive(Debug, Clone, Copy, PartialEq)]
enum ABI {
Expand Down Expand Up @@ -106,8 +106,10 @@ where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,
{
let abi = if cx.target_spec().env == Env::Musl || cx.target_spec().os == Os::FreeBsd {
let abi = if cx.target_spec().options.abi == Abi::ElfV2 {
ELFv2
} else if cx.target_spec().options.abi == Abi::ElfV1 {
ELFv1
} else if cx.target_spec().os == Os::Aix {
AIX
} else {
Expand Down
Loading
Loading