Skip to content

Commit 29e9248

Browse files
committed
Auto merge of rust-lang#128672 - matthiaskrgr:rollup-txf7siy, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#127655 (turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps`) - rust-lang#127907 (built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack and lint) - rust-lang#127974 (force compiling std from source if modified) - rust-lang#128309 (Implement cursors for `BTreeSet`) - rust-lang#128500 (Add test for updating enum discriminant through pointer) - rust-lang#128623 (Do not fire unhandled attribute assertion on multi-segment `AttributeType::Normal` attributes with builtin attribute as first segment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 176e545 + 2048007 commit 29e9248

26 files changed

+942
-343
lines changed

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+6-48
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,10 @@ use std::{iter, vec};
181181
use rustc_ast::ptr::P;
182182
use rustc_ast::{
183183
self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
184-
Mutability, PatKind, TyKind, VariantData,
184+
Mutability, PatKind, VariantData,
185185
};
186186
use rustc_attr as attr;
187187
use rustc_expand::base::{Annotatable, ExtCtxt};
188-
use rustc_session::lint::builtin::BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE;
189188
use rustc_span::symbol::{kw, sym, Ident, Symbol};
190189
use rustc_span::{Span, DUMMY_SP};
191190
use thin_vec::{thin_vec, ThinVec};
@@ -1599,52 +1598,11 @@ impl<'a> TraitDef<'a> {
15991598
),
16001599
);
16011600
if is_packed {
1602-
// In general, fields in packed structs are copied via a
1603-
// block, e.g. `&{self.0}`. The two exceptions are `[u8]`
1604-
// and `str` fields, which cannot be copied and also never
1605-
// cause unaligned references. These exceptions are allowed
1606-
// to handle the `FlexZeroSlice` type in the `zerovec`
1607-
// crate within `icu4x-0.9.0`.
1608-
//
1609-
// Once use of `icu4x-0.9.0` has dropped sufficiently, this
1610-
// exception should be removed.
1611-
let is_simple_path = |ty: &P<ast::Ty>, sym| {
1612-
if let TyKind::Path(None, ast::Path { segments, .. }) = &ty.kind
1613-
&& let [seg] = segments.as_slice()
1614-
&& seg.ident.name == sym
1615-
&& seg.args.is_none()
1616-
{
1617-
true
1618-
} else {
1619-
false
1620-
}
1621-
};
1622-
1623-
let exception = if let TyKind::Slice(ty) = &struct_field.ty.kind
1624-
&& is_simple_path(ty, sym::u8)
1625-
{
1626-
Some("byte")
1627-
} else if is_simple_path(&struct_field.ty, sym::str) {
1628-
Some("string")
1629-
} else {
1630-
None
1631-
};
1632-
1633-
if let Some(ty) = exception {
1634-
cx.sess.psess.buffer_lint(
1635-
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
1636-
sp,
1637-
ast::CRATE_NODE_ID,
1638-
rustc_lint_defs::BuiltinLintDiag::ByteSliceInPackedStructWithDerive {
1639-
ty: ty.to_string(),
1640-
},
1641-
);
1642-
} else {
1643-
// Wrap the expression in `{...}`, causing a copy.
1644-
field_expr = cx.expr_block(
1645-
cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]),
1646-
);
1647-
}
1601+
// Fields in packed structs are wrapped in a block, e.g. `&{self.0}`,
1602+
// causing a copy instead of a (potentially misaligned) reference.
1603+
field_expr = cx.expr_block(
1604+
cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]),
1605+
);
16481606
}
16491607
cx.expr_addr_of(sp, field_expr)
16501608
})

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ declare_features! (
8282
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
8383
(removed, custom_derive, "1.32.0", Some(29644),
8484
Some("subsumed by `#[proc_macro_derive]`")),
85+
/// Allows default type parameters to influence type inference.
86+
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
87+
Some("never properly implemented; requires significant design work")),
8588
/// Allows using `#[doc(keyword = "...")]`.
8689
(removed, doc_keyword, "1.28.0", Some(51315),
8790
Some("merged into `#![feature(rustdoc_internals)]`")),

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ declare_features! (
431431
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
432432
/// Allows declarative macros 2.0 (`macro`).
433433
(unstable, decl_macro, "1.17.0", Some(39412)),
434-
/// Allows default type parameters to influence type inference.
435-
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
436434
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
437435
(unstable, deprecated_safe, "1.61.0", Some(94978)),
438436
/// Allows having using `suggestion` in the `#[deprecated]` attribute.

compiler/rustc_hir_analysis/src/collect/generics_of.rs

-2
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
338338
if default.is_some() {
339339
match allow_defaults {
340340
Defaults::Allowed => {}
341-
Defaults::FutureCompatDisallowed
342-
if tcx.features().default_type_parameter_fallback => {}
343341
Defaults::FutureCompatDisallowed => {
344342
tcx.node_span_lint(
345343
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,

compiler/rustc_lint/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ fn register_builtins(store: &mut LintStore) {
543543
);
544544
store.register_removed(
545545
"suspicious_auto_trait_impls",
546-
"no longer needed, see #93367 \
546+
"no longer needed, see issue #93367 \
547547
<https://github.com/rust-lang/rust/issues/93367> for more information",
548548
);
549549
store.register_removed(
@@ -565,6 +565,11 @@ fn register_builtins(store: &mut LintStore) {
565565
"box_pointers",
566566
"it does not detect other kinds of allocations, and existed only for historical reasons",
567567
);
568+
store.register_removed(
569+
"byte_slice_in_packed_struct_with_derive",
570+
"converted into hard error, see issue #107457 \
571+
<https://github.com/rust-lang/rust/issues/107457> for more information",
572+
)
568573
}
569574

570575
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

+1-35
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ declare_lint_pass! {
2626
BARE_TRAIT_OBJECTS,
2727
BINDINGS_WITH_VARIANT_NAME,
2828
BREAK_WITH_LABEL_AND_LOOP,
29-
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
3029
CENUM_IMPL_DROP_CAST,
3130
COHERENCE_LEAK_CHECK,
3231
CONFLICTING_REPR_HINTS,
@@ -1267,7 +1266,7 @@ declare_lint! {
12671266
Deny,
12681267
"type parameter default erroneously allowed in invalid location",
12691268
@future_incompatible = FutureIncompatibleInfo {
1270-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1269+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
12711270
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
12721271
};
12731272
}
@@ -4315,39 +4314,6 @@ declare_lint! {
43154314
report_in_external_macro
43164315
}
43174316

4318-
declare_lint! {
4319-
/// The `byte_slice_in_packed_struct_with_derive` lint detects cases where a byte slice field
4320-
/// (`[u8]`) or string slice field (`str`) is used in a `packed` struct that derives one or
4321-
/// more built-in traits.
4322-
///
4323-
/// ### Example
4324-
///
4325-
/// ```rust
4326-
/// #[repr(packed)]
4327-
/// #[derive(Hash)]
4328-
/// struct FlexZeroSlice {
4329-
/// width: u8,
4330-
/// data: [u8],
4331-
/// }
4332-
/// ```
4333-
///
4334-
/// {{produces}}
4335-
///
4336-
/// ### Explanation
4337-
///
4338-
/// This was previously accepted but is being phased out, because fields in packed structs are
4339-
/// now required to implement `Copy` for `derive` to work. Byte slices and string slices are a
4340-
/// temporary exception because certain crates depended on them.
4341-
pub BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
4342-
Warn,
4343-
"`[u8]` or `str` used in a packed struct with `derive`",
4344-
@future_incompatible = FutureIncompatibleInfo {
4345-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
4346-
reference: "issue #107457 <https://github.com/rust-lang/rust/issues/107457>",
4347-
};
4348-
report_in_external_macro
4349-
}
4350-
43514317
declare_lint! {
43524318
/// The `invalid_macro_export_arguments` lint detects cases where `#[macro_export]` is being used with invalid arguments.
43534319
///

0 commit comments

Comments
 (0)