Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5088b38
Stabilize maybe_uninit_write_slice
thaliaarchi Oct 22, 2025
c56dc42
std: split up the `thread` module (preparation)
joboet Nov 9, 2025
616ff28
std: split up the `thread` module
joboet Nov 9, 2025
e2dff9e
update references to thread implementation in tests
joboet Nov 9, 2025
693055f
std: update broken links in `thread` module
joboet Nov 9, 2025
b6a6f00
Add Command::get_env_clear
schneems Nov 19, 2025
1223f5c
Resolve to a concrete impl instead of using fuzzy search
oli-obk Nov 6, 2025
9a8dc7e
Replace uses of 'CHECK: br' and 'CHECK-NOT: br' with 'br {{.*}}'.
zachs18 Nov 21, 2025
238ef54
Add tidy check to forbid 'CHECK: br' and 'CHECK-NOT: br' in new codeg…
zachs18 Nov 21, 2025
b5164c0
Fix typo and clarify bootstrap change tracker entry
yotamofek Nov 23, 2025
8b87b25
intrinsics: clarify float min/max behavios for NaNs and signed zeros
RalfJung Nov 23, 2025
15290fa
add NaN examples to public min/max functions
RalfJung Nov 24, 2025
699184b
implement and test `Iterator::{exactly_one, collect_array}`
jdonszelmann Nov 24, 2025
7f89192
num: Implement `uint_gather_scatter_bits` feature for unsigned integers
okaneco Nov 19, 2025
f201752
fixup warnings around the compiler
jdonszelmann Nov 24, 2025
3faad7c
Suggest _bytes versions of endian-converting methods
kornelski Nov 25, 2025
e1a805a
Motor OS: make decode_error_kind more comprehensive
lasiotus Nov 25, 2025
9352610
rustdoc: add regression test for #140968
lolbinarycat Nov 25, 2025
48bd321
fix
asukaminato0721 Nov 25, 2025
9218298
Add a diagnostic attribute for special casing const bound errors for …
oli-obk Nov 6, 2025
3a91d34
bootstrap: Miri now handles jemalloc like everything else
RalfJung Nov 25, 2025
29639e3
use string
asukaminato0721 Nov 26, 2025
e49f961
Fix typo in comment.
m-ou-se Nov 26, 2025
941a17a
Relocate 5 tests from tests/ui/issues
reddevilmidzy Nov 26, 2025
4af0b97
Warn about build.description compatibility issues
anishamahuli Nov 26, 2025
9a48fb6
optimize slice::Iter::next_chunk
bend-n Nov 20, 2025
4408573
Enable CI download for windows-gnullvm
mati865 Nov 26, 2025
17f1fcf
Rollup merge of #148048 - thaliaarchi:stabilize-maybeuninit-write-sli…
Zalathar Nov 26, 2025
48037a4
Rollup merge of #148641 - oli-obk:push-olzwqxsmnxmz, r=jackh726
Zalathar Nov 26, 2025
da75bfd
Rollup merge of #148765 - joboet:split-up-thread, r=ChrisDenton
Zalathar Nov 26, 2025
883de92
Rollup merge of #149074 - schneems:schneems/get_env_clear, r=Mark-Sim…
Zalathar Nov 26, 2025
d7a80db
Rollup merge of #149097 - okaneco:gather_scatter_bits, r=Mark-Simulacrum
Zalathar Nov 26, 2025
2be613c
Rollup merge of #149131 - bend-n:optimize_slice_iter_next_chunk, r=Ma…
Zalathar Nov 26, 2025
505e396
Rollup merge of #149190 - zachs18:chilly, r=Mark-Simulacrum
Zalathar Nov 26, 2025
0cfa02a
Rollup merge of #149239 - RalfJung:float-intrinsics, r=tgross35
Zalathar Nov 26, 2025
97ac62a
Rollup merge of #149243 - yotamofek:pr/change_tracker_typo, r=Mark-Si…
Zalathar Nov 26, 2025
32db637
Rollup merge of #149270 - jdonszelmann:exact-length-collection, r=Mar…
Zalathar Nov 26, 2025
3cdc89b
Rollup merge of #149295 - kornelski:endian_bytes, r=Mark-Simulacrum
Zalathar Nov 26, 2025
a4ff04f
Rollup merge of #149301 - moturus:main, r=Mark-Simulacrum
Zalathar Nov 26, 2025
775da27
Rollup merge of #149306 - RalfJung:bootstra-miri-jemalloc, r=Kobzol
Zalathar Nov 26, 2025
237984f
Rollup merge of #149325 - lolbinarycat:rustdoc-alias-sort-140968, r=G…
Zalathar Nov 26, 2025
2a391e9
Rollup merge of #149332 - asukaminato0721:149324, r=GuillaumeGomez
Zalathar Nov 26, 2025
5931454
Rollup merge of #149349 - m-ou-se:fmt-arg-comment-typo, r=Mark-Simula…
Zalathar Nov 26, 2025
fe6d4b8
Rollup merge of #149353 - reddevilmidzy:t3, r=Kivooeo
Zalathar Nov 26, 2025
52dd3dd
Rollup merge of #149355 - anishamahuli:anishamahuli-issue-103557, r=M…
Zalathar Nov 26, 2025
971bd20
Rollup merge of #149360 - mati865:push-rnmttvktztwp, r=Mark-Simulacrum
Zalathar Nov 26, 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
5 changes: 5 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@
# which is also used in places like debuginfo `DW_AT_producer`. This may be useful for
# supplementary build information, like distro-specific package versions.
#
# IMPORTANT: Changing this value changes crate IDs and symbol name mangling, making
# compiled artifacts incompatible. PGO profiles cannot be reused across different
# descriptions, and incremental compilation caches are invalidated. Keep this value
# consistent when reusing build artifacts.
#
# The Rust compiler will differentiate between versions of itself, including
# based on this string, which means that if you wish to be compatible with
# upstream Rust you need to set this to "". However, note that if you set this to "" but
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ impl MetadataLoader for DefaultMetadataLoader {
format!("failed to parse aix dylib '{}': {}", path.display(), e)
})?;

