Skip to content

Commit e238223

Browse files
committed
Auto merge of #158228 - JonathanBrouwer:rollup-AUgEk0s, r=JonathanBrouwer
Rollup of 9 pull requests Successful merges: - #156356 (bootstrap: add bootstrap step to run intrinsic-test in CI) - #157711 (Move proc-macro dlopen from proc-macro-srv to rustc_metadata) - #157836 (rebuild LLVM when `bootstrap.toml` config changes) - #158214 (Don't try to remove assignments in SimplifyComparisonIntegral) - #158226 (miri subtree update) - #158108 (Update actions/download-artifact action to v8.0.1) - #158150 (Update backtrace submodule to pick up AIX related fixes.) - #158178 (Use the target checking infrastructure for the diagnostic attributes) - #158195 (Add me to some rotation groups)
2 parents 91fe22d + 4849b10 commit e238223

90 files changed

Lines changed: 1012 additions & 891 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/dependencies.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ jobs:
9494
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
9595

9696
- name: download Cargo.lock from update job
97-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
97+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
9898
with:
9999
name: Cargo-lock
100100
- name: download cargo-update log from update job
101-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
101+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
102102
with:
103103
name: cargo-updates
104104

Cargo.lock

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,6 @@ dependencies = [
300300
"serde",
301301
]
302302

303-
[[package]]
304-
name = "bincode"
305-
version = "1.3.3"
306-
source = "registry+https://github.com/rust-lang/crates.io-index"
307-
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
308-
dependencies = [
309-
"serde",
310-
]
311-
312303
[[package]]
313304
name = "bitflags"
314305
version = "2.10.0"
@@ -2106,18 +2097,19 @@ dependencies = [
21062097

21072098
[[package]]
21082099
name = "ipc-channel"
2109-
version = "0.20.2"
2100+
version = "0.22.0"
21102101
source = "registry+https://github.com/rust-lang/crates.io-index"
2111-
checksum = "f93600b5616c2d075f8af8dbd23c1d69278c5d24e4913d220cbc60b14c95c180"
2102+
checksum = "347ef783e380784658248bdb0b87ca1293e3e3df3fc7dee061e129aa5f013d61"
21122103
dependencies = [
2113-
"bincode",
21142104
"crossbeam-channel",
2115-
"fnv",
21162105
"libc",
21172106
"mio",
2107+
"postcard",
21182108
"rand 0.9.2",
2119-
"serde",
2109+
"rustc-hash 2.1.1",
2110+
"serde_core",
21202111
"tempfile",
2112+
"thiserror 2.0.17",
21212113
"uuid",
21222114
"windows 0.61.3",
21232115
]
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::Target;
33
use rustc_hir::attrs::AttributeKind;
4-
use rustc_session::lint::builtin::{
5-
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MISPLACED_DIAGNOSTIC_ATTRIBUTES,
6-
};
4+
use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES;
75
use rustc_span::{Symbol, sym};
86

7+
use crate::attributes::prelude::Allow;
98
use crate::attributes::{OnDuplicate, SingleAttributeParser};
109
use crate::context::AcceptContext;
11-
use crate::diagnostics::IncorrectDoNotRecommendLocation;
1210
use crate::parser::ArgParser;
13-
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
11+
use crate::target_checking::AllowedTargets;
1412
use crate::{AttributeTemplate, template};
1513

1614
pub(crate) struct DoNotRecommendParser;
1715
impl SingleAttributeParser for DoNotRecommendParser {
1816
const PATH: &[Symbol] = &[sym::diagnostic, sym::do_not_recommend];
1917
const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn;
2018
// "Allowed" on any target, noop on all but trait impls
21-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
19+
const ALLOWED_TARGETS: AllowedTargets =
20+
AllowedTargets::AllowListWarnRest(&[Allow(Target::Impl { of_trait: true })]);
2221
const TEMPLATE: AttributeTemplate = template!(Word /*doesn't matter */);
2322
const STABILITY: AttributeStability = AttributeStability::Stable;
2423

@@ -32,16 +31,6 @@ impl SingleAttributeParser for DoNotRecommendParser {
3231
);
3332
}
3433

35-
if !matches!(cx.target, Target::Impl { of_trait: true }) {
36-
let target_span = cx.target_span;
37-
cx.emit_lint(
38-
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
39-
IncorrectDoNotRecommendLocation { target_span },
40-
attr_span,
41-
);
42-
return None;
43-
}
44-
4534
Some(AttributeKind::DoNotRecommend)
4635
}
4736
}

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::diagnostic::Directive;
3-
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
43

