Skip to content

Commit 34f954f

Browse files
committed
Auto merge of rust-lang#148100 - matthiaskrgr:rollup-vrd4wy8, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#143361 (Stop passing resolver disambiguator state to AST lowering.) - rust-lang#148000 (Improvements to attribute suggestions) - rust-lang#148007 (chore: Update to the latest annotate-snippets) - rust-lang#148088 (compiletest: Simplify passing arguments to spawned test threads) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 79966ae + d4f0f35 commit 34f954f

File tree

35 files changed

+973
-270
lines changed

35 files changed

+973
-270
lines changed

Cargo.lock

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7575
checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4"
7676
dependencies = [
7777
"anstyle",
78-
"unicode-width 0.2.1",
78+
"unicode-width 0.2.2",
79+
]
80+
81+
[[package]]
82+
name = "annotate-snippets"
83+
version = "0.12.7"
84+
source = "registry+https://github.com/rust-lang/crates.io-index"
85+
checksum = "47224528f74de27d1d06aad6a5dda4f865b6ebe2e56c538943d746a7270cb67e"
86+
dependencies = [
87+
"anstyle",
88+
"unicode-width 0.2.2",
7989
]
8090

8191
[[package]]
@@ -136,7 +146,7 @@ dependencies = [
136146
"anstyle-lossy",
137147
"anstyle-parse",
138148
"html-escape",
139-
"unicode-width 0.2.1",
149+
"unicode-width 0.2.2",
140150
]
141151

142152
[[package]]
@@ -677,7 +687,7 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
677687
dependencies = [
678688
"serde",
679689
"termcolor",
680-
"unicode-width 0.2.1",
690+
"unicode-width 0.2.2",
681691
]
682692

683693
[[package]]
@@ -808,7 +818,7 @@ dependencies = [
808818
"encode_unicode",
809819
"libc",
810820
"once_cell",
811-
"unicode-width 0.2.1",
821+
"unicode-width 0.2.2",
812822
"windows-sys 0.59.0",
813823
]
814824

@@ -1485,7 +1495,7 @@ version = "0.2.24"
14851495
source = "registry+https://github.com/rust-lang/crates.io-index"
14861496
checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df"
14871497
dependencies = [
1488-
"unicode-width 0.2.1",
1498+
"unicode-width 0.2.2",
14891499
]
14901500

14911501
[[package]]
@@ -1887,7 +1897,7 @@ dependencies = [
18871897
"console",
18881898
"number_prefix",
18891899
"portable-atomic",
1890-
"unicode-width 0.2.1",
1900+
"unicode-width 0.2.2",
18911901
"web-time",
18921902
]
18931903

