Skip to content

Commit 24b0b81

Browse files
Merge branch 'rust-lang:master' into fix-wasm32v1-none
2 parents b5ec13f + 350d0ef commit 24b0b81

File tree

318 files changed

+4660
-2052
lines changed

Some content is hidden

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

318 files changed

+4660
-2052
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5284,9 +5284,9 @@ dependencies = [
52845284

52855285
[[package]]
52865286
name = "sysinfo"
5287-
version = "0.36.1"
5287+
version = "0.37.0"
52885288
source = "registry+https://github.com/rust-lang/crates.io-index"
5289-
checksum = "252800745060e7b9ffb7b2badbd8b31cfa4aa2e61af879d0a3bf2a317c20217d"
5289+
checksum = "07cec4dc2d2e357ca1e610cfb07de2fa7a10fc3e9fe89f72545f3d244ea87753"
52905290
dependencies = [
52915291
"libc",
52925292
"objc2-core-foundation",

compiler/rustc_ast/src/ast.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,15 +3661,19 @@ pub struct TyAlias {
36613661

36623662
#[derive(Clone, Encodable, Decodable, Debug)]
36633663
pub struct Impl {
3664+
pub generics: Generics,
3665+
pub of_trait: Option<Box<TraitImplHeader>>,
3666+
pub self_ty: Box<Ty>,
3667+
pub items: ThinVec<Box<AssocItem>>,
3668+
}
3669+
3670+
#[derive(Clone, Encodable, Decodable, Debug)]
3671+
pub struct TraitImplHeader {
36643672
pub defaultness: Defaultness,
36653673
pub safety: Safety,
3666-
pub generics: Generics,
36673674
pub constness: Const,
36683675
pub polarity: ImplPolarity,
3669-
/// The trait being implemented, if any.
3670-
pub of_trait: Option<TraitRef>,
3671-
pub self_ty: Box<Ty>,
3672-
pub items: ThinVec<Box<AssocItem>>,
3676+
pub trait_ref: TraitRef,
36733677
}
36743678

36753679
#[derive(Clone, Encodable, Decodable, Debug, Default, Walkable)]
@@ -3793,7 +3797,7 @@ pub enum ItemKind {
37933797
/// An implementation.
37943798
///
37953799
/// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
3796-
Impl(Box<Impl>),
3800+
Impl(Impl),
37973801
/// A macro invocation.
37983802
///
37993803
/// E.g., `foo!(..)`.
@@ -3880,7 +3884,7 @@ impl ItemKind {
38803884
| Self::Union(_, generics, _)
38813885
| Self::Trait(box Trait { generics, .. })
38823886
| Self::TraitAlias(_, generics, _)
3883-
| Self::Impl(box Impl { generics, .. }) => Some(generics),
3887+
| Self::Impl(Impl { generics, .. }) => Some(generics),
38843888
_ => None,
38853889
}
38863890
}
@@ -4040,7 +4044,7 @@ mod size_asserts {
40404044
static_assert_size!(GenericArg, 24);
40414045
static_assert_size!(GenericBound, 88);
40424046
static_assert_size!(Generics, 40);
4043-
static_assert_size!(Impl, 136);
4047+
static_assert_size!(Impl, 64);
40444048
static_assert_size!(Item, 144);
40454049
static_assert_size!(ItemKind, 80);
40464050
static_assert_size!(LitKind, 24);
@@ -4053,6 +4057,7 @@ mod size_asserts {
40534057
static_assert_size!(PathSegment, 24);
40544058
static_assert_size!(Stmt, 32);
40554059
static_assert_size!(StmtKind, 16);
4060+
static_assert_size!(TraitImplHeader, 80);
40564061
static_assert_size!(Ty, 64);
40574062
static_assert_size!(TyKind, 40);
40584063
// tidy-alphabetical-end

compiler/rustc_ast/src/visit.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,13 @@ macro_rules! common_visitor_and_walkers {
929929
}
930930

931931
impl_walkable!(|&$($mut)? $($lt)? self: Impl, vis: &mut V| {
932-
let Impl { defaultness, safety, generics, constness, polarity, of_trait, self_ty, items } = self;
933-
visit_visitable!($($mut)? vis, defaultness, safety, generics, constness, polarity, of_trait, self_ty);
932+
let Impl { generics, of_trait, self_ty, items } = self;
933+
try_visit!(vis.visit_generics(generics));
934+
if let Some(box of_trait) = of_trait {
935+
let TraitImplHeader { defaultness, safety, constness, polarity, trait_ref } = of_trait;
936+
visit_visitable!($($mut)? vis, defaultness, safety, constness, polarity, trait_ref);
937+
}
938+
try_visit!(vis.visit_ty(self_ty));
934939
visit_visitable_with!($($mut)? vis, items, AssocCtxt::Impl { of_trait: of_trait.is_some() });
935940
V::Result::output()
936941
});

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
340340
);
341341
hir::ItemKind::Union(ident, generics, vdata)
342342
}
343-
ItemKind::Impl(box Impl {
344-
safety,
345-
polarity,
346-
defaultness,
347-
constness,
343+
ItemKind::Impl(Impl {
348344
generics: ast_generics,
349-
of_trait: trait_ref,
345+
of_trait,
350346
self_ty: ty,
351347
items: impl_items,
352348
}) => {
@@ -364,54 +360,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
364360
// lifetime to be added, but rather a reference to a
365361
// parent lifetime.
366362
let itctx = ImplTraitContext::Universal;
367-
let (generics, (trait_ref, lowered_ty)) =
363+
let (generics, (of_trait, lowered_ty)) =
368364
self.lower_generics(ast_generics, id, itctx, |this| {
369-
let modifiers = TraitBoundModifiers {
370-
constness: BoundConstness::Never,
371-
asyncness: BoundAsyncness::Normal,
372-
// we don't use this in bound lowering
373-
polarity: BoundPolarity::Positive,
374-
};
375-
376-
let trait_ref = trait_ref.as_ref().map(|trait_ref| {
377-
this.lower_trait_ref(
378-
modifiers,
379-
trait_ref,
380-
ImplTraitContext::Disallowed(ImplTraitPosition::Trait),
381-
)
382-
});
365+
let of_trait = of_trait
366+
.as_deref()
367+
.map(|of_trait| this.lower_trait_impl_header(of_trait));
383368

384369
let lowered_ty = this.lower_ty(
385370
ty,
386371
ImplTraitContext::Disallowed(ImplTraitPosition::ImplSelf),
387372
);
388373

389-
(trait_ref, lowered_ty)
374+
(of_trait, lowered_ty)
390375
});
391376

392377
let new_impl_items = self
393378
.arena
394379
.alloc_from_iter(impl_items.iter().map(|item| self.lower_impl_item_ref(item)));
395380

396-
// `defaultness.has_value()` is never called for an `impl`, always `true` in order
397-
// to not cause an assertion failure inside the `lower_defaultness` function.
398-
let has_val = true;
399-
let (defaultness, defaultness_span) = self.lower_defaultness(*defaultness, has_val);
400-
let polarity = match polarity {
401-
ImplPolarity::Positive => ImplPolarity::Positive,
402-
ImplPolarity::Negative(s) => ImplPolarity::Negative(self.lower_span(*s)),
403-
};
404-
hir::ItemKind::Impl(self.arena.alloc(hir::Impl {
405-
constness: self.lower_constness(*constness),
406-
safety: self.lower_safety(*safety, hir::Safety::Safe),
407-
polarity,
408-
defaultness,
409-
defaultness_span,
381+
hir::ItemKind::Impl(hir::Impl {
410382
generics,
411-
of_trait: trait_ref,
383+
of_trait,
412384
self_ty: lowered_ty,
413385
items: new_impl_items,
414-
}))
386+
})
415387
}
416388
ItemKind::Trait(box Trait {
417389
constness,
@@ -982,6 +954,44 @@ impl<'hir> LoweringContext<'_, 'hir> {
982954
self.expr(span, hir::ExprKind::Err(guar))
983955
}
984956

957+
fn lower_trait_impl_header(
958+
&mut self,
959+
trait_impl_header: &TraitImplHeader,
960+
) -> &'hir hir::TraitImplHeader<'hir> {
961+
let TraitImplHeader { constness, safety, polarity, defaultness, ref trait_ref } =
962+
*trait_impl_header;
963+
let constness = self.lower_constness(constness);
964+
let safety = self.lower_safety(safety, hir::Safety::Safe);
965+
let polarity = match polarity {
966+
ImplPolarity::Positive => ImplPolarity::Positive,
967+
ImplPolarity::Negative(s) => ImplPolarity::Negative(self.lower_span(s)),
968+
};
969+
// `defaultness.has_value()` is never called for an `impl`, always `true` in order
970+
// to not cause an assertion failure inside the `lower_defaultness` function.
971+
let has_val = true;
972+
let (defaultness, defaultness_span) = self.lower_defaultness(defaultness, has_val);
973+
let modifiers = TraitBoundModifiers {
974+
constness: BoundConstness::Never,
975+
asyncness: BoundAsyncness::Normal,
976+
// we don't use this in bound lowering
977+
polarity: BoundPolarity::Positive,
978+
};
979+
let trait_ref = self.lower_trait_ref(
980+
modifiers,
981+
trait_ref,
982+
ImplTraitContext::Disallowed(ImplTraitPosition::Trait),
983+
);
984+
985+
self.arena.alloc(hir::TraitImplHeader {
986+
constness,
987+
safety,
988+
polarity,
989+
defaultness,
990+
defaultness_span,
991+
trait_ref,
992+
})
993+
}
994+
985995
fn lower_impl_item(
986996
&mut self,
987997
i: &AssocItem,

compiler/rustc_ast_passes/messages.ftl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ ast_passes_generic_default_trailing = generic parameters with a default must be
175175
ast_passes_incompatible_features = `{$f1}` and `{$f2}` are incompatible, using them at the same time is not allowed
176176
.help = remove one of these features
177177
178-
ast_passes_inherent_cannot_be = inherent impls cannot be {$annotation}
179-
.because = {$annotation} because of this
180-
.type = inherent impl for this type
181-
.only_trait = only trait implementations may be annotated with {$annotation}
182-
183178
ast_passes_item_invalid_safety = items outside of `unsafe extern {"{ }"}` cannot be declared with `safe` safety qualifier
184179
.suggestion = remove safe from this item
185180

0 commit comments

Comments
 (0)