Skip to content
Merged
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
b4781c8
Use default field values in a few more cases
estebank Jan 15, 2026
996d72b
compiletest: Support `--extern` modifiers with `proc-macro` directive
Enselic Jan 17, 2026
0271b6b
regression test for alias-relate changes in lub
jdonszelmann Jan 30, 2026
8c0d93b
Skip overlapping spans in argument error suggestions
chenyukang Jan 31, 2026
8927aa5
Add `inline` syntax for diagnostic messages
JonathanBrouwer Jan 30, 2026
378c6fc
Uitests for `#[diagnostic]`
JonathanBrouwer Jan 30, 2026
523d9d9
Uitests for subdiagnostics
JonathanBrouwer Jan 30, 2026
ca2be71
Add verification for inline fluent messages
JonathanBrouwer Jan 30, 2026
caaee92
more float constants: sqrt(5), 1/sqrt(5)
joshuarayton Sep 23, 2025
cd1c773
Remove `lift_query_info`.
nnethercote Jan 30, 2026
4ff360e
Rename some query-related things.
nnethercote Jan 30, 2026
8e2c9c6
Eliminate some `'a` lifetimes.
nnethercote Jan 30, 2026
c6afd45
Move `depth_limit_error` out of `QueryContext` trait.
nnethercote Feb 1, 2026
59868c1
Fix uninitialized UEFI globals in tests
nicholasbishop Jan 23, 2026
09de0fd
Use `#![feature(adt_const_params)]` for static query flags
Zalathar Jan 30, 2026
c725637
explain why we dont skip some of this work when there are field proje…
RalfJung Feb 2, 2026
c0393cf
resolve: Report more early resolution ambiguities for imports
petrochenkov Oct 24, 2025
629ff9b
Update tests/ui/traits/next-solver/generalize/relate-alias-in-lub.rs
jdonszelmann Feb 2, 2026
82a530c
Port
crazazy Feb 2, 2026
55f75af
Rollup merge of #149596 - petrochenkov:visambig2, r=yaahc
JonathanBrouwer Feb 2, 2026
0a7697c
Rollup merge of #151695 - Enselic:proc-macro-priv-v2, r=Zalathar
JonathanBrouwer Feb 2, 2026
1c42fd4
Rollup merge of #151938 - Zalathar:adt-query-flags, r=nnethercote
JonathanBrouwer Feb 2, 2026
5144366
Rollup merge of #151172 - estebank:default-field-values, r=dianne
JonathanBrouwer Feb 2, 2026
f0355cc
Rollup merge of #151825 - joshuarayton:more-float-constants, r=tgross35
JonathanBrouwer Feb 2, 2026
894d05d
Rollup merge of #151870 - jdonszelmann:regression-test-alias-relate, …
JonathanBrouwer Feb 2, 2026
5e1db44
Rollup merge of #151872 - JonathanBrouwer:diag3, r=Kivooeo
JonathanBrouwer Feb 2, 2026
382c889
Rollup merge of #151902 - RalfJung:place-ty-opt, r=Kobzol
JonathanBrouwer Feb 2, 2026
a34cb94
Rollup merge of #151909 - chenyukang:yukang-fix-151607-disjoint-spans…
JonathanBrouwer Feb 2, 2026
9625c1e
Rollup merge of #151978 - nnethercote:query-cleanups, r=Zalathar
JonathanBrouwer Feb 2, 2026
22b2913
Rollup merge of #151979 - nicholasbishop:push-ssmqyutnpypo, r=jhpratt
JonathanBrouwer Feb 2, 2026
467053f
Rollup merge of #151992 - crazazy:main, r=JonathanBrouwer
JonathanBrouwer Feb 2, 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
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4229,6 +4229,8 @@ dependencies = [
name = "rustc_macros"
version = "0.0.0"
dependencies = [
"fluent-bundle",
"fluent-syntax",
"proc-macro2",
"quote",
"syn 2.0.110",
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParse
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHasIncoherentInherentImpls;
}

pub(crate) struct RustcHiddenTypeOfOpaquesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcHiddenTypeOfOpaquesParser {
const PATH: &[Symbol] = &[sym::rustc_hidden_type_of_opaques];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHiddenTypeOfOpaques;
}
pub(crate) struct RustcNounwindParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcNounwindParser {
Expand Down
16 changes: 9 additions & 7 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ use crate::attributes::rustc_dump::{
RustcDumpVtable,
};
use crate::attributes::rustc_internal::{
RustcHasIncoherentInherentImplsParser, RustcLayoutParser, RustcLayoutScalarValidRangeEndParser,
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser,
RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser,
RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser,
RustcNonConstTraitMethodParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
RustcHasIncoherentInherentImplsParser, RustcHiddenTypeOfOpaquesParser, RustcLayoutParser,
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser,
RustcLegacyConstGenericsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
RustcNoImplicitAutorefsParser, RustcNonConstTraitMethodParser, RustcNounwindParser,
RustcObjectLifetimeDefaultParser, RustcOffloadKernelParser, RustcScalableVectorParser,
RustcSimdMonomorphizeLaneLimitParser,
};
use crate::attributes::semantics::MayDangleParser;
use crate::attributes::stability::{
Expand Down Expand Up @@ -299,6 +300,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcDumpUserArgs>>,
Single<WithoutArgs<RustcDumpVtable>>,
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
Single<WithoutArgs<RustcLintOptTyParser>>,
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,
Expand Down
48 changes: 15 additions & 33 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,12 +2309,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
tcx: TyCtxt<'hir>,
issue_span: Span,
expr_span: Span,
body_expr: Option<&'hir hir::Expr<'hir>>,
loop_bind: Option<&'hir Ident>,
loop_span: Option<Span>,
head_span: Option<Span>,
pat_span: Option<Span>,
head: Option<&'hir hir::Expr<'hir>>,
body_expr: Option<&'hir hir::Expr<'hir>> = None,
loop_bind: Option<&'hir Ident> = None,
loop_span: Option<Span> = None,
head_span: Option<Span> = None,
pat_span: Option<Span> = None,
head: Option<&'hir hir::Expr<'hir>> = None,
}
impl<'hir> Visitor<'hir> for ExprFinder<'hir> {
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
Expand Down Expand Up @@ -2380,17 +2380,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
hir::intravisit::walk_expr(self, ex);
}
}
let mut finder = ExprFinder {
tcx,
expr_span: span,
issue_span,
loop_bind: None,
body_expr: None,
head_span: None,
loop_span: None,
pat_span: None,
head: None,
};
let mut finder = ExprFinder { tcx, expr_span: span, issue_span, .. };
finder.visit_expr(tcx.hir_body(body_id).value);

