Skip to content

Commit 1c55a27

Browse files
author
The Miri Cronjob Bot
committed
Merge ref '3507a749b365' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 3507a74 Filtered ref: 67f9124a1e199effc310447c1c1f9548093bd8f9 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents a490578 + f3ef465 commit 1c55a27

File tree

424 files changed

+7994
-5876
lines changed

Some content is hidden

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

424 files changed

+7994
-5876
lines changed

.editorconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ root = true
77
[*]
88
end_of_line = lf
99
charset = utf-8
10-
trim_trailing_whitespace = true
1110
insert_final_newline = true
1211

12+
# some tests need trailing whitespace in output snapshots
13+
[!tests/]
14+
trim_trailing_whitespace = true
15+
# for actual source code files of test, we still don't want trailing whitespace
16+
[tests/**.{rs,js}]
17+
trim_trailing_whitespace = true
18+
# these specific source files need to have trailing whitespace.
19+
[tests/ui/{frontmatter/frontmatter-whitespace-3.rs,parser/shebang/shebang-space.rs}]
20+
trim_trailing_whitespace = false
21+
1322
[!src/llvm-project]
1423
indent_style = space
1524
indent_size = 4

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
run_type: ${{ steps.jobs.outputs.run_type }}
5353
steps:
5454
- name: Checkout the source code
55-
uses: actions/checkout@v4
55+
uses: actions/checkout@v5
5656
- name: Test citool
5757
# Only test citool on the auto branch, to reduce latency of the calculate matrix job
5858
# on PR/try builds.
@@ -113,7 +113,7 @@ jobs:
113113
run: git config --global core.autocrlf false
114114

115115
- name: checkout the source code
116-
uses: actions/checkout@v4
116+
uses: actions/checkout@v5
117117
with:
118118
fetch-depth: 2
119119

@@ -313,7 +313,7 @@ jobs:
313313
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
314314
steps:
315315
- name: checkout the source code
316-
uses: actions/checkout@v4
316+
uses: actions/checkout@v5
317317
with:
318318
fetch-depth: 2
319319
# Calculate the exit status of the whole CI workflow.

.github/workflows/dependencies.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-24.04
5252
steps:
5353
- name: checkout the source code
54-
uses: actions/checkout@v4
54+
uses: actions/checkout@v5
5555
with:
5656
submodules: recursive
5757
- name: install the bootstrap toolchain
@@ -101,7 +101,7 @@ jobs:
101101
pull-requests: write
102102
steps:
103103
- name: checkout the source code
104-
uses: actions/checkout@v4
104+
uses: actions/checkout@v5
105105

106106
- name: download Cargo.lock from update job
107107
uses: actions/download-artifact@v4

.github/workflows/ghcr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
# Needed to write to the ghcr.io registry
3030
packages: write
3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
3333
with:
3434
persist-credentials: false
3535

.github/workflows/post-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
permissions:
1616
pull-requests: write
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
with:
2020
# Make sure that we have enough commits to find the parent merge commit.
2121
# Since all merges should be through merge commits, fetching two commits

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,7 @@ dependencies = [
34803480
name = "rustc_attr_parsing"
34813481
version = "0.0.0"
34823482
dependencies = [
3483+
"itertools",
34833484
"rustc_abi",
34843485
"rustc_ast",
34853486
"rustc_ast_pretty",
@@ -3889,6 +3890,7 @@ dependencies = [
38893890
name = "rustc_hir"
38903891
version = "0.0.0"
38913892
dependencies = [
3893+
"bitflags",
38923894
"odht",
38933895
"rustc_abi",
38943896
"rustc_arena",

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind};
22
use rustc_hir as hir;
3+
use rustc_hir::Target;
34
use rustc_span::sym;
45
use smallvec::SmallVec;
56

@@ -109,7 +110,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
109110
};
110111
let span = self.lower_span(l.span);
111112
let source = hir::LocalSource::Normal;
112-
self.lower_attrs(hir_id, &l.attrs, l.span);
113+
self.lower_attrs(hir_id, &l.attrs, l.span, Target::Statement);
113114
self.arena.alloc(hir::LetStmt { hir_id, super_, ty, pat, init, els, span, source })
114115
}
115116

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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::{HirId, find_attr};
10+
use rustc_hir::{HirId, Target, find_attr};
1111
use rustc_middle::span_bug;
1212
use rustc_middle::ty::TyCtxt;
1313
use rustc_session::errors::report_lit_error;
@@ -74,7 +74,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
7474
if !e.attrs.is_empty() {
7575
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
7676
let new_attrs = self
77-
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id)
77+
.lower_attrs_vec(&e.attrs, e.span, ex.hir_id, Target::from_expr(e))
7878
.into_iter()
7979
.chain(old_attrs.iter().cloned());
8080
let new_attrs = &*self.arena.alloc_from_iter(new_attrs);
@@ -97,7 +97,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
9797
}
9898

9999
let expr_hir_id = self.lower_node_id(e.id);
100-
let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span);
100+
let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span, Target::from_expr(e));
101101

102102
let kind = match &e.kind {
103103
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
@@ -639,7 +639,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
639639
let guard = arm.guard.as_ref().map(|cond| self.lower_expr(cond));
640640
let hir_id = self.next_id();
641641
let span = self.lower_span(arm.span);
642-
self.lower_attrs(hir_id, &arm.attrs, arm.span);
642+
self.lower_attrs(hir_id, &arm.attrs, arm.span, Target::Arm);
643643
let is_never_pattern = pat.is_never_pattern();
644644
// We need to lower the body even if it's unneeded for never pattern in match,
645645
// ensure that we can get HirId for DefId if need (issue #137708).
@@ -820,6 +820,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
820820
span: unstable_span,
821821
}],
822822
span,
823+
Target::Fn,
823824
);
824825
}
825826
}
@@ -1654,7 +1655,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16541655

16551656
fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
16561657
let hir_id = self.lower_node_id(f.id);
1657-
self.lower_attrs(hir_id, &f.attrs, f.span);
1658+
self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField);
16581659
hir::ExprField {
16591660
hir_id,
16601661
ident: self.lower_ident(f.ident),
@@ -1910,7 +1911,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19101911
//
19111912
// Also, add the attributes to the outer returned expr node.
19121913
let expr = self.expr_drop_temps_mut(for_span, match_expr);
1913-
self.lower_attrs(expr.hir_id, &e.attrs, e.span);
1914+
self.lower_attrs(expr.hir_id, &e.attrs, e.span, Target::from_expr(e));
19141915
expr
19151916
}
19161917

@@ -1967,7 +1968,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19671968
let val_ident = Ident::with_dummy_span(sym::val);
19681969
let (val_pat, val_pat_nid) = self.pat_ident(span, val_ident);
19691970
let val_expr = self.expr_ident(span, val_ident, val_pat_nid);
1970-
self.lower_attrs(val_expr.hir_id, &attrs, span);
1971+
self.lower_attrs(val_expr.hir_id, &attrs, span, Target::Expression);
19711972
let continue_pat = self.pat_cf_continue(unstable_span, val_pat);
19721973
self.arm(continue_pat, val_expr)
19731974
};
@@ -1998,7 +1999,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19981999
let ret_expr = self.checked_return(Some(from_residual_expr));
19992000
self.arena.alloc(self.expr(try_span, ret_expr))
20002001
};
2001-
self.lower_attrs(ret_expr.hir_id, &attrs, span);
2002+
self.lower_attrs(ret_expr.hir_id, &attrs, span, Target::Expression);
20022003

20032004
let break_pat = self.pat_cf_break(try_span, residual_local);
20042005
self.arm(break_pat, ret_expr)

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err};
55
use rustc_hir::attrs::AttributeKind;
66
use rustc_hir::def::{DefKind, PerNS, Res};
77
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
8-
use rustc_hir::{self as hir, HirId, LifetimeSource, PredicateOrigin, find_attr};
8+
use rustc_hir::{self as hir, HirId, LifetimeSource, PredicateOrigin, Target, find_attr};
99
use rustc_index::{IndexSlice, IndexVec};
1010
use rustc_middle::span_bug;
1111
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
@@ -80,7 +80,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
8080
self.with_lctx(CRATE_NODE_ID, |lctx| {
8181
let module = lctx.lower_mod(&c.items, &c.spans);
8282
// FIXME(jdonszelman): is dummy span ever a problem here?
83-
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP);
83+
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, DUMMY_SP, Target::Crate);
8484
hir::OwnerNode::Crate(module)
8585
})
8686
}
@@ -136,7 +136,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
136136
fn lower_item(&mut self, i: &Item) -> &'hir hir::Item<'hir> {
137137
let vis_span = self.lower_span(i.vis.span);
138138
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
139-
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
139+
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span, Target::from_ast_item(i));
140140
let kind = self.lower_item_kind(i.span, i.id, hir_id, attrs, vis_span, &i.kind);
141141
let item = hir::Item {
142142
owner_id: hir_id.expect_owner(),
@@ -436,14 +436,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
436436
let body = Box::new(self.lower_delim_args(body));
437437
let def_id = self.local_def_id(id);
438438
let def_kind = self.tcx.def_kind(def_id);
439-
let DefKind::Macro(macro_kind) = def_kind else {
439+
let DefKind::Macro(macro_kinds) = def_kind else {
440440
unreachable!(
441441
"expected DefKind::Macro for macro item, found {}",
442442
def_kind.descr(def_id.to_def_id())
443443
);
444444
};
445445
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
446-
hir::ItemKind::Macro(ident, macro_def, macro_kind)
446+
hir::ItemKind::Macro(ident, macro_def, macro_kinds)
447447
}
448448
ItemKind::Delegation(box delegation) => {
449449
let delegation_results = self.lower_delegation(delegation, id, false);
@@ -621,7 +621,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
621621
fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir hir::ForeignItem<'hir> {
622622
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
623623
let owner_id = hir_id.expect_owner();
624-
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
624+
let attrs =
625+
self.lower_attrs(hir_id, &i.attrs, i.span, Target::from_foreign_item_kind(&i.kind));
625626
let (ident, kind) = match &i.kind {
626627
ForeignItemKind::Fn(box Fn { sig, ident, generics, define_opaque, .. }) => {
627628
let fdec = &sig.decl;
@@ -690,7 +691,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
690691

691692
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> {
692693
let hir_id = self.lower_node_id(v.id);
693-
self.lower_attrs(hir_id, &v.attrs, v.span);
694+
self.lower_attrs(hir_id, &v.attrs, v.span, Target::Variant);
694695
hir::Variant {
695696
hir_id,
696697
def_id: self.local_def_id(v.id),
@@ -773,7 +774,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
773774
) -> hir::FieldDef<'hir> {
774775
let ty = self.lower_ty(&f.ty, ImplTraitContext::Disallowed(ImplTraitPosition::FieldTy));
775776
let hir_id = self.lower_node_id(f.id);
776-
self.lower_attrs(hir_id, &f.attrs, f.span);
777+
self.lower_attrs(hir_id, &f.attrs, f.span, Target::Field);
777778
hir::FieldDef {
778779
span: self.lower_span(f.span),
779780
hir_id,
@@ -792,7 +793,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
792793

793794
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
794795
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
795-
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
796+
let attrs = self.lower_attrs(
797+
hir_id,
798+
&i.attrs,
799+
i.span,
800+
Target::from_assoc_item_kind(&i.kind, AssocCtxt::Trait),
801+
);
796802
let trait_item_def_id = hir_id.expect_owner();
797803

798804
let (ident, generics, kind, has_default) = match &i.kind {
@@ -1001,7 +1007,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
10011007
let has_value = true;
10021008
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
10031009
let hir_id = hir::HirId::make_owner(self.current_hir_id_owner.def_id);
1004-
let attrs = self.lower_attrs(hir_id, &i.attrs, i.span);
1010+
let attrs = self.lower_attrs(
1011+
hir_id,
1012+
&i.attrs,
1013+
i.span,
1014+
Target::from_assoc_item_kind(&i.kind, AssocCtxt::Impl { of_trait: is_in_trait_impl }),
1015+
);
10051016

10061017
let (ident, (generics, kind)) = match &i.kind {
10071018
AssocItemKind::Const(box ConstItem {
@@ -1171,7 +1182,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11711182

11721183
fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> {
11731184
let hir_id = self.lower_node_id(param.id);
1174-
self.lower_attrs(hir_id, &param.attrs, param.span);
1185+
self.lower_attrs(hir_id, &param.attrs, param.span, Target::Param);
11751186
hir::Param {
11761187
hir_id,
11771188
pat: self.lower_pat(&param.pat),
@@ -1851,7 +1862,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18511862
) -> hir::WherePredicate<'hir> {
18521863
let hir_id = self.lower_node_id(pred.id);
18531864
let span = self.lower_span(pred.span);
1854-
self.lower_attrs(hir_id, &pred.attrs, span);
1865+
self.lower_attrs(hir_id, &pred.attrs, span, Target::WherePredicate);
18551866
let kind = self.arena.alloc(match &pred.kind {
18561867
WherePredicateKind::BoundPredicate(WhereBoundPredicate {
18571868
bound_generic_params,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5454
use rustc_hir::lints::DelayedLint;
5555
use rustc_hir::{
5656
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
57-
LifetimeSyntax, ParamName, TraitCandidate,
57+
LifetimeSyntax, ParamName, Target, TraitCandidate,
5858
};
5959
use rustc_index::{Idx, IndexSlice, IndexVec};
6060
use rustc_macros::extension;
@@ -943,11 +943,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
943943
id: HirId,
944944
attrs: &[Attribute],
945945
target_span: Span,
946+
target: Target,
946947
) -> &'hir [hir::Attribute] {
947948
if attrs.is_empty() {
948949
&[]
949950
} else {
950-
let lowered_attrs = self.lower_attrs_vec(attrs, self.lower_span(target_span), id);
951+
let lowered_attrs =
952+
self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target);
951953

952954
assert_eq!(id.owner, self.current_hir_id_owner);
953955
let ret = self.arena.alloc_from_iter(lowered_attrs);
@@ -972,12 +974,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
972974
attrs: &[Attribute],
973975
target_span: Span,
974976
target_hir_id: HirId,
977+
target: Target,
975978
) -> Vec<hir::Attribute> {
976979
let l = self.span_lowerer();
977980
self.attribute_parser.parse_attribute_list(
978981
attrs,
979982
target_span,
980983
target_hir_id,
984+
target,
981985
OmitDoc::Lower,
982986
|s| l.lower(s),
983987
|l| {
@@ -1942,7 +1946,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19421946
let (name, kind) = self.lower_generic_param_kind(param, source);
19431947

19441948
let hir_id = self.lower_node_id(param.id);
1945-
self.lower_attrs(hir_id, &param.attrs, param.span());
1949+
self.lower_attrs(hir_id, &param.attrs, param.span(), Target::Param);
19461950
hir::GenericParam {
19471951
hir_id,
19481952
def_id: self.local_def_id(param.id),

0 commit comments

Comments
 (0)