Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
36e4fe5
reject extern statics in promotion
sjwang05 Jun 13, 2026
9ac2606
re-bless tests
sjwang05 Jun 13, 2026
0439f4e
Hint that memchr returns an in-bounds index
SomeFlyingThing Jul 23, 2026
c1f36d5
Hint that memrchr returns an in-bounds index
SomeFlyingThing Jul 24, 2026
844c01e
Cover memchr fast path with bounds assertion
SomeFlyingThing Jul 27, 2026
49c1f02
Fix memchr result CI checks
SomeFlyingThing Jul 27, 2026
19fe04b
Add regression test for GAT bound mismatched-type error
zakrad Jul 28, 2026
807750a
Preserve memchr codegen on LLVM 21
SomeFlyingThing Jul 28, 2026
1e1aad2
Inline the splatted_callee function
teor2345 Jul 21, 2026
9f9fb37
Refactor splat using custom enums (with stubs)
teor2345 Jul 28, 2026
f88563c
Make splatted FnPtr calls work (rather than ICE)
teor2345 Jul 28, 2026
9ff75a7
make `DefiningTy` independent of borrowck
lcnr Aug 3, 2026
8427cb5
Add regression test for associated type outlives bound at call site
zakrad Aug 5, 2026
cd19505
rustc_resolve: move diagnostic attribute linting to attr parsing
mejrs Aug 5, 2026
cd8a97b
Handle LLVM 21 in memchr result codegen test
SomeFlyingThing Aug 5, 2026
6ea57af
Snapshot test for `./x fix compiler`
Zalathar Aug 6, 2026
938bf98
Inline and remove constructors from `check::Rustc`
Zalathar Aug 5, 2026
b344260
Store and use an explicit CheckKind in `check::Rustc`
Zalathar Aug 5, 2026
fd7e845
Add documentation and maintainer for L4Re target
farao Jan 9, 2026
5bb8d31
Add aarch64 architecture for L4Re target
farao Jan 9, 2026
225ca5f
platform-support/netbsd.md: No longer mention 8.x, due to EoL.
he32 Aug 6, 2026
0d75b8c
fix ICE in `suggest_add_reference_to_arg` for non-callable items
im-lunex Aug 6, 2026
140d4cb
delegation: add support for wrapping of the return value with `From::…
aerooneqq Aug 6, 2026
86b915f
expand: Feature gate AST-based attribute macros on expressions and no…
petrochenkov Aug 5, 2026
f2dd932
L4Re: Repair build and move to rustc linking
farao Jul 13, 2026
f639348
expand: Change feature gate wording for `feature(proc_macro_hygiene)`
petrochenkov Aug 6, 2026
c1af195
cleanup `DefiningTy::new`
lcnr Aug 4, 2026
b326732
make the c_variadic region late bound
lcnr Aug 4, 2026
234a308
Fix determining wrong fn kind when delegation is inside const arg
aerooneqq Aug 6, 2026
8bb9f27
refactor handling of target features in Session
RalfJung Aug 4, 2026
78de456
derive(Diagnostic): link to proper docs
RalfJung Aug 6, 2026
6e9475f
Derive attribute parser debug impls
mejrs Aug 6, 2026
a1b86a7
codegen: classify localized MSVC linker progress as linker_info
rabindra789 Aug 3, 2026
6253cca
rename 'forbidden' target features to 'internal-only'
RalfJung Aug 5, 2026
e5004d0
ensure that we never toggle internal target features via the attribute
RalfJung Aug 5, 2026
b9ad974
Fix FutureDropPoll shim for by-move async closures
KR-bluejay Aug 6, 2026
08e7eaf
Remove fragile memchr codegen test
SomeFlyingThing Aug 6, 2026
f98cf4c
move naked function ui tests
folkertdev Aug 6, 2026
b5c330c
snippet emitter: rework debug impls
mejrs Aug 6, 2026
b829f17
Simplify `MaybeTransitiveLiveLocals`
nnethercote Aug 5, 2026
530c82c
Rename `TransferFunction`
nnethercote Aug 5, 2026
7e95965
Remove `MaybeLiveLocals::transfer_function`
nnethercote Aug 5, 2026
0ae7d22
Remove an unnecessary lifetime
nnethercote Aug 5, 2026
d1689e2
Fix a typo
nnethercote Aug 5, 2026
d7a07f0
Remove unused derives on `DefUse`
nnethercote Aug 5, 2026
a7b542a
Remove unnecessary `&` sigils
nnethercote Aug 5, 2026
162cba5
dlopen Offload
sgasho Aug 6, 2026
93a46b6
Improve the canonical param env cache
nnethercote Aug 6, 2026
8ba2b46
Update a comment
nnethercote Aug 6, 2026
87d95f5
Introduce `Canonicalizer::new`
nnethercote Aug 7, 2026
8b5cad1
Add note to invalidate iterator when mutating inside a for-loop
ssenthilnathan3 Aug 7, 2026
5c0a732
Add regression test for unknown feature name with other errors present
zakrad Aug 7, 2026
2a773d2
make test use minicore
folkertdev Aug 6, 2026
10dbc1c
Add branch config for perf. unrolling in bors
Kobzol Aug 7, 2026
1bd2075
rustc_codegen_llvm: handle sm_101* features being an alias
durin42 Aug 7, 2026
6eac4e4
renovate: clarify that vulnerability PRs are opened automatically
marcoieni Aug 7, 2026
f231e43
Streamline `canonicalize_param_env`
nnethercote Aug 7, 2026
34d9f1e
Rollup merge of #159784 - SomeFlyingThing:agent/hint-memchr-result-bo…
JonathanBrouwer Aug 7, 2026
88c37ce
Rollup merge of #160673 - nnethercote:improve-canonical-param-env-cac…
JonathanBrouwer Aug 7, 2026
4eeee3b
Rollup merge of #150885 - farao:main, r=saethlin,joboet
JonathanBrouwer Aug 7, 2026
ede75f6
Rollup merge of #159643 - teor2345:splat-fn-ptr, r=folkertdev
JonathanBrouwer Aug 7, 2026
f6d93ec
Rollup merge of #160433 - aerooneqq:delegation-return-wrapping-3, r=p…
JonathanBrouwer Aug 7, 2026
6a3b9ac
Rollup merge of #160530 - RalfJung:internal-target-features, r=nnethe…
JonathanBrouwer Aug 7, 2026
1dec347
Rollup merge of #160606 - Zalathar:check-kind, r=Kobzol
JonathanBrouwer Aug 7, 2026
846e5a4
Rollup merge of #160628 - im-lunex:fix_#160591, r=JohnTitor
JonathanBrouwer Aug 7, 2026
da74d6b
Rollup merge of #160683 - zakrad:regr-test-58390, r=estebank
JonathanBrouwer Aug 7, 2026
ce07b0a
Rollup merge of #157641 - sjwang05:fix-143174-extern-static-promotion…
JonathanBrouwer Aug 7, 2026
a87e770
Rollup merge of #158904 - KR-bluejay:issue-142559-fix, r=oli-obk
JonathanBrouwer Aug 7, 2026
386fb4e
Rollup merge of #159816 - ssenthilnathan3:e0502-loop-mutate, r=camelid
JonathanBrouwer Aug 7, 2026
626d81f
Rollup merge of #160103 - zakrad:regr-test-106832, r=tiif
JonathanBrouwer Aug 7, 2026
6265969
Rollup merge of #160335 - sgasho:dlopen_offload, r=ZuseZ4
JonathanBrouwer Aug 7, 2026
615aa92
Rollup merge of #160445 - rabindra789:fix/msvc-localized-linker-outpu…
JonathanBrouwer Aug 7, 2026
6738083
Rollup merge of #160499 - mejrs:move_diagnostic_attr_not_found_lint, …
JonathanBrouwer Aug 7, 2026
ec8ac07
Rollup merge of #160504 - lcnr:borrowck-cleanup, r=oli-obk
JonathanBrouwer Aug 7, 2026
ca2ba0c
Rollup merge of #160577 - petrochenkov:astgate, r=khyperia
JonathanBrouwer Aug 7, 2026
3f438d1
Rollup merge of #160587 - zakrad:regr-test-63253, r=JohnTitor
JonathanBrouwer Aug 7, 2026
3e7cb80
Rollup merge of #160625 - he32:update-netbsd-doc, r=nnethercote
JonathanBrouwer Aug 7, 2026
e228bce
Rollup merge of #160633 - aerooneqq:delegation-fn-kind-ice, r=petroch…
JonathanBrouwer Aug 7, 2026
2ac7c92
Rollup merge of #160636 - RalfJung:derive-diagnostic, r=mejrs
JonathanBrouwer Aug 7, 2026
24780be
Rollup merge of #160644 - mejrs:debug-impls, r=khyperia
JonathanBrouwer Aug 7, 2026
53b781f
Rollup merge of #160649 - folkertdev:move-naked-ui-tests, r=chenyukang
JonathanBrouwer Aug 7, 2026
20ea46d
Rollup merge of #160672 - nnethercote:improve-MaybeLiveLocals, r=cjgi…
JonathanBrouwer Aug 7, 2026
2804fce
Rollup merge of #160693 - Kobzol:try-perf-branches, r=marcoieni
JonathanBrouwer Aug 7, 2026
ff1eba1
Rollup merge of #160696 - durin42:llvm-24-nvptx-subtarget-rename, r=f…
JonathanBrouwer Aug 7, 2026
f07399c
Rollup merge of #160706 - marcoieni:renovate-security-prs-auto, r=ubi…
JonathanBrouwer Aug 7, 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
7 changes: 6 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
"src/doc/book",
"src/doc/reference"
],
// Require manual approval from the Dependency Dashboard before opening PRs
// Require manual approval from the Dependency Dashboard before opening PRs,
// except for the update types explicitly configured below.
"dependencyDashboardApproval": true,
// No dashboard approval necessary for security updates
"vulnerabilityAlerts": {
"dependencyDashboardApproval": false
},
// Renovate shouldn't update a PR if it is in the bors merge queue.
"stopUpdatingLabel": "S-waiting-on-bors",
"packageRules": [
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
branches:
- automation/bors/auto
- automation/bors/try
- automation/bors/try-perf
- try-perf
pull_request:
branches:
Expand All @@ -34,7 +35,7 @@ concurrency:
# We add an exception for try builds (automation/bors/try branch) and unrolled rollup builds
# (try-perf), which are all triggered on the same branch, but which should be able to run
# concurrently.
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try') && github.sha) || github.ref }}
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try-perf' || github.ref == 'refs/heads/automation/bors/try') && github.sha) || github.ref }}
cancel-in-progress: true
env:
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:
# access the environment.
#
# We only enable the environment for the rust-lang/rust repository, so that CI works on forks.
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/automation/bors/try' || github.ref == 'refs/heads/automation/bors/try-perf' || github.ref == 'refs/heads/automation/bors/auto')) && 'bors') || '' }}
env:
CI_JOB_NAME: ${{ matrix.name }}
CI_JOB_DOC_URL: ${{ matrix.doc_url }}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
match asm::InlineAsmClobberAbi::parse(
asm_arch,
&self.tcx.sess.target,
&self.tcx.sess.unstable_target_features,
&self.tcx.sess.internal_target_features,
*abi_name,
) {
Ok(abi) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
p.def_id.to_def_id(),
);

self.create_resolved_path(res, p.name.ident(), p.span)
self.create_resolved_qpath(res, p.name.ident(), p.span)
}

pub(super) fn create_resolved_path(
pub(super) fn create_resolved_qpath(
&mut self,
res: Res,
ident: Ident,
Expand Down
11 changes: 9 additions & 2 deletions compiler/rustc_ast_lowering/src/delegation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
};

let ident = Ident::new(kw::SelfUpper, span);
let path = self.create_resolved_path(res, ident, span);
let path = self.create_resolved_qpath(res, ident, span);

// FIXME(fn_delegation): add default `..` for all other fields.
let initializer = hir::ExprKind::Struct(
Expand All @@ -454,7 +454,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::StructTailExpr::None,
);

self.arena.alloc(self.mk_expr(initializer, span))
let expr = self.mk_expr(initializer, span);

let path = self.make_lang_item_qpath(hir::LangItem::FromFn, span, None);
let path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(path), span));

let call = hir::ExprKind::Call(path, self.arena.alloc_slice(&[expr]));

self.arena.alloc(self.mk_expr(call, span))
} else {
self.arena.alloc(call)
};
Expand Down
51 changes: 43 additions & 8 deletions compiler/rustc_ast_lowering/src/delegation/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use hir::def::DefKind;
use rustc_ast::{self as ast, Delegation, DelegationSource, NodeId};
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_hir as hir;
use rustc_middle::ty::Ty;
use rustc_middle::ty::{Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_middle::{span_bug, ty};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::{ErrorGuaranteed, Span, kw};
use rustc_span::{ErrorGuaranteed, Span};

use crate::delegation::generics::GenericsGenerationResults;
use crate::delegation::resolution::resolver::DelegationResolver;
Expand All @@ -31,7 +31,7 @@ pub(super) struct ParamInfo {
pub splatted: Option<u8>,
}

#[derive(Default)]
#[derive(Default, Debug)]
pub(super) struct SigMapping {
pub map_return: bool,
pub arguments_to_map: FxIndexSet<usize>,
Expand Down Expand Up @@ -254,17 +254,52 @@ impl<'tcx> DelegationResolver<'_, 'tcx> {
}

if self.can_perform_self_mapping(delegation, parent)? {
// FIXME(fn_delegation): support heuristics for mapping of complex
// return types: `Self` -> `Box<Arc<Rc<Self>>>`
mapping.map_return = sig.output().is_param(0);
/// Finds `Self` generic param only in ADT or references, so we avoid cases like
/// `Self::Item` which will return true if `output.contains(...)` will be used.
struct SelfFinder;

impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for SelfFinder {
type Result = ControlFlow<()>;

fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
match t.kind() {
ty::Adt(_, args) => {
if args
.iter()
.flat_map(|arg| arg.as_type())
.any(|type_arg| type_arg.is_self_param())
{
return ControlFlow::Break(());
}

t.super_visit_with(self)
}
ty::Ref(_, ref_t, _) => {
if ref_t.is_self_param() {
return ControlFlow::Break(());
}

t.super_visit_with(self)
}
_ => ControlFlow::Continue(()),
}
}
}

impl SelfFinder {
fn contains_self(t: Ty<'_>) -> bool {
t.is_self_param() || t.visit_with(&mut SelfFinder).is_break()
}
}

mapping.map_return = SelfFinder::contains_self(sig.output());

let self_param = Ty::new_param(self.tcx(), 0, kw::SelfUpper);
let arguments_to_map = sig
.inputs()
.iter()
.enumerate()
.skip(1) // Already checked above.
.filter_map(|(idx, param)| param.contains(self_param).then_some(idx));
.filter_map(|(idx, &param)| SelfFinder::contains_self(param).then_some(idx));

mapping.arguments_to_map.extend(arguments_to_map);
}
Expand Down
68 changes: 67 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
use std::ops::Range;

use rustc_ast::PathSegment;
use rustc_errors::{Diagnostic, MultiSpan};
use rustc_hir::attrs::diagnostic::{
Directive, Filter, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name,
NameValue, Piece, Predicate,
};
use rustc_lint_defs::LintId;
use rustc_parse_format::{
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
};
use rustc_session::lint::builtin::{
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MALFORMED_DIAGNOSTIC_FILTERS,
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
};
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::{Ident, InnerSpan, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};

Expand All @@ -20,6 +24,7 @@ use crate::diagnostics::{
MissingOptionsForDiagnosticAttribute, NonMetaItemDiagnosticAttribute, WrappedParserError,
};
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
use crate::{EmitAttribute, diagnostics};

pub(crate) mod do_not_recommend;
pub(crate) mod on_const;
Expand All @@ -30,6 +35,67 @@ pub(crate) mod on_unknown;
pub(crate) mod on_unmatched_args;
pub(crate) mod opaque;

impl<'sess> crate::AttributeParser<'sess> {
pub(crate) fn unknown_diagnostic_attr(
&self,
segment: &PathSegment,
mut emit_lint: impl FnMut(LintId, MultiSpan, EmitAttribute),
) {
const DIAGNOSTIC_ATTRIBUTES: [(
Symbol, /* name */
Option<Symbol>, /* feature gate */
); 8] = [
(sym::on_unimplemented, None),
(sym::do_not_recommend, None),
(sym::on_move, Some(sym::diagnostic_on_move)),
(sym::on_const, Some(sym::diagnostic_on_const)),
(sym::on_unknown, Some(sym::diagnostic_on_unknown)),
(sym::on_unmatched_args, Some(sym::diagnostic_on_unmatched_args)),
(sym::on_type_error, Some(sym::diagnostic_on_type_error)),
(sym::opaque, Some(sym::diagnostic_opaque)),
];
// No need to emit a lint if features aren't available.
let Some(features) = self.features else { return };
let span = segment.span();
let candidates = DIAGNOSTIC_ATTRIBUTES
.iter()
.filter_map(|(attr, feature)| {
feature.is_none_or(|f| features.enabled(f)).then_some(*attr)
})
.collect::<Vec<_>>();

let typo = find_best_match_for_name(&candidates, segment.ident.name, None)
.map(|typo_name| diagnostics::UnknownDiagnosticAttributeTypo { span, typo_name });
emit_lint(
LintId::of(UNKNOWN_DIAGNOSTIC_ATTRIBUTES),
span.into(),
EmitAttribute(Box::new(move |dcx, level, _| {
diagnostics::UnknownDiagnosticAttribute { typo }.into_diag(dcx, level)
})),
)
}
}

#[rustc_macro_transparency = "transparent"]
macro gate_diagnostic_attr($feature:ident) {{
if let Some(features) = cx.features_option()
&& !features.$feature()
{
args.ignore_args();
let nightly_build = cx.sess.is_nightly_build();
let span = cx.attr_span;
cx.emit_lint(
rustc_lint_defs::builtin::UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
$crate::diagnostics::UnstableDiagnosticAttribute {
feature: sym::$feature,
nightly_build,
},
span,
);
return;
}
}}

#[derive(Copy, Clone)]
pub(crate) enum Mode {
/// `#[rustc_on_unimplemented]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ impl AttributeParser for OnConstParser {
const ATTRIBUTES: AcceptMapping<Self> = &[(
&[sym::diagnostic, sym::on_const],
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
AttributeStability::Stable, // Unstable, stability checked manually in the parser
AttributeStability::Stable, // Unstable, stability checked manually below
|this, cx, args| {
if !cx.features().diagnostic_on_const() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}
gate_diagnostic_attr!(diagnostic_on_const);

let path_span = cx.attr_path.span;
this.path_span = Some(path_span);
Expand Down
34 changes: 12 additions & 22 deletions compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use rustc_span::sym;

use crate::attributes::diagnostic::*;
use crate::attributes::prelude::*;
use crate::context::AcceptContext;
use crate::parser::ArgParser;
use crate::target_checking::AllowedTargets;
use crate::template;

Expand All @@ -15,31 +13,23 @@ pub(crate) struct OnMoveParser {
directive: Option<(Span, Directive)>,
}

impl OnMoveParser {
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser, mode: Mode) {
if !cx.features().diagnostic_on_move() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}

let span = cx.attr_span;
self.span = Some(span);

let Some(items) = parse_list(cx, args, mode) else { return };

if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
merge_directives(cx, &mut self.directive, (span, directive));
}
}
}
impl AttributeParser for OnMoveParser {
const ATTRIBUTES: AcceptMapping<Self> = &[(
&[sym::diagnostic, sym::on_move],
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
AttributeStability::Stable, // Unstable, stability checked manually in the parser
AttributeStability::Stable, // Unstable, stability checked manually below
|this, cx, args| {
this.parse(cx, args, Mode::DiagnosticOnMove);
gate_diagnostic_attr!(diagnostic_on_move);

let span = cx.attr_span;
this.span = Some(span);
let mode = Mode::DiagnosticOnMove;

let Some(items) = parse_list(cx, args, mode) else { return };

if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
merge_directives(cx, &mut this.directive, (span, directive));
}
},
)];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use rustc_span::sym;
use crate::attributes::AttributeStability;
use crate::attributes::diagnostic::*;
use crate::attributes::prelude::*;
use crate::context::AcceptContext;
use crate::parser::ArgParser;
use crate::target_checking::AllowedTargets;
use crate::template;

Expand All @@ -15,32 +13,22 @@ pub(crate) struct OnTypeErrorParser {
directive: Option<(Span, Directive)>,
}

impl OnTypeErrorParser {
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser, mode: Mode) {
if !cx.features().diagnostic_on_type_error() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}

let span = cx.attr_span;
self.span = Some(span);

let Some(items) = parse_list(cx, args, mode) else { return };

if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
merge_directives(cx, &mut self.directive, (span, directive));
}
}
}

impl AttributeParser for OnTypeErrorParser {
const ATTRIBUTES: AcceptMapping<Self> = &[(
&[sym::diagnostic, sym::on_type_error],
template!(List: &[r#"note = "...""#]),
AttributeStability::Stable,
AttributeStability::Stable, // Unstable, stability checked manually below
|this, cx, args| {
this.parse(cx, args, Mode::DiagnosticOnTypeError);
gate_diagnostic_attr!(diagnostic_on_type_error);

let span = cx.attr_span;
this.span = Some(span);
let mode = Mode::DiagnosticOnTypeError;
let Some(items) = parse_list(cx, args, mode) else { return };

if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
merge_directives(cx, &mut this.directive, (span, directive));
}
},
)];

Expand Down
Loading
Loading