if let Some(body_expr) = finder.body_expr
Expand Down Expand Up @@ -2625,13 +2615,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {

struct ExpressionFinder<'tcx> {
capture_span: Span,
closure_change_spans: Vec<Span>,
closure_arg_span: Option<Span>,
in_closure: bool,
suggest_arg: String,
closure_change_spans: Vec<Span> = vec![],
closure_arg_span: Option<Span> = None,
in_closure: bool = false,
suggest_arg: String = String::new(),
tcx: TyCtxt<'tcx>,
closure_local_id: Option<hir::HirId>,
closure_call_changes: Vec<(Span, String)>,
closure_local_id: Option<hir::HirId> = None,
closure_call_changes: Vec<(Span, String)> = vec![],
}
impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
Expand Down Expand Up @@ -2712,16 +2702,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}) = self.infcx.tcx.hir_node(self.mir_hir_id())
&& let hir::Node::Expr(expr) = self.infcx.tcx.hir_node(body_id.hir_id)
{
let mut finder = ExpressionFinder {
capture_span: *capture_kind_span,
closure_change_spans: vec![],
closure_arg_span: None,
in_closure: false,
suggest_arg: String::new(),
closure_local_id: None,
closure_call_changes: vec![],
tcx: self.infcx.tcx,
};
let mut finder =
ExpressionFinder { capture_span: *capture_kind_span, tcx: self.infcx.tcx, .. };
finder.visit_expr(expr);

if finder.closure_change_spans.is_empty() || finder.closure_call_changes.is_empty() {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![allow(internal_features)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(file_buffered)]
#![feature(if_let_guard)]
#![feature(negative_impls)]
Expand Down
11 changes: 9 additions & 2 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ pub enum SubdiagMessage {
/// Identifier of a Fluent message. Instances of this variant are generated by the
/// `Subdiagnostic` derive.
FluentIdentifier(FluentId),
/// An inline Fluent message. Instances of this variant are generated by the
/// `Subdiagnostic` derive.
Inline(Cow<'static, str>),
/// Attribute of a Fluent message. Needs to be combined with a Fluent identifier to produce an
/// actual translated message. Instances of this variant are generated by the `fluent_messages`
/// macro.
Expand Down Expand Up @@ -291,6 +294,8 @@ pub enum DiagMessage {
/// <https://projectfluent.org/fluent/guide/hello.html>
/// <https://projectfluent.org/fluent/guide/attributes.html>
FluentIdentifier(FluentId, Option<FluentId>),
/// An inline Fluent message, containing the to be translated diagnostic message.
Inline(Cow<'static, str>),
}

impl DiagMessage {
Expand All @@ -305,21 +310,22 @@ impl DiagMessage {
SubdiagMessage::FluentIdentifier(id) => {
return DiagMessage::FluentIdentifier(id, None);
}
SubdiagMessage::Inline(s) => return DiagMessage::Inline(s),
SubdiagMessage::FluentAttr(attr) => attr,
};

match self {
DiagMessage::Str(s) => DiagMessage::Str(s.clone()),
DiagMessage::FluentIdentifier(id, _) => {
DiagMessage::FluentIdentifier(id.clone(), Some(attr))
}
_ => panic!("Tried to add a subdiagnostic to a message without a fluent identifier"),
}
}

pub fn as_str(&self) -> Option<&str> {
match self {
DiagMessage::Str(s) => Some(s),
DiagMessage::FluentIdentifier(_, _) => None,
DiagMessage::FluentIdentifier(_, _) | DiagMessage::Inline(_) => None,
}
}
}
Expand Down Expand Up @@ -353,6 +359,7 @@ impl From<DiagMessage> for SubdiagMessage {
// There isn't really a sensible behaviour for this because it loses information but
// this is the most sensible of the behaviours.
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagMessage::FluentAttr(attr),
DiagMessage::Inline(s) => SubdiagMessage::Inline(s),
}
}
}
Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_errors/src/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use std::env;
use std::error::Report;
use std::sync::Arc;

use rustc_error_messages::langid;
pub use rustc_error_messages::{FluentArgs, LazyFallbackBundle};
use tracing::{debug, trace};

use crate::error::{TranslateError, TranslateErrorKind};
use crate::{DiagArg, DiagMessage, FluentBundle, Style};
use crate::fluent_bundle::FluentResource;
use crate::{DiagArg, DiagMessage, FluentBundle, Style, fluent_bundle};

/// Convert diagnostic arguments (a rustc internal type that exists to implement
/// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation.
Expand Down Expand Up @@ -79,6 +81,28 @@ impl Translator {
return Ok(Cow::Borrowed(msg));
}
DiagMessage::FluentIdentifier(identifier, attr) => (identifier, attr),
// This translates an inline fluent diagnostic message
// It does this by creating a new `FluentBundle` with only one message,
// and then translating using this bundle.
DiagMessage::Inline(msg) => {
const GENERATED_MSG_ID: &str = "generated_msg";
let resource =
FluentResource::try_new(format!("{GENERATED_MSG_ID} = {msg}\n")).unwrap();
let mut bundle = fluent_bundle::FluentBundle::new(vec![langid!("en-US")]);
bundle.set_use_isolating(false);
bundle.add_resource(resource).unwrap();
let message = bundle.get_message(GENERATED_MSG_ID).unwrap();
let value = message.value().unwrap();

let mut errs = vec![];
let translated = bundle.format_pattern(value, Some(args), &mut errs).to_string();
debug!(?translated, ?errs);
return if errs.is_empty() {
Ok(Cow::Owned(translated))
} else {
Err(TranslateError::fluent(&Cow::Borrowed(GENERATED_MSG_ID), args, errs))
};
}
};
let translate_with_bundle =
|bundle: &'a FluentBundle| -> Result<Cow<'_, str>, TranslateError<'_>> {
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_has_incoherent_inherent_impls]`
RustcHasIncoherentInherentImpls,

/// Represents `#[rustc_hidden_type_of_opaques]`
RustcHiddenTypeOfOpaques,

