Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 99cc250

Browse files
committed
Auto merge of rust-lang#137982 - matthiaskrgr:rollup-12jvilg, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - rust-lang#136975 (Look for `python3` first on MacOS, not `py`) - rust-lang#137240 (Slightly reformat `std::fs::remove_dir_all` error docs) - rust-lang#137303 (Remove `MaybeForgetReturn` suggestion) - rust-lang#137463 ([illumos] attempt to use posix_spawn to spawn processes) - rust-lang#137722 (`librustdoc`: 2024 edition! 🎊) - rust-lang#137758 (fix usage of ty decl macro fragments in attributes) - rust-lang#137772 (Fix char count in `Display` for `ByteStr`) - rust-lang#137805 (adjust Layout debug printing to match the internal field name) - rust-lang#137808 (Do not require that unsafe fields lack drop glue) - rust-lang#137913 (Allow struct field default values to reference struct's generics) - rust-lang#137963 (Add ``dyn`` keyword to `E0373` examples) - rust-lang#137975 (Remove unused `PpMode::needs_hir`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fd17dea + 98c6bd4 commit 99cc250

File tree

66 files changed

+636
-809
lines changed

Some content is hidden

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

66 files changed

+636
-809
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ where
18121812
f.debug_struct("Layout")
18131813
.field("size", size)
18141814
.field("align", align)
1815-
.field("abi", backend_repr)
1815+
.field("backend_repr", backend_repr)
18161816
.field("fields", fields)
18171817
.field("largest_niche", largest_niche)
18181818
.field("uninhabited", uninhabited)

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,15 @@ impl<'a> MetaItemListParserContext<'a> {
473473
{
474474
self.inside_delimiters.next();
475475
return Some(MetaItemOrLitParser::Lit(lit));
476+
} else if let Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) =
477+
self.inside_delimiters.peek()
478+
{
479+
self.inside_delimiters.next();
480+
return MetaItemListParserContext {
481+
inside_delimiters: inner_tokens.iter().peekable(),
482+
dcx: self.dcx,
483+
}
484+
.next();
476485
}
477486

478487
// or a path.

compiler/rustc_data_structures/src/captures.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

compiler/rustc_data_structures/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub use rustc_index::static_assert_size;
4848
pub mod aligned;
4949
pub mod base_n;
5050
pub mod binary_search_util;
51-
pub mod captures;
5251
pub mod fingerprint;
5352
pub mod flat_map_in_place;
5453
pub mod flock;

compiler/rustc_error_codes/src/error_codes/E0373.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ A captured variable in a closure may not live long enough.
33
Erroneous code example:
44