54
use crate::attributes::diagnostic::*;
65
use crate::attributes::prelude::*;
7-
use crate::diagnostics::DiagnosticOnConstOnlyForTraitImpls;
86
#[derive(Default)]
97
pub(crate) struct OnConstParser {
108
span: Option<Span>,
@@ -26,18 +24,6 @@ impl AttributeParser for OnConstParser {
2624
let span = cx.attr_span;
2725
this.span = Some(span);
2826

29-
// FIXME(mejrs) no constness field on `Target`,
30-
// so non-constness is still checked in check_attr.rs
31-
if !matches!(cx.target, Target::Impl { of_trait: true }) {
32-
let target_span = cx.target_span;
33-
cx.emit_lint(
34-
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
35-
DiagnosticOnConstOnlyForTraitImpls { target_span },
36-
span,
37-
);
38-
return;
39-
}
40-
4127
let mode = Mode::DiagnosticOnConst;
4228

4329
let Some(items) = parse_list(cx, args, mode) else { return };
@@ -51,7 +37,11 @@ impl AttributeParser for OnConstParser {
5137

5238
// "Allowed" on all targets; noop on anything but non-const trait impls;
5339
// this linted on in parser.
54-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
40+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
41+
// FIXME(mejrs) no constness field on `Target`,
42+
// so non-constness is still checked in check_attr.rs
43+
Allow(Target::Impl { of_trait: true }),
44+
]);
5545

5646
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
5747
if let Some(span) = self.span {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::AttributeKind;
3-
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
43
use rustc_span::sym;
54

65
use crate::attributes::diagnostic::*;
76
use crate::attributes::prelude::*;
87
use crate::context::AcceptContext;
9-
use crate::diagnostics::DiagnosticOnMoveOnlyForAdt;
108
use crate::parser::ArgParser;
11-
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
9+
use crate::target_checking::AllowedTargets;
1210
use crate::template;
1311

1412
#[derive(Default)]
@@ -28,11 +26,6 @@ impl OnMoveParser {
2826
let span = cx.attr_span;
2927
self.span = Some(span);
3028

31-
if !matches!(cx.target, Target::Enum | Target::Struct | Target::Union) {
32-
cx.emit_lint(MISPLACED_DIAGNOSTIC_ATTRIBUTES, DiagnosticOnMoveOnlyForAdt, span);
33-
return;
34-
}
35-
3629
let Some(items) = parse_list(cx, args, mode) else { return };
3730

3831
if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
@@ -50,8 +43,11 @@ impl AttributeParser for OnMoveParser {
5043
},
5144
)];
5245

53-
// "Allowed" for all targets but noop if used on not-adt.
54-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
46+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
47+
Allow(Target::Enum),
48+
Allow(Target::Struct),
49+
Allow(Target::Union),
50+
]);
5551

5652
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
5753
if let Some(_span) = self.span {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use rustc_hir::attrs::AttributeKind;
2-
use rustc_lint_defs::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
32
use rustc_span::sym;
43

54
use crate::attributes::AttributeStability;
65
use crate::attributes::diagnostic::*;
76
use crate::attributes::prelude::*;
87
use crate::context::AcceptContext;
9-
use crate::diagnostics::DiagnosticOnTypeErrorOnlyForAdt;
108
use crate::parser::ArgParser;
11-
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
9+
use crate::target_checking::AllowedTargets;
1210
use crate::template;
1311

1412
#[derive(Default)]
@@ -26,11 +24,6 @@ impl OnTypeErrorParser {
2624
let span = cx.attr_span;
2725
self.span = Some(span);
2826

29-
if !matches!(cx.target, Target::Enum | Target::Struct | Target::Union) {
30-
cx.emit_lint(MISPLACED_DIAGNOSTIC_ATTRIBUTES, DiagnosticOnTypeErrorOnlyForAdt, span);
31-
return;
32-
}
33-
3427
let Some(items) = parse_list(cx, args, mode) else { return };
3528

3629
if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
@@ -49,7 +42,11 @@ impl AttributeParser for OnTypeErrorParser {
4942
},
5043
)];
5144

52-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
45+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
46+
Allow(Target::Enum),
47+
Allow(Target::Struct),
48+
Allow(Target::Union),
49+
]);
5350