/// Represents `#[rustc_layout]`
RustcLayout(ThinVec<RustcLayoutType>),

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl AttributeKind {
RustcDumpVtable(..) => No,
RustcDynIncompatibleTrait(..) => No,
RustcHasIncoherentInherentImpls => Yes,
RustcHiddenTypeOfOpaques => No,
RustcLayout(..) => No,
RustcLayoutScalarValidRangeEnd(..) => Yes,
RustcLayoutScalarValidRangeStart(..) => Yes,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/collect/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_span::sym;

pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
if !tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) {
if !find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcHiddenTypeOfOpaques) {
return;
}

for id in tcx.hir_crate_items(()).opaques() {
if let hir::OpaqueTyOrigin::FnReturn { parent: fn_def_id, .. }
| hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, .. } =
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_hir_analysis/src/hir_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>(
struct HirWfCheck<'tcx> {
tcx: TyCtxt<'tcx>,
predicate: ty::Predicate<'tcx>,
cause: Option<ObligationCause<'tcx>>,
cause_depth: usize,
cause: Option<ObligationCause<'tcx>> = None,
cause_depth: usize = 0,
icx: ItemCtxt<'tcx>,
def_id: LocalDefId,
param_env: ty::ParamEnv<'tcx>,
depth: usize,
depth: usize = 0,
}