55
```compile_fail,E0373
6-
fn foo() -> Box<Fn(u32) -> u32> {
6+
fn foo() -> Box<dyn Fn(u32) -> u32> {
77
let x = 0u32;
88
Box::new(|y| x + y)
99
}
@@ -42,7 +42,7 @@ This approach moves (or copies, where possible) data into the closure, rather
4242
than taking references to it. For example:
4343

4444
```
45-
fn foo() -> Box<Fn(u32) -> u32> {
45+
fn foo() -> Box<dyn Fn(u32) -> u32> {
4646
let x = 0u32;
4747
Box::new(move |y| x + y)
4848
}

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ pub enum StashKey {
626626
MaybeFruTypo,
627627
CallAssocMethod,
628628
AssociatedTypeSuggestion,
629-
MaybeForgetReturn,
630629
/// Query cycle detected, stashing in favor of a better error.
631630
Cycle,
632631
UndeterminedMacroResolution,

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,6 @@ hir_analysis_invalid_union_field =
278278
hir_analysis_invalid_union_field_sugg =
279279
wrap the field type in `ManuallyDrop<...>`
280280
281-
hir_analysis_invalid_unsafe_field =
282-
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be unsafe
283-
.note = unsafe fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
284-
285-
hir_analysis_invalid_unsafe_field_sugg =
286-
wrap the field type in `ManuallyDrop<...>`
287-
288281
hir_analysis_late_bound_const_in_apit = `impl Trait` can only mention const parameters from an fn or impl
289282
.label = const parameter declared here
290283

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
7070

7171
check_transparent(tcx, def);
7272
check_packed(tcx, span, def);
73-
check_unsafe_fields(tcx, def_id);
7473
}
7574

7675
fn check_union(tcx: TyCtxt<'_>, def_id: LocalDefId) {
@@ -144,36 +143,6 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
144143
true
145144
}
146145

147-
/// Check that the unsafe fields do not need dropping.
148-
fn check_unsafe_fields(tcx: TyCtxt<'_>, item_def_id: LocalDefId) {
149-
let span = tcx.def_span(item_def_id);
150-
let def = tcx.adt_def(item_def_id);
151-
152-
let typing_env = ty::TypingEnv::non_body_analysis(tcx, item_def_id);
153-
let args = ty::GenericArgs::identity_for_item(tcx, item_def_id);
154-
155-
for field in def.all_fields() {
156-
if !field.safety.is_unsafe() {
157-
continue;
158-
}
159-
160-
if !allowed_union_or_unsafe_field(tcx, field.ty(tcx, args), typing_env, span) {
161-
let hir::Node::Field(field) = tcx.hir_node_by_def_id(field.did.expect_local()) else {
162-
unreachable!("field has to correspond to hir field")
163-
};
164-
let ty_span = field.ty.span;
165-
tcx.dcx().emit_err(errors::InvalidUnsafeField {
166-
field_span: field.span,
167-
sugg: errors::InvalidUnsafeFieldSuggestion {
168-
lo: ty_span.shrink_to_lo(),
169-
hi: ty_span.shrink_to_hi(),
170-
},
171-
note: (),
172-
});
173-
}
174-
}
175-
}
176-
177146
/// Check that a `static` is inhabited.
178147
fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
179148
// Make sure statics are inhabited.
@@ -1517,7 +1486,6 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
15171486

15181487
detect_discriminant_duplicate(tcx, def);
15191488
check_transparent(tcx, def);
1520-
check_unsafe_fields(tcx, def_id);
15211489
}
15221490

15231491
/// Part of enum check. Given the discriminants of an enum, errors if two or more discriminants are equal

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
187187
Some(parent_did)
188188
}
189189
Node::TyPat(_) => Some(parent_did),
190+
// Field default values inherit the ADT's generics.
191+
Node::Field(_) => Some(parent_did),
190192
_ => None,
191193
}
192194
}

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -710,17 +710,6 @@ pub(crate) struct InvalidUnionField {
710710
pub note: (),
711711
}
712712

713-
#[derive(Diagnostic)]
714-
#[diag(hir_analysis_invalid_unsafe_field, code = E0740)]
715-
pub(crate) struct InvalidUnsafeField {
716-
#[primary_span]
717-
pub field_span: Span,
718-
#[subdiagnostic]
719-
pub sugg: InvalidUnsafeFieldSuggestion,
720-
#[note]
721-
pub note: (),
722-
}
723-
724713
#[derive(Diagnostic)]
725714
#[diag(hir_analysis_return_type_notation_on_non_rpitit)]
726715
pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
@@ -742,18 +731,6 @@ pub(crate) struct InvalidUnionFieldSuggestion {
742731
pub hi: Span,
743732
}
744733

745-
#[derive(Subdiagnostic)]
746-
#[multipart_suggestion(
747-
hir_analysis_invalid_unsafe_field_sugg,
748-
applicability = "machine-applicable"
749-
)]
750-
pub(crate) struct InvalidUnsafeFieldSuggestion {
751-
#[suggestion_part(code = "std::mem::ManuallyDrop<")]
752-
pub lo: Span,
753-
#[suggestion_part(code = ">")]
754-
pub hi: Span,
755-
}
756-
757734
#[derive(Diagnostic)]
758735
#[diag(hir_analysis_return_type_notation_equality_bound)]
759736
pub(crate) struct ReturnTypeNotationEqualityBound {

0 commit comments

Comments
 (0)