Skip to content

Rollup of 6 pull requests #128672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9d9b55c
make invalid_type_param_default lint show up in cargo future-compat r…
RalfJung Jul 15, 2024
bda31d1
built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack …
RalfJung Jul 18, 2024
9b165a1
Implement cursors for `BTreeSet`
kmicklas Jul 28, 2024
bbeff8c
set `force_recompile: true` if library is modified
onur-ozkan Jul 30, 2024
6fcc630
update download-rustc documentation
onur-ozkan Jul 30, 2024
0204762
Share `UnorderedKeyError` with `BTReeMap` for set API
kmicklas Aug 1, 2024
4560770
Fix some uses of "map" instead of "set" in `BTreeSet` cursor API docs
kmicklas Aug 1, 2024
cbdc377
Introduce `Cursor`/`CursorMut`/`CursorMutKey` thrichotomy for `BTreeS…
kmicklas Aug 1, 2024
0bc501e
Fix mutability in doc tests for `BTreeSet` cursors
kmicklas Aug 1, 2024
8497800
Add test for updating enum discriminant through pointer
clubby789 Aug 1, 2024
9e5c9c1
tests: add regression test for incorrect "builtin attribute is checke…
jieyouxu Aug 4, 2024
9d0eaa2
check_attr: cover multi-segment attributes on specific check arms
jieyouxu Aug 4, 2024
cc61dc8
Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=comp…
matthiaskrgr Aug 5, 2024
d10f2b3
Rollup merge of #127907 - RalfJung:byte_slice_in_packed_struct_with_d…
matthiaskrgr Aug 5, 2024
f6c8b7a
Rollup merge of #127974 - onur-ozkan:force-std-builds, r=Mark-Simulacrum
matthiaskrgr Aug 5, 2024
e4367ce
Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu
matthiaskrgr Aug 5, 2024
3c8b259
Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum
matthiaskrgr Aug 5, 2024
2048007
Rollup merge of #128623 - jieyouxu:check-attr-ice, r=nnethercote
matthiaskrgr Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 6 additions & 48 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,10 @@ use std::{iter, vec};
use rustc_ast::ptr::P;
use rustc_ast::{
self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
Mutability, PatKind, TyKind, VariantData,
Mutability, PatKind, VariantData,
};
use rustc_attr as attr;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::lint::builtin::BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
Expand Down Expand Up @@ -1599,52 +1598,11 @@ impl<'a> TraitDef<'a> {
),
);
if is_packed {
// In general, fields in packed structs are copied via a
// block, e.g. `&{self.0}`. The two exceptions are `[u8]`
// and `str` fields, which cannot be copied and also never
// cause unaligned references. These exceptions are allowed
// to handle the `FlexZeroSlice` type in the `zerovec`
// crate within `icu4x-0.9.0`.
//
// Once use of `icu4x-0.9.0` has dropped sufficiently, this
// exception should be removed.
let is_simple_path = |ty: &P<ast::Ty>, sym| {
if let TyKind::Path(None, ast::Path { segments, .. }) = &ty.kind
&& let [seg] = segments.as_slice()
&& seg.ident.name == sym
&& seg.args.is_none()
{
true
} else {
false
}
};

let exception = if let TyKind::Slice(ty) = &struct_field.ty.kind
&& is_simple_path(ty, sym::u8)
{
Some("byte")
} else if is_simple_path(&struct_field.ty, sym::str) {
Some("string")
} else {
None
};

if let Some(ty) = exception {
cx.sess.psess.buffer_lint(
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
sp,
ast::CRATE_NODE_ID,
rustc_lint_defs::BuiltinLintDiag::ByteSliceInPackedStructWithDerive {
ty: ty.to_string(),
},
);
} else {
// Wrap the expression in `{...}`, causing a copy.
field_expr = cx.expr_block(
cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]),
);
}
// Fields in packed structs are wrapped in a block, e.g. `&{self.0}`,
// causing a copy instead of a (potentially misaligned) reference.
field_expr = cx.expr_block(
cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]),
);
}
cx.expr_addr_of(sp, field_expr)
})
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ declare_features! (
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
(removed, custom_derive, "1.32.0", Some(29644),
Some("subsumed by `#[proc_macro_derive]`")),
/// Allows default type parameters to influence type inference.
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
Some("never properly implemented; requires significant design work")),
/// Allows using `#[doc(keyword = "...")]`.
(removed, doc_keyword, "1.28.0", Some(51315),
Some("merged into `#![feature(rustdoc_internals)]`")),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ declare_features! (
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
/// Allows declarative macros 2.0 (`macro`).
(unstable, decl_macro, "1.17.0", Some(39412)),
/// Allows default type parameters to influence type inference.
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
(unstable, deprecated_safe, "1.61.0", Some(94978)),
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
if default.is_some() {
match allow_defaults {
Defaults::Allowed => {}
Defaults::FutureCompatDisallowed
if tcx.features().default_type_parameter_fallback => {}
Defaults::FutureCompatDisallowed => {
tcx.node_span_lint(
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ fn register_builtins(store: &mut LintStore) {
);
store.register_removed(
"suspicious_auto_trait_impls",
"no longer needed, see #93367 \
"no longer needed, see issue #93367 \
<https://github.com/rust-lang/rust/issues/93367> for more information",
);
store.register_removed(
Expand All @@ -565,6 +565,11 @@ fn register_builtins(store: &mut LintStore) {
"box_pointers",
"it does not detect other kinds of allocations, and existed only for historical reasons",
);
store.register_removed(
"byte_slice_in_packed_struct_with_derive",
"converted into hard error, see issue #107457 \
<https://github.com/rust-lang/rust/issues/107457> for more information",
)
}

fn register_internals(store: &mut LintStore) {
Expand Down
36 changes: 1 addition & 35 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ declare_lint_pass! {
BARE_TRAIT_OBJECTS,
BINDINGS_WITH_VARIANT_NAME,
BREAK_WITH_LABEL_AND_LOOP,
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
CENUM_IMPL_DROP_CAST,
COHERENCE_LEAK_CHECK,
CONFLICTING_REPR_HINTS,
Expand Down Expand Up @@ -1267,7 +1266,7 @@ declare_lint! {
Deny,
"type parameter default erroneously allowed in invalid location",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
};
}
Expand Down Expand Up @@ -4315,39 +4314,6 @@ declare_lint! {
report_in_external_macro
}

declare_lint! {
/// The `byte_slice_in_packed_struct_with_derive` lint detects cases where a byte slice field
/// (`[u8]`) or string slice field (`str`) is used in a `packed` struct that derives one or
/// more built-in traits.
///
/// ### Example
///
/// ```rust
/// #[repr(packed)]
/// #[derive(Hash)]
/// struct FlexZeroSlice {
/// width: u8,
/// data: [u8],
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// This was previously accepted but is being phased out, because fields in packed structs are
/// now required to implement `Copy` for `derive` to work. Byte slices and string slices are a
/// temporary exception because certain crates depended on them.
pub BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
Warn,
"`[u8]` or `str` used in a packed struct with `derive`",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #107457 <https://github.com/rust-lang/rust/issues/107457>",
};
report_in_external_macro
}

declare_lint! {
/// The `invalid_macro_export_arguments` lint detects cases where `#[macro_export]` is being used with invalid arguments.
///
Expand Down
Loading
Loading