match archive.members().exactly_one() {
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
match Itertools::exactly_one(archive.members()) {
Ok(lib) => {
let lib = lib.map_err(|e| {
format!("failed to parse aix dylib '{}': {}", path.display(), e)
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ enum MulAddType {

#[derive(Copy, Clone)]
pub(crate) enum MinMax {
/// The IEEE `Minimum` operation - see `f32::minimum` etc
/// The IEEE-2019 `minimum` operation - see `f32::minimum` etc.
/// In particular, `-0.0` is considered smaller than `+0.0` and
/// if either input is NaN, the result is NaN.
Minimum,
/// The IEEE `MinNum` operation - see `f32::min` etc
/// The IEEE-2008 `minNum` operation - see `f32::min` etc.
/// In particular, if the inputs are `-0.0` and `+0.0`, the result is non-deterministic,
/// and is one argument is NaN, the other one is returned.
/// and if one argument is NaN, the other one is returned.
MinNum,
/// The IEEE `Maximum` operation - see `f32::maximum` etc
/// The IEEE-2019 `maximum` operation - see `f32::maximum` etc.
/// In particular, `-0.0` is considered smaller than `+0.0` and
/// if either input is NaN, the result is NaN.
Maximum,
/// The IEEE `MaxNum` operation - see `f32::max` etc
/// The IEEE-2008 `maxNum` operation - see `f32::max` etc.
/// In particular, if the inputs are `-0.0` and `+0.0`, the result is non-deterministic,
/// and is one argument is NaN, the other one is returned.
/// and if one argument is NaN, the other one is returned.
MaxNum,
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,9 +1586,10 @@ pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>>
map
});

pub fn is_stable_diagnostic_attribute(sym: Symbol, _features: &Features) -> bool {
pub fn is_stable_diagnostic_attribute(sym: Symbol, features: &Features) -> bool {
match sym {
sym::on_unimplemented | sym::do_not_recommend => true,
sym::on_const => features.diagnostic_on_const(),
_ => false,
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ declare_features! (
(incomplete, deref_patterns, "1.79.0", Some(87121)),
/// Allows deriving the From trait on single-field structs.
(unstable, derive_from, "1.91.0", Some(144889)),
/// Allows giving non-const impls custom diagnostic messages if attempted to be used as const
(unstable, diagnostic_on_const, "CURRENT_RUSTC_VERSION", Some(143874)),
/// Allows `#[doc(cfg(...))]`.
(unstable, doc_cfg, "1.21.0", Some(43781)),
/// Allows `#[doc(masked)]`.
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
tcx.ensure_ok().type_of(def_id);
tcx.ensure_ok().predicates_of(def_id);
tcx.ensure_ok().associated_items(def_id);
check_diagnostic_attrs(tcx, def_id);
if of_trait {
let impl_trait_header = tcx.impl_trait_header(def_id);
res = res.and(
Expand All @@ -824,7 +825,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
tcx.ensure_ok().predicates_of(def_id);
tcx.ensure_ok().associated_items(def_id);
let assoc_items = tcx.associated_items(def_id);
check_on_unimplemented(tcx, def_id);
check_diagnostic_attrs(tcx, def_id);

for &assoc_item in assoc_items.in_definition_order() {
match assoc_item.kind {
Expand Down Expand Up @@ -1112,7 +1113,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
})
}

pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, def_id: LocalDefId) {
pub(super) fn check_diagnostic_attrs(tcx: TyCtxt<'_>, def_id: LocalDefId) {
// an error would be reported if this fails.
let _ = OnUnimplementedDirective::of_item(tcx, def_id.to_def_id());
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ passes_deprecated_annotation_has_no_effect =
passes_deprecated_attribute =
deprecated attribute must be paired with either stable or unstable attribute
passes_diagnostic_diagnostic_on_const_only_for_trait_impls =
`#[diagnostic::on_const]` can only be applied to trait impls
passes_diagnostic_diagnostic_on_unimplemented_only_for_traits =
`#[diagnostic::on_unimplemented]` can only be applied to trait definitions
Expand Down
36 changes: 34 additions & 2 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalModDefId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{
self as hir, Attribute, CRATE_HIR_ID, CRATE_OWNER_ID, FnSig, ForeignItem, HirId, Item,
ItemKind, MethodKind, PartialConstStability, Safety, Stability, StabilityLevel, Target,
self as hir, Attribute, CRATE_HIR_ID, CRATE_OWNER_ID, Constness, FnSig, ForeignItem, HirId,
Item, ItemKind, MethodKind, PartialConstStability, Safety, Stability, StabilityLevel, Target,
TraitItem, find_attr,
};
use rustc_macros::LintDiagnostic;
Expand Down Expand Up @@ -55,6 +55,10 @@ use crate::{errors, fluent_generated as fluent};
#[diag(passes_diagnostic_diagnostic_on_unimplemented_only_for_traits)]
struct DiagnosticOnUnimplementedOnlyForTraits;

#[derive(LintDiagnostic)]
#[diag(passes_diagnostic_diagnostic_on_const_only_for_trait_impls)]
struct DiagnosticOnConstOnlyForTraitImpls;

fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target {
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
Expand Down Expand Up @@ -294,6 +298,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::diagnostic, sym::on_unimplemented, ..] => {
self.check_diagnostic_on_unimplemented(attr.span(), hir_id, target)
}
[sym::diagnostic, sym::on_const, ..] => {
self.check_diagnostic_on_const(attr.span(), hir_id, target, item)
}
[sym::thread_local, ..] => self.check_thread_local(attr, span, target),
[sym::doc, ..] => self.check_doc_attrs(
attr,
Expand Down Expand Up @@ -517,6 +524,31 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}

/// Checks if `#[diagnostic::on_const]` is applied to a trait impl
fn check_diagnostic_on_const(
&self,
attr_span: Span,
hir_id: HirId,
target: Target,
item: Option<ItemLike<'_>>,
) {
if matches!(target, Target::Impl { of_trait: true }) {
match item.unwrap() {
ItemLike::Item(it) => match it.expect_impl().constness {
Constness::Const => {}
Constness::NotConst => return,
},
ItemLike::ForeignItem => {}
}
}
self.tcx.emit_node_span_lint(
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
hir_id,
attr_span,
DiagnosticOnConstOnlyForTraitImpls,
);
}

/// Checks if an `#[inline]` is applied to a function or a closure.
fn check_inline(&self, hir_id: HirId, attr_span: Span, kind: &InlineAttr, target: Target) {
match target {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)
&& let [namespace, attribute, ..] = &*path.segments
&& namespace.ident.name == sym::diagnostic
&& ![sym::on_unimplemented, sym::do_not_recommend].contains(&attribute.ident.name)
&& ![sym::on_unimplemented, sym::do_not_recommend, sym::on_const]
.contains(&attribute.ident.name)
{
let typo_name = find_best_match_for_name(
&[sym::on_unimplemented, sym::do_not_recommend],
&[sym::on_unimplemented, sym::do_not_recommend, sym::on_const],
attribute.ident.name,
Some(5),
);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ symbols! {
destructuring_assignment,
diagnostic,
diagnostic_namespace,
diagnostic_on_const,
dialect,
direct,
discriminant_kind,
Expand Down Expand Up @@ -1594,6 +1595,7 @@ symbols! {
old_name,
omit_gdb_pretty_printer_section,
on,
on_const,
on_unimplemented,
opaque,
opaque_module_name_placeholder: "<opaque>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use super::{
};
use crate::error_reporting::TypeErrCtxt;
use crate::error_reporting::infer::TyCategory;
use crate::error_reporting::traits::on_unimplemented::OnUnimplementedDirective;
use crate::error_reporting::traits::report_dyn_incompatibility;
use crate::errors::{ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn};
use crate::infer::{self, InferCtxt, InferCtxtExt as _};
Expand Down Expand Up @@ -587,7 +588,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}

ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
self.report_host_effect_error(bound_predicate.rebind(predicate), obligation.param_env, span)
self.report_host_effect_error(bound_predicate.rebind(predicate), &obligation, span)
}

ty::PredicateKind::Subtype(predicate) => {
Expand Down Expand Up @@ -808,20 +809,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn report_host_effect_error(
&self,
predicate: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
main_obligation: &PredicateObligation<'tcx>,
span: Span,
) -> Diag<'a> {
// FIXME(const_trait_impl): We should recompute the predicate with `[const]`
// if it's `const`, and if it holds, explain that this bound only
// *conditionally* holds. If that fails, we should also do selection
// to drill this down to an impl or built-in source, so we can
// point at it and explain that while the trait *is* implemented,
// that implementation is not const.
// *conditionally* holds.
let trait_ref = predicate.map_bound(|predicate| ty::TraitPredicate {
trait_ref: predicate.trait_ref,
polarity: ty::PredicatePolarity::Positive,
});
let mut file = None;

let err_msg = self.get_standard_error_message(
trait_ref,
None,
Expand All @@ -832,18 +831,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
);
let mut diag = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
*diag.long_ty_path() = file;
if !self.predicate_may_hold(&Obligation::new(
let obligation = Obligation::new(
self.tcx,
ObligationCause::dummy(),
param_env,
main_obligation.param_env,
trait_ref,
)) {
);
if !self.predicate_may_hold(&obligation) {
diag.downgrade_to_delayed_bug();
}
for candidate in self.find_similar_impl_candidates(trait_ref) {
let CandidateSimilarity::Exact { .. } = candidate.similarity else { continue };
let impl_did = candidate.impl_def_id;
let trait_did = candidate.trait_ref.def_id;

if let Ok(Some(ImplSource::UserDefined(impl_data))) =
SelectionContext::new(self).select(&obligation.with(self.tcx, trait_ref.skip_binder()))
{
let impl_did = impl_data.impl_def_id;
let trait_did = trait_ref.def_id();
let impl_span = self.tcx.def_span(impl_did);
let trait_name = self.tcx.item_name(trait_did);

Expand All @@ -865,6 +867,42 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
impl_span,
format!("trait `{trait_name}` is implemented but not `const`"),
);

let (condition_options, format_args) = self.on_unimplemented_components(
trait_ref,
main_obligation,
diag.long_ty_path(),
);

if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, impl_did)
{
let note = command.evaluate(
self.tcx,
predicate.skip_binder().trait_ref,
&condition_options,
&format_args,
);
let OnUnimplementedNote {
message,
label,
notes,
parent_label,
append_const_msg: _,
} = note;

if let Some(message) = message {
diag.primary_message(message);
}
if let Some(label) = label {
diag.span_label(impl_span, label);
}
for note in notes {
diag.note(note);
}
if let Some(parent_label) = parent_label {
diag.span_label(impl_span, parent_label);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit};
use rustc_errors::codes::*;
use rustc_errors::{ErrorGuaranteed, struct_span_code_err};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{AttrArgs, Attribute};
use rustc_macros::LintDiagnostic;
Expand Down Expand Up @@ -103,7 +104,27 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if trait_pred.polarity() != ty::PredicatePolarity::Positive {
return OnUnimplementedNote::default();
}
let (condition_options, format_args) =
self.on_unimplemented_components(trait_pred, obligation, long_ty_path);
if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, trait_pred.def_id())
{
command.evaluate(
self.tcx,
trait_pred.skip_binder().trait_ref,
&condition_options,
&format_args,
)
} else {
OnUnimplementedNote::default()
}
}

pub(crate) fn on_unimplemented_components(
&self,
trait_pred: ty::PolyTraitPredicate<'tcx>,
obligation: &PredicateObligation<'tcx>,
long_ty_path: &mut Option<PathBuf>,
) -> (ConditionOptions, FormatArgs<'tcx>) {
let (def_id, args) = self
.impl_similar_to(trait_pred, obligation)
.unwrap_or_else(|| (trait_pred.def_id(), trait_pred.skip_binder().trait_ref.args));
Expand Down Expand Up @@ -293,12 +314,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
.collect();

let format_args = FormatArgs { this, trait_sugared, generic_args, item_context };

if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, def_id) {
command.evaluate(self.tcx, trait_pred.trait_ref, &condition_options, &format_args)
} else {
OnUnimplementedNote::default()
}
(condition_options, format_args)
}
}

Expand All @@ -325,7 +341,7 @@ pub struct OnUnimplementedDirective {
}

/// For the `#[rustc_on_unimplemented]` attribute
#[derive(Default)]
#[derive(Default, Debug)]
pub struct OnUnimplementedNote {
pub message: Option<String>,
pub label: Option<String>,
Expand Down Expand Up @@ -562,17 +578,21 @@ impl<'tcx> OnUnimplementedDirective {
}

pub fn of_item(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> Result<Option<Self>, ErrorGuaranteed> {
if !tcx.is_trait(item_def_id) {
let attr = if tcx.is_trait(item_def_id) {
sym::on_unimplemented
} else if let DefKind::Impl { of_trait: true } = tcx.def_kind(item_def_id) {
sym::on_const
} else {
// It could be a trait_alias (`trait MyTrait = SomeOtherTrait`)
// or an implementation (`impl MyTrait for Foo {}`)
//
// We don't support those.
return Ok(None);
}
};
if let Some(attr) = tcx.get_attr(item_def_id, sym::rustc_on_unimplemented) {
return Self::parse_attribute(attr, false, tcx, item_def_id);
} else {
tcx.get_attrs_by_path(item_def_id, &[sym::diagnostic, sym::on_unimplemented])
tcx.get_attrs_by_path(item_def_id, &[sym::diagnostic, attr])
.filter_map(|attr| Self::parse_attribute(attr, true, tcx, item_def_id).transpose())
.try_fold(None, |aggr: Option<Self>, directive| {
let directive = directive?;
Expand Down
Loading
Loading