@@ -3756,7 +3766,7 @@ dependencies = [
37563766
name = "rustc_errors"
37573767
version = "0.0.0"
37583768
dependencies = [
3759-
"annotate-snippets 0.11.5",
3769+
"annotate-snippets 0.12.7",
37603770
"anstream",
37613771
"anstyle",
37623772
"derive_setters",
@@ -4331,7 +4341,7 @@ dependencies = [
43314341
"thin-vec",
43324342
"tracing",
43334343
"unicode-normalization",
4334-
"unicode-width 0.2.1",
4344+
"unicode-width 0.2.2",
43354345
]
43364346

43374347
[[package]]
@@ -4590,7 +4600,7 @@ dependencies = [
45904600
"sha1",
45914601
"sha2",
45924602
"tracing",
4593-
"unicode-width 0.2.1",
4603+
"unicode-width 0.2.2",
45944604
]
45954605

45964606
[[package]]
@@ -5936,9 +5946,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
59365946

59375947
[[package]]
59385948
name = "unicode-width"
5939-
version = "0.2.1"
5949+
version = "0.2.2"
59405950
source = "registry+https://github.com/rust-lang/crates.io-index"
5941-
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
5951+
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
59425952

59435953
[[package]]
59445954
name = "unicode-xid"
@@ -6223,7 +6233,7 @@ dependencies = [
62236233
"bumpalo",
62246234
"leb128fmt",
62256235
"memchr",
6226-
"unicode-width 0.2.1",
6236+
"unicode-width 0.2.2",
62276237
"wasm-encoder 0.240.0",
62286238
]
62296239

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
77
use rustc_hir as hir;
88
use rustc_hir::attrs::AttributeKind;
99
use rustc_hir::def::{DefKind, Res};
10+
use rustc_hir::definitions::DefPathData;
1011
use rustc_hir::{HirId, Target, find_attr};
1112
use rustc_middle::span_bug;
1213
use rustc_middle::ty::TyCtxt;
@@ -461,7 +462,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
461462
for (idx, arg) in args.iter().cloned().enumerate() {
462463
if legacy_args_idx.contains(&idx) {
463464
let node_id = self.next_node_id();
464-
self.create_def(node_id, None, DefKind::AnonConst, f.span);
465+
self.create_def(
466+
node_id,
467+
None,
468+
DefKind::AnonConst,
469+
DefPathData::LateAnonConst,
470+
f.span,
471+
);
465472
let mut visitor = WillCreateDefIdsVisitor {};
466473
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
467474
Box::new(Expr {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use rustc_data_structures::tagged_ptr::TaggedRef;
5151
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
5252
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5353
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
54+
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
5455
use rustc_hir::lints::DelayedLint;
5556
use rustc_hir::{
5657
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
@@ -93,6 +94,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
9394
struct LoweringContext<'a, 'hir> {
9495
tcx: TyCtxt<'hir>,
9596
resolver: &'a mut ResolverAstLowering,
97+
disambiguator: DisambiguatorState,
9698

9799
/// Used to allocate HIR nodes.
98100
arena: &'hir hir::Arena<'hir>,
@@ -155,6 +157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
155157
// Pseudo-globals.
156158
tcx,
157159
resolver,
160+
disambiguator: DisambiguatorState::new(),
158161
arena: tcx.hir_arena,
159162

160163
// HirId handling.
@@ -546,6 +549,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
546549
node_id: ast::NodeId,
547550
name: Option<Symbol>,
548551
def_kind: DefKind,
552+
def_path_data: DefPathData,
549553
span: Span,
550554
) -> LocalDefId {
551555
let parent = self.current_hir_id_owner.def_id;
@@ -561,7 +565,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
561565
let def_id = self
562566
.tcx
563567
.at(span)
564-
.create_def(parent, name, def_kind, None, &mut self.resolver.disambiguator)
568+
.create_def(parent, name, def_kind, Some(def_path_data), &mut self.disambiguator)
565569
.def_id();
566570

567571
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
@@ -846,6 +850,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
846850
param,
847851
Some(kw::UnderscoreLifetime),
848852
DefKind::LifetimeParam,
853+
DefPathData::DesugaredAnonymousLifetime,
849854
ident.span,
850855
);
851856
debug!(?_def_id);
@@ -2290,7 +2295,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22902295
// We're lowering a const argument that was originally thought to be a type argument,
22912296
// so the def collector didn't create the def ahead of time. That's why we have to do
22922297
// it here.
2293-
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2298+
let def_id = self.create_def(
2299+
node_id,
2300+
None,
2301+
DefKind::AnonConst,
2302+
DefPathData::LateAnonConst,
2303+
span,
2304+
);
22942305
let hir_id = self.lower_node_id(node_id);
22952306

22962307
let path_expr = Expr {

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::Arc;
33
use rustc_ast::*;
44
use rustc_data_structures::stack::ensure_sufficient_stack;
55
use rustc_hir::def::{DefKind, Res};
6+
use rustc_hir::definitions::DefPathData;
67
use rustc_hir::{self as hir, LangItem, Target};
78
use rustc_middle::span_bug;
89
use rustc_span::source_map::{Spanned, respan};
@@ -527,7 +528,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
527528
// We're generating a range end that didn't exist in the AST,
528529
// so the def collector didn't create the def ahead of time. That's why we have to do
529530
// it here.
530-
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
531+
let def_id =
532+
self.create_def(node_id, None, DefKind::AnonConst, DefPathData::LateAnonConst, span);
531533
let hir_id = self.lower_node_id(node_id);
532534

533535
let unstable_span = self.mark_span_with_reason(

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ pub fn parse_cfg_attr(
326326
}) {
327327
Ok(r) => return Some(r),
328328
Err(e) => {
329-
let suggestions = CFG_ATTR_TEMPLATE.suggestions(cfg_attr.style, sym::cfg_attr);
329+
let suggestions =
330+
CFG_ATTR_TEMPLATE.suggestions(Some(cfg_attr.style), sym::cfg_attr);
330331
e.with_span_suggestions(
331332
cfg_attr.span,
332333
"must be of the form",
@@ -356,7 +357,7 @@ pub fn parse_cfg_attr(
356357
template: CFG_ATTR_TEMPLATE,
357358
attribute: AttrPath::from_ast(&cfg_attr.get_normal_item().path),
358359
reason,
359-
attr_style: cfg_attr.style,
360+
suggestions: CFG_ATTR_TEMPLATE.suggestions(Some(cfg_attr.style), sym::cfg_attr),
360361
});
361362
}
362363
}
@@ -388,6 +389,7 @@ fn parse_cfg_attr_internal<'a>(
388389
let cfg_predicate = AttributeParser::parse_single_args(
389390
sess,
390391
attribute.span,
392+
attribute.get_normal_item().span(),
391393
attribute.style,
392394
AttrPath {
393395
segments: attribute

compiler/rustc_attr_parsing/src/attributes/inline.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ impl<S: Stage> SingleAttributeParser<S> for InlineParser {
5656
}
5757
}
5858
ArgParser::NameValue(_) => {
59-
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
60-
.suggestions(cx.attr_style, "inline");
59+
let suggestions = cx.suggestions();
6160
let span = cx.attr_span;
6261
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
6362
return None;

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
7171
// Specifically `#[link = "dl"]` is accepted with a FCW
7272
// For more information, see https://github.com/rust-lang/rust/pull/143193
7373
ArgParser::NameValue(nv) if nv.value_as_str().is_some_and(|v| v == sym::dl) => {
74-
let suggestions = <Self as CombineAttributeParser<S>>::TEMPLATE
75-
.suggestions(cx.attr_style, "link");
74+
let suggestions = cx.suggestions();
7675
let span = cx.attr_span;
7776
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
7877
return None;

compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rustc_ast::AttrStyle;
21
use rustc_errors::DiagArgValue;
32
use rustc_hir::attrs::MacroUseArgs;
43

@@ -102,7 +101,7 @@ impl<S: Stage> AttributeParser<S> for MacroUseParser {
102101
}
103102
}
104103
ArgParser::NameValue(_) => {
105-
let suggestions = MACRO_USE_TEMPLATE.suggestions(cx.attr_style, sym::macro_use);
104+
let suggestions = cx.suggestions();
106105
cx.emit_err(IllFormedAttributeInputLint {
107106
num_suggestions: suggestions.len(),
108107
suggestions: DiagArgValue::StrListSepByAnd(
@@ -149,19 +148,14 @@ impl<S: Stage> SingleAttributeParser<S> for MacroExportParser {
149148
]);
150149

151150
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
152-
let suggestions = || {
153-
<Self as SingleAttributeParser<S>>::TEMPLATE
154-
.suggestions(AttrStyle::Inner, "macro_export")
155-
};
156151
let local_inner_macros = match args {
157152
ArgParser::NoArgs => false,
158153
ArgParser::List(list) => {
159154
let Some(l) = list.single() else {
160155
let span = cx.attr_span;
156+
let suggestions = cx.suggestions();
161157
cx.emit_lint(
162-
AttributeLintKind::InvalidMacroExportArguments {
163-
suggestions: suggestions(),
164-
},
158+
AttributeLintKind::InvalidMacroExportArguments { suggestions },
165159
span,
166160
);
167161
return None;
@@ -170,10 +164,9 @@ impl<S: Stage> SingleAttributeParser<S> for MacroExportParser {
170164
Some(sym::local_inner_macros) => true,
171165
_ => {
172166
let span = cx.attr_span;
167+
let suggestions = cx.suggestions();
173168
cx.emit_lint(
174-
AttributeLintKind::InvalidMacroExportArguments {
175-
suggestions: suggestions(),
176-
},
169+
AttributeLintKind::InvalidMacroExportArguments { suggestions },
177170
span,
178171
);
179172
return None;
@@ -182,7 +175,7 @@ impl<S: Stage> SingleAttributeParser<S> for MacroExportParser {
182175
}
183176
ArgParser::NameValue(_) => {
184177
let span = cx.attr_span;
185-
let suggestions = suggestions();
178+
let suggestions = cx.suggestions();
186179
cx.emit_err(IllFormedAttributeInputLint {
187180
num_suggestions: suggestions.len(),
188181
suggestions: DiagArgValue::StrListSepByAnd(

compiler/rustc_attr_parsing/src/attributes/must_use.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
4545
Some(value_str)
4646
}
4747
ArgParser::List(_) => {
48-
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
49-
.suggestions(cx.attr_style, "must_use");
48+
let suggestions = cx.suggestions();
5049
cx.emit_err(IllFormedAttributeInputLint {
5150
num_suggestions: suggestions.len(),
5251
suggestions: DiagArgValue::StrListSepByAnd(

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
2020
ArgParser::NoArgs => None,
2121
ArgParser::NameValue(name_value) => {
2222
let Some(str_value) = name_value.value_as_str() else {
23-
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
24-
.suggestions(cx.attr_style, "ignore");
23+
let suggestions = cx.suggestions();
2524
let span = cx.attr_span;
2625
cx.emit_lint(
2726
AttributeLintKind::IllFormedAttributeInput { suggestions },
@@ -32,8 +31,7 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
3231
Some(str_value)
3332
}
3433
ArgParser::List(_) => {
35-
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
36-
.suggestions(cx.attr_style, "ignore");
34+
let suggestions = cx.suggestions();
3735
let span = cx.attr_span;
3836
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
3937
return None;

0 commit comments

Comments
 (0)