Skip to content

Commit ba2a7d3

Browse files
committed
Auto merge of #151291 - jhpratt:rollup-CVsL9ZN, r=jhpratt
Rollup of 8 pull requests Successful merges: - #148769 (Stabilize `alloc_layout_extra`) - #150200 (Add title field to `ice.md` issue template) - #150955 (Underscore-prefixed bindings are explicitly allowed to be unused) - #151200 (time: Add saturating arithmetic for `SystemTime`) - #151235 (Change field `bit_width: usize` to `bits: u32` in type info) - #151242 (Port #[needs_allocator] to attribute parser) - #151274 (Include a link to `count_ones` in the docs for `uN::count_zeros` [docs only]) - #151279 (remove trailing periods in built-in attribute gate messages) r? @ghost
2 parents 621d767 + 5fd13b5 commit ba2a7d3

File tree

34 files changed

+266
-99
lines changed

34 files changed

+266
-99
lines changed

.github/ISSUE_TEMPLATE/ice.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: Internal Compiler Error
33
about: Create a report for an internal compiler error in rustc.
44
labels: C-bug, I-ICE, T-compiler
5+
title: "[ICE]: "
56
---
67
<!--
78
Thank you for finding an Internal Compiler Error! 🧊 If possible, try to provide

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,12 @@ impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
658658
Some(AttributeKind::Linkage(linkage, cx.attr_span))
659659
}
660660
}
661+
662+
pub(crate) struct NeedsAllocatorParser;
663+
664+
impl<S: Stage> NoArgsAttributeParser<S> for NeedsAllocatorParser {
665+
const PATH: &[Symbol] = &[sym::needs_allocator];
666+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
667+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
668+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsAllocator;
669+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
4141
use crate::attributes::instruction_set::InstructionSetParser;
4242
use crate::attributes::link_attrs::{
4343
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
44-
LinkParser, LinkSectionParser, LinkageParser, StdInternalSymbolParser,
44+
LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser, StdInternalSymbolParser,
4545
};
4646
use crate::attributes::lint_helpers::{
4747
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
@@ -259,6 +259,7 @@ attribute_parsers!(
259259
Single<WithoutArgs<MacroEscapeParser>>,
260260
Single<WithoutArgs<MarkerParser>>,
261261
Single<WithoutArgs<MayDangleParser>>,
262+
Single<WithoutArgs<NeedsAllocatorParser>>,
262263
Single<WithoutArgs<NoCoreParser>>,
263264
Single<WithoutArgs<NoImplicitPreludeParser>>,
264265
Single<WithoutArgs<NoLinkParser>>,

compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ diff --git a/coretests/tests/lib.rs b/coretests/tests/lib.rs
1414
index 1e336bf..35e6f54 100644
1515
--- a/coretests/tests/lib.rs
1616
+++ b/coretests/tests/lib.rs
17-
@@ -2,5 +2,4 @@
17+
@@ -2,4 +2,3 @@
1818
// tidy-alphabetical-start
1919
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
2020
#![cfg_attr(test, feature(cfg_select))]
21-
#![feature(alloc_layout_extra)]
2221
#![feature(array_ptr_get)]
2322
diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs
2423
index b735957..ea728b6 100644

compiler/rustc_const_eval/src/const_eval/type_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
257257
{
258258
let field_place = self.project_field(&place, field_idx)?;
259259
match field.name {
260-
sym::bit_width => self.write_scalar(
261-
ScalarInt::try_from_target_usize(bit_width, self.tcx.tcx).unwrap(),
260+
sym::bits => self.write_scalar(
261+
Scalar::from_u32(bit_width.try_into().expect("bit_width overflowed")),
262262
&field_place,
263263
)?,
264264
sym::signed => self.write_scalar(Scalar::from_bool(signed), &field_place)?,
@@ -278,8 +278,8 @@ impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
278278
{
279279
let field_place = self.project_field(&place, field_idx)?;
280280
match field.name {
281-
sym::bit_width => self.write_scalar(
282-
ScalarInt::try_from_target_usize(bit_width, self.tcx.tcx).unwrap(),
281+
sym::bits => self.write_scalar(
282+
Scalar::from_u32(bit_width.try_into().expect("bit_width overflowed")),
283283
&field_place,
284284
)?,
285285
other => span_bug!(self.tcx.def_span(field.did), "unimplemented field {other}"),

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
678678
rustc_attr!(
679679
rustc_pass_indirectly_in_non_rustic_abis, Normal, template!(Word), ErrorFollowing,
680680
EncodeCrossCrate::No,
681-
"types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic abis."
681+
"types marked with `#[rustc_pass_indirectly_in_non_rustic_abis]` are always passed indirectly by non-Rustic ABIs"
682682
),
683683

684684
// Limits:
@@ -1275,38 +1275,38 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
12751275
rustc_attr!(
12761276
rustc_as_ptr, Normal, template!(Word), ErrorFollowing,
12771277
EncodeCrossCrate::Yes,
1278-
"`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations."
1278+
"`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations"
12791279
),
12801280
rustc_attr!(
12811281
rustc_should_not_be_called_on_const_items, Normal, template!(Word), ErrorFollowing,
12821282
EncodeCrossCrate::Yes,
1283-
"`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts."
1283+
"`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts"
12841284
),
12851285
rustc_attr!(
12861286
rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
12871287
EncodeCrossCrate::Yes,
1288-
"`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference."
1288+
"`#[rustc_pass_by_value]` is used to mark types that must be passed by value instead of reference"
12891289
),
12901290
rustc_attr!(
12911291
rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing,
12921292
EncodeCrossCrate::Yes,
1293-
"`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers."
1293+
"`#[rustc_never_returns_null_ptr]` is used to mark functions returning non-null pointers"
12941294
),
12951295
rustc_attr!(
12961296
rustc_no_implicit_autorefs, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes,
1297-
"`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument."
1297+
"`#[rustc_no_implicit_autorefs]` is used to mark functions for which an autoref to the dereference of a raw pointer should not be used as an argument"
12981298
),
12991299
rustc_attr!(
13001300
rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, EncodeCrossCrate::No,
1301-
"`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`."
1301+
"`#![rustc_coherence_is_core]` allows inherent methods on builtin types, only intended to be used in `core`"
13021302
),
13031303
rustc_attr!(
13041304
rustc_coinductive, AttributeType::Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
1305-
"`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver."
1305+
"`#[rustc_coinductive]` changes a trait to be coinductive, allowing cycles in the trait solver"
13061306
),
13071307
rustc_attr!(
13081308
rustc_allow_incoherent_impl, AttributeType::Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::No,
1309-
"`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl."
1309+
"`#[rustc_allow_incoherent_impl]` has to be added to all impl items of an incoherent inherent impl"
13101310
),
13111311
rustc_attr!(
13121312
rustc_preserve_ub_checks, AttributeType::CrateLevel, template!(Word), ErrorFollowing, EncodeCrossCrate::No,
@@ -1333,7 +1333,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13331333
rustc_has_incoherent_inherent_impls, AttributeType::Normal, template!(Word),
13341334
ErrorFollowing, EncodeCrossCrate::Yes,
13351335
"`#[rustc_has_incoherent_inherent_impls]` allows the addition of incoherent inherent impls for \
1336-
the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`."
1336+
the given type by annotating all impl items with `#[rustc_allow_incoherent_impl]`"
13371337
),
13381338

13391339
BuiltinAttribute {
@@ -1396,7 +1396,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13961396
EncodeCrossCrate::No,
13971397
"the `#[rustc_skip_during_method_dispatch]` attribute is used to exclude a trait \
13981398
from method dispatch when the receiver is of the following type, for compatibility in \
1399-
editions < 2021 (array) or editions < 2024 (boxed_slice)."
1399+
editions < 2021 (array) or editions < 2024 (boxed_slice)"
14001400
),
14011401
rustc_attr!(
14021402
rustc_must_implement_one_of, Normal, template!(List: &["function1, function2, ..."]),

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ pub enum AttributeKind {
840840
/// Represents `#[naked]`
841841
Naked(Span),
842842

843+
/// Represents `#[needs_allocator]`
844+
NeedsAllocator,
845+
843846
/// Represents `#[no_core]`
844847
NoCore(Span),
845848

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl AttributeKind {
7575
MustNotSupend { .. } => Yes,
7676
MustUse { .. } => Yes,
7777
Naked(..) => No,
78+
NeedsAllocator => No,
7879
NoCore(..) => No,
7980
NoImplicitPrelude(..) => No,
8081
NoLink => No,

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
742742
proc_macro_data,
743743
debugger_visualizers,
744744
compiler_builtins: ast::attr::contains_name(attrs, sym::compiler_builtins),
745-
needs_allocator: ast::attr::contains_name(attrs, sym::needs_allocator),
745+
needs_allocator: find_attr!(attrs, AttributeKind::NeedsAllocator),
746746
needs_panic_runtime: ast::attr::contains_name(attrs, sym::needs_panic_runtime),
747747
no_builtins: ast::attr::contains_name(attrs, sym::no_builtins),
748748
panic_runtime: ast::attr::contains_name(attrs, sym::panic_runtime),

compiler/rustc_mir_transform/src/liveness.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,11 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
10861086

10871087
let Some((name, decl_span)) = self.checked_places.names[index] else { continue };
10881088

1089+
// By convention, underscore-prefixed bindings are explicitly allowed to be unused.
1090+
if name.as_str().starts_with('_') {
1091+
continue;
1092+
}
1093+
10891094
let is_maybe_drop_guard = maybe_drop_guard(
10901095
tcx,
10911096
self.typing_env,

0 commit comments

Comments
 (0)