Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 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
f3e2153
don't force intronsic results into memory
RalfJung Aug 3, 2026
9a5b317
Merge pull request #5240 from RalfJung/less-force-alloc
RalfJung Aug 3, 2026
9ff75a7
make `DefiningTy` independent of borrowck
lcnr Aug 3, 2026
df4b2ec
Prepare for merging from rust-lang/rust
RalfJung Aug 5, 2026
9950e2c
Merge ref '7218ebe93668' from rust-lang/rust
RalfJung Aug 5, 2026
e6a0fa2
fmt
RalfJung Aug 5, 2026
efc7c74
remove readdir_r now that we no longer need it
RalfJung Aug 5, 2026
ec46f10
fix priroda build
RalfJung Aug 5, 2026
393e0ad
Merge pull request #5243 from rust-lang/rustup-2026-08-05
RalfJung Aug 5, 2026
50ad30b
[Priroda] Extract CLI command result rendering
moabo3li Jul 29, 2026
049c9da
[Priroda] Add initial DAP frontend selection
moabo3li Jul 29, 2026
7b174e3
[Priroda] Add DAP UI fixtures
moabo3li Jul 29, 2026
1544ae7
[Priroda] Split debugger frontends into modules
moabo3li Jul 29, 2026
a6a7a9d
[Priroda] Add minimal DAP initialize handshake
moabo3li Jul 29, 2026
0158e09
[Priroda] Add DAP initialized and launch handshake
moabo3li Jul 31, 2026
5e8f7b9
[Priroda] Handle DAP configurationDone startup request
moabo3li Jul 31, 2026
8cb2e7c
[Priroda] Handle DAP threads request
moabo3li Jul 31, 2026
5a29686
[Priroda] Handle DAP stackTrace request
moabo3li Aug 1, 2026
2d7ddb6
[Priroda] Add core debugger stop-at-first-user-location
moabo3li Aug 1, 2026
dc71376
[Priroda] Wire DAP to interpreter lifecycle and stopped event
moabo3li Aug 1, 2026
84ec755
[Priroda] Report current DAP stack frame
moabo3li Aug 1, 2026
abef458
[Priroda] Add DAP locals scope and variables
moabo3li Aug 1, 2026
d233df9
[Priroda] Add bounded DAP source-line stepping demo
moabo3li Aug 2, 2026
cb35d76
[Priroda] Return Continue instead of Exit for unsupported DAP requests
moabo3li Aug 2, 2026
f1fb454
[Priroda] Document DAP prototype in README
moabo3li Aug 2, 2026
afd33c8
[Priroda] Translate interpreter exits into DAP events
moabo3li Aug 2, 2026
dc93370
[Priroda] Track DAP lifecycle state and validate request ids
moabo3li Aug 2, 2026
51dbde5
[Priroda] Add DAP negative protocol fixtures
moabo3li Aug 2, 2026
00c51d4
[Priroda] Use bug! for dispatch-guaranteed DAP invariants
moabo3li Aug 2, 2026
f32ac7c
[Priroda] Resolve macro-backed spans to their callsite
moabo3li Aug 2, 2026
1f184d7
[Priroda] Handle DAP continue request
moabo3li Aug 2, 2026
affac58
[Priroda] Handle DAP setBreakpoints request
moabo3li Aug 2, 2026
042a542
[Priroda] Advertise single-thread execution + unbounded loop
moabo3li Aug 2, 2026
adb5bb2
[Priroda] Normalise DAP Content-Length in test output
moabo3li 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
a0c286e
[Priroda] render interpreter errors via InterpError::to_string
moabo3li Aug 5, 2026
195fd93
[Priroda] exhaustively list every DAP Command in dispatch and display
moabo3li Aug 5, 2026
e0bf0c7
[Priroda] route DAP request arguments into handlers, add setBreakpoin…
moabo3li Aug 5, 2026
b723b12
[Priroda] fill DAP Locals scope source position from current frame
moabo3li Aug 5, 2026
66470f5
[Priroda] rework DAP dispatch return type for bubble-up rejections
moabo3li Aug 5, 2026
2237402
[Priroda] drop redundant termination guards in DAP handlers
moabo3li Aug 5, 2026
66e0a9e
[Priroda] bubble predicate failures through HandlerError
moabo3li Aug 5, 2026
a17c6d5
[Priroda] pass thread_id by value into require_thread_id
moabo3li Aug 5, 2026
ed18aea
[Priroda] centralize DAP response sends in run_requests
moabo3li Aug 5, 2026
b3cafb3
Merge pull request #5241 from moabo3li/priroda-dap-startup
oli-obk Aug 5, 2026
cd8a97b
Handle LLVM 21 in memchr result codegen test
SomeFlyingThing Aug 5, 2026
2d66ef1
Lookup exported statics when encountering an unsupported imported static
hkalbasi Jul 26, 2026
51c49ff
Merge pull request #5230 from hkalbasi/push-ruquxrvxyplk
RalfJung Aug 5, 2026
a44d862
Prepare for merging from rust-lang/rust
Aug 6, 2026
d83cfa3
Merge ref 'f73951df0a55' from rust-lang/rust
Aug 6, 2026
6ea57af
Snapshot test for `./x fix compiler`
Zalathar Aug 6, 2026
938bf98
Inline and remove constructors from `check::Rustc`
Zalathar Aug 5, 2026
43bc042
Merge pull request #5245 from rust-lang/rustup-2026-08-06
RalfJung Aug 6, 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
dec9493
[Priroda] CI: add clippy check for priroda
moabo3li 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
d68ddd0
Merge pull request #5246 from moabo3li/push-kxrmpxvsomnl
oli-obk 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
2c388de
miri: implement more restrictive trivial-ABI checks
RalfJung 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
24802a1
Rollup merge of #159784 - SomeFlyingThing:agent/hint-memchr-result-bo…
jhpratt Aug 7, 2026
034397f
Rollup merge of #160673 - nnethercote:improve-canonical-param-env-cac…
jhpratt Aug 7, 2026
2e73097
Rollup merge of #150885 - farao:main, r=saethlin,joboet
jhpratt Aug 7, 2026
00640a4
Rollup merge of #159643 - teor2345:splat-fn-ptr, r=folkertdev
jhpratt Aug 7, 2026
7defe43
Rollup merge of #160433 - aerooneqq:delegation-return-wrapping-3, r=p…
jhpratt Aug 7, 2026
c9baaac
Rollup merge of #160530 - RalfJung:internal-target-features, r=nnethe…
jhpratt Aug 7, 2026
a5132fd
Rollup merge of #160606 - Zalathar:check-kind, r=Kobzol
jhpratt Aug 7, 2026
053799c
Rollup merge of #160628 - im-lunex:fix_#160591, r=JohnTitor
jhpratt Aug 7, 2026
13860a7
Rollup merge of #160634 - RalfJung:miri, r=RalfJung
jhpratt Aug 7, 2026
b4fc9b7
Rollup merge of #160683 - zakrad:regr-test-58390, r=estebank
jhpratt Aug 7, 2026
9f4b3dc
Rollup merge of #157641 - sjwang05:fix-143174-extern-static-promotion…
jhpratt Aug 7, 2026
cc2485b
Rollup merge of #158904 - KR-bluejay:issue-142559-fix, r=oli-obk
jhpratt Aug 7, 2026
93a1465
Rollup merge of #159816 - ssenthilnathan3:e0502-loop-mutate, r=camelid
jhpratt Aug 7, 2026
b01d87c
Rollup merge of #160103 - zakrad:regr-test-106832, r=tiif
jhpratt Aug 7, 2026
9d27f1b
Rollup merge of #160335 - sgasho:dlopen_offload, r=ZuseZ4
jhpratt Aug 7, 2026
fed24cc
Rollup merge of #160445 - rabindra789:fix/msvc-localized-linker-outpu…
jhpratt Aug 7, 2026
94fbfdd
Rollup merge of #160499 - mejrs:move_diagnostic_attr_not_found_lint, …
jhpratt Aug 7, 2026
e4b307c
Rollup merge of #160504 - lcnr:borrowck-cleanup, r=oli-obk
jhpratt Aug 7, 2026
2460209
Rollup merge of #160577 - petrochenkov:astgate, r=khyperia
jhpratt Aug 7, 2026
c95ac80
Rollup merge of #160587 - zakrad:regr-test-63253, r=JohnTitor
jhpratt Aug 7, 2026
9814e26
Rollup merge of #160625 - he32:update-netbsd-doc, r=nnethercote
jhpratt Aug 7, 2026
03ffa88
Rollup merge of #160633 - aerooneqq:delegation-fn-kind-ice, r=petroch…
jhpratt Aug 7, 2026
b7508da
Rollup merge of #160636 - RalfJung:derive-diagnostic, r=mejrs
jhpratt Aug 7, 2026
ce93a1b
Rollup merge of #160644 - mejrs:debug-impls, r=khyperia
jhpratt Aug 7, 2026
fe448ff
Rollup merge of #160649 - folkertdev:move-naked-ui-tests, r=chenyukang
jhpratt Aug 7, 2026
8d725bd
Rollup merge of #160658 - RalfJung:trivial-abi, r=oli-obk
jhpratt Aug 7, 2026
1037732
Rollup merge of #160672 - nnethercote:improve-MaybeLiveLocals, r=cjgi…
jhpratt Aug 7, 2026
08f4135
Rollup merge of #160693 - Kobzol:try-perf-branches, r=marcoieni
jhpratt Aug 7, 2026
138d748
Rollup merge of #160696 - durin42:llvm-24-nvptx-subtarget-rename, r=f…
jhpratt Aug 7, 2026
56427be
Rollup merge of #160706 - marcoieni:renovate-security-prs-auto, r=ubi…
jhpratt Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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