5451
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
5552
if let Some(span) = self.span {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::diagnostic::Directive;
3-
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
43

54
use crate::attributes::diagnostic::*;
65
use crate::attributes::prelude::*;
7-
use crate::diagnostics::DiagnosticOnUnimplementedOnlyForTraits;
86

97
#[derive(Default)]
108
pub(crate) struct OnUnimplementedParser {
@@ -17,15 +15,6 @@ impl OnUnimplementedParser {
1715
let span = cx.attr_span;
1816
self.span = Some(span);
1917

20-
if !matches!(cx.target, Target::Trait) {
21-
cx.emit_lint(
22-
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
23-
DiagnosticOnUnimplementedOnlyForTraits,
24-
span,
25-
);
26-
return;
27-
}
28-
2918
let Some(items) = parse_list(cx, args, mode) else { return };
3019

3120
if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
@@ -56,8 +45,8 @@ impl AttributeParser for OnUnimplementedParser {
5645
},
5746
),
5847
];
59-
//FIXME attribute is not parsed for non-traits but diagnostics are issued in `check_attr.rs`
60-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
48+
const ALLOWED_TARGETS: AllowedTargets =
49+
AllowedTargets::AllowListWarnRest(&[Allow(Target::Trait)]);
6150

6251
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
6352
if let Some(_span) = self.span {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::diagnostic::Directive;
3-
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
43

5-
use crate::ShouldEmit;
64
use crate::attributes::diagnostic::*;
75
use crate::attributes::prelude::*;
8-
use crate::diagnostics::DiagnosticOnUnknownInvalidTarget;
96

107
#[derive(Default)]
118
pub(crate) struct OnUnknownParser {
@@ -25,20 +22,6 @@ impl OnUnknownParser {
2522
let span = cx.attr_span;
2623
self.span = Some(span);
2724

28-
// At early parsing we get passed `Target::Crate` regardless of the item we're on.
29-
// Therefore, only do target checking if we can emit.
30-
let early = matches!(cx.should_emit, ShouldEmit::Nothing);
31-
32-
if !early && !matches!(cx.target, Target::Use | Target::Mod | Target::Crate) {
33-
let target_span = cx.target_span;
34-
cx.emit_lint(
35-
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
36-
DiagnosticOnUnknownInvalidTarget { target_span },
37-
span,
38-
);
39-
return;
40-
}
41-
4225
let Some(items) = parse_list(cx, args, mode) else { return };
4326

4427
if let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) {
@@ -57,7 +40,11 @@ impl AttributeParser for OnUnknownParser {
5740
},
5841
)];
5942
// "Allowed" for all targets, but noop for all but use statements.
60-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
43+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
44+
Allow(Target::Use),
45+
Allow(Target::Mod),
46+
Allow(Target::Crate),
47+
]);
6148

6249
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
6350
if let Some(_span) = self.span {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::diagnostic::Directive;
3-
use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES;
43

54
use crate::attributes::diagnostic::*;
65
use crate::attributes::prelude::*;
7-
use crate::diagnostics::DiagnosticOnUnmatchedArgsOnlyForMacros;
86

97
#[derive(Default)]
108
pub(crate) struct OnUnmatchedArgsParser {
@@ -25,15 +23,6 @@ impl AttributeParser for OnUnmatchedArgsParser {
2523
let span = cx.attr_span;
2624
this.span = Some(span);
2725

28-
if !matches!(cx.target, Target::MacroDef) {
29-
cx.emit_lint(
30-
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
31-
DiagnosticOnUnmatchedArgsOnlyForMacros,
32-
span,
33-
);
34-
return;
35-
}
36-
3726
let mode = Mode::DiagnosticOnUnmatchedArgs;
3827
let Some(items) = parse_list(cx, args, mode) else { return };
3928

@@ -44,7 +33,8 @@ impl AttributeParser for OnUnmatchedArgsParser {
4433
},
4534
)];
4635

47-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
36+
const ALLOWED_TARGETS: AllowedTargets =
37+
AllowedTargets::AllowListWarnRest(&[Allow(Target::MacroDef)]);
4838

4939
fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option<AttributeKind> {
5040
if let Some(_span) = self.span {

compiler/rustc_attr_parsing/src/diagnostics.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -279,45 +279,6 @@ pub(crate) struct UnknownCrateTypesSuggestion {
279279
pub snippet: Symbol,
280280
}
281281

282-
#[derive(Diagnostic)]
283-
#[diag("`#[diagnostic::on_const]` can only be applied to non-const trait implementations")]
284-
pub(crate) struct DiagnosticOnConstOnlyForTraitImpls {
285-
#[label("not a trait implementation")]
286-
pub target_span: Span,
287-
}
288-
289-
#[derive(Diagnostic)]
290-
#[diag("`#[diagnostic::on_move]` can only be applied to enums, structs or unions")]
291-
pub(crate) struct DiagnosticOnMoveOnlyForAdt;
292-
293-
#[derive(Diagnostic)]
294-
#[diag("`#[diagnostic::on_unimplemented]` can only be applied to trait definitions")]
295-
pub(crate) struct DiagnosticOnUnimplementedOnlyForTraits;
296-
297-
#[derive(Diagnostic)]
298-
#[diag(
299-
"`#[diagnostic::on_unknown]` can only be applied to `use` statements and module declarations"
300-
)]
301-
pub(crate) struct DiagnosticOnUnknownInvalidTarget {
302-
#[label("not an import or module")]
303-
pub target_span: Span,
304-
}
305-
306-
#[derive(Diagnostic)]
307-
#[diag("`#[diagnostic::on_unmatched_args]` can only be applied to macro definitions")]
308-
pub(crate) struct DiagnosticOnUnmatchedArgsOnlyForMacros;
309-
310-
#[derive(Diagnostic)]
311-
#[diag("`#[diagnostic::on_type_error]` can only be applied to enums, structs or unions")]
312-
pub(crate) struct DiagnosticOnTypeErrorOnlyForAdt;
313-
314-
#[derive(Diagnostic)]
315-
#[diag("`#[diagnostic::do_not_recommend]` can only be placed on trait implementations")]
316-
pub(crate) struct IncorrectDoNotRecommendLocation {
317-
#[label("not a trait implementation")]
318-
pub target_span: Span,
319-
}
320-
321282
#[derive(Diagnostic)]
322283
#[diag("malformed `doc` attribute input")]
323284
#[warning(

0 commit comments

Comments
 (0)