Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 759ba6a

Browse files
committed
Auto merge of #144995 - Zalathar:rollup-poqb8e0, r=Zalathar
Rollup of 21 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143679 (Preserve the .debug_gdb_scripts section) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps) - #144133 (Stabilize const TypeId::of) - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny) - #144473 (Address libunwind.a inconsistency issues in the bootstrap program) - #144498 (Add --print target-spec-json-schema) - #144552 (Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #144659 (bootstrap: refactor mingw dist and fix gnullvm) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) - #144836 (Change visibility of Args new function) - #144861 (Stabilize `panic_payload_as_str` feature) - #144910 (Add regression tests for seemingly fixed issues) - #144913 ([rustdoc] Fix wrong `i` tooltip icon) - #144917 (Enforce tail call type is related to body return type in borrowck) - #144924 (compiletest: add hint for when a ui test produces no errors) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dc0bae1 + c89b0b4 commit 759ba6a

File tree

203 files changed

+2179
-1302
lines changed

Some content is hidden

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

203 files changed

+2179
-1302
lines changed

‎Cargo.lock

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ version = "1.0.10"
12031203
source = "registry+https://github.com/rust-lang/crates.io-index"
12041204
checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921"
12051205

1206+
[[package]]
1207+
name = "dyn-clone"
1208+
version = "1.0.19"
1209+
source = "registry+https://github.com/rust-lang/crates.io-index"
1210+
checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005"
1211+
12061212
[[package]]
12071213
name = "either"
12081214
version = "1.15.0"
@@ -3196,6 +3202,26 @@ dependencies = [
31963202
"thiserror 2.0.12",
31973203
]
31983204

3205+
[[package]]
3206+
name = "ref-cast"
3207+
version = "1.0.24"
3208+
source = "registry+https://github.com/rust-lang/crates.io-index"
3209+
checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf"
3210+
dependencies = [
3211+
"ref-cast-impl",
3212+
]
3213+
3214+
[[package]]
3215+
name = "ref-cast-impl"
3216+
version = "1.0.24"
3217+
source = "registry+https://github.com/rust-lang/crates.io-index"
3218+
checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7"
3219+
dependencies = [
3220+
"proc-macro2",
3221+
"quote",
3222+
"syn 2.0.104",
3223+
]
3224+
31993225
[[package]]
32003226
name = "regex"
32013227
version = "1.11.1"
@@ -4650,6 +4676,7 @@ dependencies = [
46504676
"rustc_macros",
46514677
"rustc_serialize",
46524678
"rustc_span",
4679+
"schemars",
46534680
"serde",
46544681
"serde_derive",
46554682
"serde_json",
@@ -4964,6 +4991,31 @@ dependencies = [
49644991
"windows-sys 0.59.0",
49654992
]
49664993

4994+
[[package]]
4995+
name = "schemars"
4996+
version = "1.0.4"
4997+
source = "registry+https://github.com/rust-lang/crates.io-index"
4998+
checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0"
4999+
dependencies = [
5000+
"dyn-clone",
5001+
"ref-cast",
5002+
"schemars_derive",
5003+
"serde",
5004+
"serde_json",
5005+
]
5006+
5007+
[[package]]
5008+
name = "schemars_derive"
5009+
version = "1.0.4"
5010+
source = "registry+https://github.com/rust-lang/crates.io-index"
5011+
checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80"
5012+
dependencies = [
5013+
"proc-macro2",
5014+
"quote",
5015+
"serde_derive_internals",
5016+
"syn 2.0.104",
5017+
]
5018+
49675019
[[package]]
49685020
name = "scoped-tls"
49695021
version = "1.0.1"
@@ -5038,6 +5090,17 @@ dependencies = [
50385090
"syn 2.0.104",
50395091
]
50405092

5093+
[[package]]
5094+
name = "serde_derive_internals"
5095+
version = "0.29.1"
5096+
source = "registry+https://github.com/rust-lang/crates.io-index"
5097+
checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
5098+
dependencies = [
5099+
"proc-macro2",
5100+
"quote",
5101+
"syn 2.0.104",
5102+
]
5103+
50415104
[[package]]
50425105
name = "serde_json"
50435106
version = "1.0.142"

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
9898
}
9999

100100
let expr_hir_id = self.lower_node_id(e.id);
101-
self.lower_attrs(expr_hir_id, &e.attrs, e.span);
101+
let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span);
102102

