Skip to content

Commit bca4136

Browse files
author
The Miri Cronjob Bot
committed
Merge ref '401ae5542752' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 401ae55 Filtered ref: 1bd47ec470de5c7eab11a24bfee0e7f663cd56a2 Upstream diff: 5f9dd05...401ae55 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 4384d43 + e77e5d1 commit bca4136

File tree

703 files changed

+9320
-3704
lines changed

Some content is hidden

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

703 files changed

+9320
-3704
lines changed

compiler/rustc_abi/src/canon_abi.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ pub enum CanonAbi {
5151
X86(X86Call),
5252
}
5353

54+
impl CanonAbi {
55+
pub fn is_rustic_abi(self) -> bool {
56+
match self {
57+
CanonAbi::Rust | CanonAbi::RustCold => true,
58+
CanonAbi::C
59+
| CanonAbi::Custom
60+
| CanonAbi::Arm(_)
61+
| CanonAbi::GpuKernel
62+
| CanonAbi::Interrupt(_)
63+
| CanonAbi::X86(_) => false,
64+
}
65+
}
66+
}
67+
5468
impl fmt::Display for CanonAbi {
5569
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5670
// convert to the ExternAbi that *shares a string* with this CanonAbi.

compiler/rustc_abi/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
812812
let (max, min) = largest_niche
813813
// We might have no inhabited variants, so pretend there's at least one.
814814
.unwrap_or((0, 0));
815-
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::repr_discr(tcx, ty, &repr, min, max);
815+
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::discr_range_of_repr(tcx, ty, &repr, min, max);
816816

817817
let mut align = dl.aggregate_align;
818818
let mut max_repr_align = repr.align;

compiler/rustc_abi/src/layout/ty.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug {
172172
fn is_tuple(this: TyAndLayout<'a, Self>) -> bool;
173173
fn is_unit(this: TyAndLayout<'a, Self>) -> bool;
174174
fn is_transparent(this: TyAndLayout<'a, Self>) -> bool;
175+
/// See [`TyAndLayout::pass_indirectly_in_non_rustic_abis`] for details.
176+
fn is_pass_indirectly_in_non_rustic_abis_flag_set(this: TyAndLayout<'a, Self>) -> bool;
175177
}
176178

177179
impl<'a, Ty> TyAndLayout<'a, Ty> {
@@ -269,6 +271,30 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
269271
Ty::is_transparent(self)
270272
}
271273

274+
/// If this method returns `true`, then this type should always have a `PassMode` of
275+
/// `Indirect { on_stack: false, .. }` when being used as the argument type of a function with a
276+
/// non-Rustic ABI (this is true for structs annotated with the
277+
/// `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute).
278+
///
279+
/// This is used to replicate some of the behaviour of C array-to-pointer decay; however unlike
280+
/// C any changes the caller makes to the passed value will not be reflected in the callee, so
281+
/// the attribute is only useful for types where observing the value in the caller after the
282+
/// function call isn't allowed (a.k.a. `va_list`).
283+
///
284+
/// This function handles transparent types automatically.
285+
pub fn pass_indirectly_in_non_rustic_abis<C>(mut self, cx: &C) -> bool
286+
where
287+
Ty: TyAbiInterface<'a, C> + Copy,
288+
{
289+
while self.is_transparent()
290+
&& let Some((_, field)) = self.non_1zst_field(cx)
291+
{
292+
self = field;
293+
}
294+
295+
Ty::is_pass_indirectly_in_non_rustic_abis_flag_set(self)
296+
}
297+
272298
/// Finds the one field that is not a 1-ZST.
273299
/// Returns `None` if there are multiple non-1-ZST fields or only 1-ZST-fields.
274300
pub fn non_1zst_field<C>(&self, cx: &C) -> Option<(FieldIdx, Self)>

compiler/rustc_abi/src/lib.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// tidy-alphabetical-start
22
#![cfg_attr(feature = "nightly", allow(internal_features))]
3-
#![cfg_attr(feature = "nightly", doc(rust_logo))]
43
#![cfg_attr(feature = "nightly", feature(assert_matches))]
54
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
6-
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
75
#![cfg_attr(feature = "nightly", feature(step_trait))]
86
// tidy-alphabetical-end
97

@@ -88,14 +86,17 @@ bitflags! {
8886
const IS_C = 1 << 0;
8987
const IS_SIMD = 1 << 1;
9088
const IS_TRANSPARENT = 1 << 2;
91-
// Internal only for now. If true, don't reorder fields.
92-
// On its own it does not prevent ABI optimizations.
89+
/// Internal only for now. If true, don't reorder fields.
90+
/// On its own it does not prevent ABI optimizations.
9391
const IS_LINEAR = 1 << 3;
94-
// If true, the type's crate has opted into layout randomization.
95-
// Other flags can still inhibit reordering and thus randomization.
96-
// The seed stored in `ReprOptions.field_shuffle_seed`.
92+
/// If true, the type's crate has opted into layout randomization.
93+
/// Other flags can still inhibit reordering and thus randomization.
94+
/// The seed stored in `ReprOptions.field_shuffle_seed`.
9795
const RANDOMIZE_LAYOUT = 1 << 4;
98-
// Any of these flags being set prevent field reordering optimisation.
96+
/// If true, the type is always passed indirectly by non-Rustic ABIs.
97+
/// See [`TyAndLayout::pass_indirectly_in_non_rustic_abis`] for details.
98+
const PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS = 1 << 5;
99+
/// Any of these flags being set prevent field reordering optimisation.
99100
const FIELD_ORDER_UNOPTIMIZABLE = ReprFlags::IS_C.bits()
100101
| ReprFlags::IS_SIMD.bits()
101102
| ReprFlags::IS_LINEAR.bits();
@@ -183,6 +184,11 @@ impl ReprOptions {
183184

184185
/// Returns the discriminant type, given these `repr` options.
185186
/// This must only be called on enums!
187+
///
188+
/// This is the "typeck type" of the discriminant, which is effectively the maximum size:
189+
/// discriminant values will be wrapped to fit (with a lint). Layout can later decide to use a
190+
/// smaller type for the tag that stores the discriminant at runtime and that will work just
191+
/// fine, it just induces casts when getting/setting the discriminant.
186192
pub fn discr_type(&self) -> IntegerType {
187193
self.int.unwrap_or(IntegerType::Pointer(true))
188194
}

compiler/rustc_arena/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,13 @@
1212
#![allow(internal_features)]
1313
#![cfg_attr(test, feature(test))]
1414
#![deny(unsafe_op_in_unsafe_fn)]
15-
#![doc(
16-
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
17-
test(no_crate_inject, attr(deny(warnings)))
18-
)]
19-
#![doc(rust_logo)]
15+
#![doc(test(no_crate_inject, attr(deny(warnings), allow(internal_features))))]
2016
#![feature(core_intrinsics)]
2117
#![feature(decl_macro)]
2218
#![feature(dropck_eyepatch)]
2319
#![feature(maybe_uninit_slice)]
2420
#![feature(never_type)]
2521
#![feature(rustc_attrs)]
26-
#![feature(rustdoc_internals)]
2722
#![feature(unwrap_infallible)]
2823
// tidy-alphabetical-end
2924

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@
55
//! This API is completely unstable and subject to change.
66
77
// tidy-alphabetical-start
8-
#![allow(internal_features)]
9-
#![doc(
10-
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
11-
test(attr(deny(warnings)))
12-
)]
13-
#![doc(rust_logo)]
8+
#![doc(test(attr(deny(warnings), allow(internal_features))))]
149
#![feature(array_windows)]
1510
#![feature(associated_type_defaults)]
1611
#![feature(box_patterns)]
1712
#![feature(if_let_guard)]
1813
#![feature(iter_order_by)]
1914
#![feature(macro_metavar_expr)]
20-
#![feature(rustdoc_internals)]
2115
#![recursion_limit = "256"]
2216
// tidy-alphabetical-end
2317

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@
3131
//! in the HIR, especially for multiple identifiers.
3232
3333
// tidy-alphabetical-start
34-
#![allow(internal_features)]
35-
#![doc(rust_logo)]
3634
#![feature(box_patterns)]
3735
#![feature(if_let_guard)]
38-
#![feature(rustdoc_internals)]
3936
// tidy-alphabetical-end
4037

4138
use std::sync::Arc;

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
//! by `rustc_ast_lowering`.
44
55
// tidy-alphabetical-start
6-
#![allow(internal_features)]
7-
#![doc(rust_logo)]
86
#![feature(box_patterns)]
97
#![feature(if_let_guard)]
108
#![feature(iter_is_partitioned)]
11-
#![feature(rustdoc_internals)]
129
// tidy-alphabetical-end
1310

1411
pub mod ast_validation;

compiler/rustc_ast_pretty/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// tidy-alphabetical-start
2-
#![allow(internal_features)]
3-
#![doc(rust_logo)]
42
#![feature(box_patterns)]
53
#![feature(negative_impls)]
6-
#![feature(rustdoc_internals)]
74
// tidy-alphabetical-end
85

96
mod helpers;

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,12 @@ impl<S: Stage> SingleAttributeParser<S> for SanitizeParser {
676676
Some(AttributeKind::Sanitize { on_set, off_set, span: cx.attr_span })
677677
}
678678
}
679+
680+
pub(crate) struct RustcPassIndirectlyInNonRusticAbisParser;
681+
682+
impl<S: Stage> NoArgsAttributeParser<S> for RustcPassIndirectlyInNonRusticAbisParser {
683+
const PATH: &[Symbol] = &[sym::rustc_pass_indirectly_in_non_rustic_abis];
684+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
685+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
686+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPassIndirectlyInNonRusticAbis;
687+
}

0 commit comments

Comments
 (0)