impl<'tcx> Visitor<'tcx> for HirWfCheck<'tcx> {
Expand Down Expand Up @@ -124,16 +124,8 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>(
}
}

let mut visitor = HirWfCheck {
tcx,
predicate,
cause: None,
cause_depth: 0,
icx,
def_id,
param_env: tcx.param_env(def_id.to_def_id()),
depth: 0,
};
let param_env = tcx.param_env(def_id.to_def_id());
let mut visitor = HirWfCheck { tcx, predicate, icx, def_id, param_env, .. };

// Get the starting `hir::Ty` using our `WellFormedLoc`.
// We will walk 'into' this type to try to find
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This API is completely unstable and subject to change.

// tidy-alphabetical-start
#![feature(assert_matches)]
#![feature(default_field_values)]
#![feature(gen_blocks)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,15 @@ impl<'a, 'b, 'tcx> FnCallDiagCtxt<'a, 'b, 'tcx> {
// To suggest a multipart suggestion when encountering `foo(1, "")` where the def
// was `fn foo(())`.
let (_, expected_ty) = self.formal_and_expected_inputs[expected_idx];
suggestions.push((*arg_span, self.ty_to_snippet(expected_ty, expected_idx)));
// Check if the new suggestion would overlap with any existing suggestion.
// This can happen when we have both removal suggestions (which may include
// adjacent commas) and type replacement suggestions for the same span.
let dominated = suggestions
.iter()
.any(|(span, _)| span.contains(*arg_span) || arg_span.overlaps(*span));
if !dominated {
suggestions.push((*arg_span, self.ty_to_snippet(expected_ty, expected_idx)));
}
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare_lint_pass! {
AMBIGUOUS_GLOB_IMPORTED_TRAITS,
AMBIGUOUS_GLOB_IMPORTS,
AMBIGUOUS_GLOB_REEXPORTS,
AMBIGUOUS_IMPORT_VISIBILITIES,
AMBIGUOUS_PANIC_IMPORTS,
ARITHMETIC_OVERFLOW,
ASM_SUB_REGISTER,
Expand Down Expand Up @@ -4564,6 +4565,55 @@ declare_lint! {
};
}

declare_lint! {
/// The `ambiguous_import_visibilities` lint detects imports that should report ambiguity
/// errors, but previously didn't do that due to rustc bugs.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(unknown_lints)]
/// #![deny(ambiguous_import_visibilities)]
/// mod reexport {
/// mod m {
/// pub struct S {}
/// }
///
/// macro_rules! mac {
/// () => { use m::S; }
/// }
///
/// pub use m::*;
/// mac!();
///
/// pub use S as Z; // ambiguous visibility
/// }
///
/// fn main() {
/// reexport::Z {};
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Previous versions of Rust compile it successfully because it
/// fetched the glob import's visibility for `pub use S as Z` import, and ignored the private
/// `use m::S` import that appeared later.
///
/// This is a [future-incompatible] lint to transition this to a
/// hard error in the future.
///
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub AMBIGUOUS_IMPORT_VISIBILITIES,
Warn,
"detects certain glob imports that require reporting an ambiguity error",
@future_incompatible = FutureIncompatibleInfo {
reason: fcw!(FutureReleaseError #149145),
};
}

declare_lint! {
/// The `refining_impl_trait_reachable` lint detects `impl Trait` return
/// types in method signatures that are refined by a publically reachable
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ proc-macro = true

[dependencies]
# tidy-alphabetical-start
fluent-bundle = "0.16"
fluent-syntax = "0.12"
proc-macro2 = "1"
quote = "1"
syn = { version = "2.0.9", features = ["full"] }
Expand Down
Loading
Loading