103103
let kind = match &e.kind {
104104
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
@@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
232232
*fn_arg_span,
233233
),
234234
None => self.lower_expr_closure(
235+
attrs,
235236
binder,
236237
*capture_clause,
237238
e.id,
238-
expr_hir_id,
239239
*constness,
240240
*movability,
241241
fn_decl,
@@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
10521052

10531053
fn lower_expr_closure(
10541054
&mut self,
1055+
attrs: &[rustc_hir::Attribute],
10551056
binder: &ClosureBinder,
10561057
capture_clause: CaptureBy,
10571058
closure_id: NodeId,
1058-
closure_hir_id: hir::HirId,
10591059
constness: Const,
10601060
movability: Movability,
10611061
decl: &FnDecl,
@@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
10671067
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
10681068

10691069
let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
1070-
let mut coroutine_kind = if this
1071-
.attrs
1072-
.get(&closure_hir_id.local_id)
1073-
.is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
1074-
{
1075-
Some(hir::CoroutineKind::Coroutine(Movability::Movable))
1076-
} else {
1077-
None
1078-
};
1070+
1071+
let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));
1072+
10791073
// FIXME(contracts): Support contracts on closures?
10801074
let body_id = this.lower_fn_body(decl, None, |this| {
10811075
this.coroutine_kind = coroutine_kind;

‎compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ast_passes_auto_generic = auto traits cannot have generic parameters
4040
4141
ast_passes_auto_items = auto traits cannot have associated items
4242
.label = {ast_passes_auto_items}
43-
.suggestion = remove these associated items
43+
.suggestion = remove the associated items
4444
4545
ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetime bounds
4646
.label = {ast_passes_auto_super_lifetime}

‎compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,19 +699,23 @@ impl<'a> AstValidator<'a> {
699699
}
700700
}
701701

702-
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
702+
fn deny_super_traits(&self, bounds: &GenericBounds, ident: Span) {
703703
if let [.., last] = &bounds[..] {
704-
let span = ident_span.shrink_to_hi().to(last.span());
705-
self.dcx().emit_err(errors::AutoTraitBounds { span, ident: ident_span });
704+
let span = bounds.iter().map(|b| b.span()).collect();
705+
let removal = ident.shrink_to_hi().to(last.span());
706+
self.dcx().emit_err(errors::AutoTraitBounds { span, removal, ident });
706707
}
707708
}
708709

709-
fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) {
710+
fn deny_where_clause(&self, where_clause: &WhereClause, ident: Span) {
710711
if !where_clause.predicates.is_empty() {
711712
// FIXME: The current diagnostic is misleading since it only talks about
712713
// super trait and lifetime bounds while we should just say "bounds".
713-
self.dcx()
714-
.emit_err(errors::AutoTraitBounds { span: where_clause.span, ident: ident_span });
714+
self.dcx().emit_err(errors::AutoTraitBounds {
715+
span: vec![where_clause.span],
716+
removal: where_clause.span,
717+
ident,
718+
});
715719
}
716720
}
717721

‎compiler/rustc_ast_passes/src/errors.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub(crate) struct ModuleNonAscii {
344344
#[diag(ast_passes_auto_generic, code = E0567)]
345345
pub(crate) struct AutoTraitGeneric {
346346
#[primary_span]
347-
#[suggestion(code = "", applicability = "machine-applicable")]
347+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
348348
pub span: Span,
349349
#[label]
350350
pub ident: Span,
@@ -354,8 +354,9 @@ pub(crate) struct AutoTraitGeneric {
354354
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
355355
pub(crate) struct AutoTraitBounds {
356356
#[primary_span]
357-
#[suggestion(code = "", applicability = "machine-applicable")]
358-
pub span: Span,
357+
pub span: Vec<Span>,
358+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
359+
pub removal: Span,
359360
#[label]
360361
pub ident: Span,
361362
}
@@ -365,7 +366,7 @@ pub(crate) struct AutoTraitBounds {
365366
pub(crate) struct AutoTraitItems {
366367
#[primary_span]
367368
pub spans: Vec<Span>,
368-
#[suggestion(code = "", applicability = "machine-applicable")]
369+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
369370
pub total: Span,
370371
#[label]
371372
pub ident: Span,

‎compiler/rustc_attr_parsing/messages.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ attr_parsing_ill_formed_attribute_input = {$num_suggestions ->
3232
*[other] valid forms for the attribute are {$suggestions}
3333
}
3434
35+
attr_parsing_invalid_macro_export_arguments = {$num_suggestions ->
36+
[1] attribute must be of the form {$suggestions}
37+
*[other] valid forms for the attribute are {$suggestions}
38+
}
39+
3540
attr_parsing_incorrect_repr_format_align_one_arg =
3641
incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
3742
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Attributes that can be found in function body.
2+
3+
use rustc_hir::attrs::AttributeKind;
4+
use rustc_span::{Symbol, sym};
5+
6+
use super::{NoArgsAttributeParser, OnDuplicate};
7+
use crate::context::Stage;
8+
9+
pub(crate) struct CoroutineParser;
10+
11+
impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
12+
const PATH: &[Symbol] = &[sym::coroutine];
13+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
14+
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);
15+
}

‎compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
use rustc_errors::DiagArgValue;
22
use rustc_feature::{AttributeTemplate, template};
33
use rustc_hir::attrs::{AttributeKind, MacroUseArgs};
4+
use rustc_hir::lints::AttributeLintKind;
45
use rustc_span::{Span, Symbol, sym};
56
use thin_vec::ThinVec;
67

7-
use crate::attributes::{AcceptMapping, AttributeParser, NoArgsAttributeParser, OnDuplicate};
8+
use crate::attributes::{
9+
AcceptMapping, AttributeOrder, AttributeParser, NoArgsAttributeParser, OnDuplicate,
10+
SingleAttributeParser,
11+
};
812
use crate::context::{AcceptContext, FinalizeContext, Stage};
913
use crate::parser::ArgParser;
1014
use crate::session_diagnostics;
@@ -113,3 +117,58 @@ impl<S: Stage> AttributeParser<S> for MacroUseParser {
113117
Some(AttributeKind::MacroUse { span: self.first_span?, arguments: self.state })
114118
}
115119
}
120+
121+
pub(crate) struct MacroExportParser;
122+
123+
impl<S: Stage> SingleAttributeParser<S> for crate::attributes::macro_attrs::MacroExportParser {
124+
const PATH: &[Symbol] = &[sym::macro_export];
125+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
126+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
127+
const TEMPLATE: AttributeTemplate = template!(Word, List: "local_inner_macros");
128+
129+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
130+
let suggestions =
131+
|| <Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "macro_export");
132+
let local_inner_macros = match args {
133+
ArgParser::NoArgs => false,
134+
ArgParser::List(list) => {
135+
let Some(l) = list.single() else {
136+
let span = cx.attr_span;
137+
cx.emit_lint(
138+
AttributeLintKind::InvalidMacroExportArguments {
139+
suggestions: suggestions(),
140+
},
141+
span,
142+
);
143+
return None;
144+
};
145+
match l.meta_item().and_then(|i| i.path().word_sym()) {
146+
Some(sym::local_inner_macros) => true,
147+
_ => {
148+
let span = cx.attr_span;
149+
cx.emit_lint(
150+
AttributeLintKind::InvalidMacroExportArguments {
151+
suggestions: suggestions(),
152+
},
153+
span,
154+
);
155+
return None;
156+
}
157+
}
158+
}
159+
ArgParser::NameValue(_) => {
160+
let span = cx.attr_span;
161+
let suggestions = suggestions();
162+
cx.emit_err(session_diagnostics::IllFormedAttributeInputLint {
163+
num_suggestions: suggestions.len(),
164+
suggestions: DiagArgValue::StrListSepByAnd(
165+
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
166+
),
167+
span,
168+
});
169+
return None;
170+
}
171+
};
172+
Some(AttributeKind::MacroExport { span: cx.attr_span, local_inner_macros })
173+
}
174+
}

‎compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::parser::ArgParser;
2626
use crate::session_diagnostics::UnusedMultiple;
2727

2828
pub(crate) mod allow_unstable;
29+
pub(crate) mod body;
2930
pub(crate) mod cfg;
3031
pub(crate) mod cfg_old;
3132
pub(crate) mod codegen_attrs;

‎compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1616
use crate::attributes::allow_unstable::{
1717
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
1818
};
19+
use crate::attributes::body::CoroutineParser;
1920
use crate::attributes::codegen_attrs::{
2021
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser,
2122
TargetFeatureParser, TrackCallerParser, UsedParser,
@@ -32,7 +33,7 @@ use crate::attributes::lint_helpers::{
3233
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
3334
};
3435
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
35-
use crate::attributes::macro_attrs::{MacroEscapeParser, MacroUseParser};
36+
use crate::attributes::macro_attrs::{MacroEscapeParser, MacroExportParser,MacroUseParser};
3637
use crate::attributes::must_use::MustUseParser;
3738
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
3839
use crate::attributes::non_exhaustive::NonExhaustiveParser;
@@ -164,6 +165,7 @@ attribute_parsers!(
164165
Single<LinkNameParser>,
165166
Single<LinkOrdinalParser>,
166167
Single<LinkSectionParser>,
168+
Single<MacroExportParser>,
167169
Single<MustUseParser>,
168170
Single<OptimizeParser>,
169171
Single<PathAttributeParser>,
@@ -184,6 +186,7 @@ attribute_parsers!(
184186
Single<WithoutArgs<ConstContinueParser>>,
185187
Single<WithoutArgs<ConstStabilityIndirectParser>>,
186188
Single<WithoutArgs<ConstTraitParser>>,
189+
Single<WithoutArgs<CoroutineParser>>,
187190
Single<WithoutArgs<DenyExplicitImplParser>>,
188191
Single<WithoutArgs<DoNotImplementViaObjectParser>>,
189192
Single<WithoutArgs<ExportStableParser>>,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /