Skip to content

Commit 7b31983

Browse files
committed
Auto merge of rust-lang#136533 - jhpratt:rollup-s0ign8n, r=jhpratt
Rollup of 5 pull requests Successful merges: - rust-lang#134777 (Enable more tests on Windows) - rust-lang#135621 (Move some std tests to integration tests) - rust-lang#135844 ( Add new tool for dumping feature status based on tidy ) - rust-lang#136167 (Implement unstable `new_range` feature) - rust-lang#136334 (Extract `core::ffi` primitives to a separate (internal) module) Failed merges: - rust-lang#136201 (Removed dependency on the field-offset crate, alternate approach) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 019fc4d + 54f9ef9 commit 7b31983

File tree

142 files changed

+1234
-926
lines changed

Some content is hidden

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

142 files changed

+1234
-926
lines changed

Cargo.lock

+15
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ name = "anyhow"
186186
version = "1.0.95"
187187
source = "registry+https://github.com/rust-lang/crates.io-index"
188188
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
189+
dependencies = [
190+
"backtrace",
191+
]
189192

190193
[[package]]
191194
name = "ar_archive_writer"
@@ -1195,6 +1198,17 @@ version = "2.3.0"
11951198
source = "registry+https://github.com/rust-lang/crates.io-index"
11961199
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
11971200

1201+
[[package]]
1202+
name = "features-status-dump"
1203+
version = "0.1.0"
1204+
dependencies = [
1205+
"anyhow",
1206+
"clap",
1207+
"serde",
1208+
"serde_json",
1209+
"tidy",
1210+
]
1211+
11981212
[[package]]
11991213
name = "field-offset"
12001214
version = "0.3.6"
@@ -5418,6 +5432,7 @@ dependencies = [
54185432
"regex",
54195433
"rustc-hash 2.1.0",
54205434
"semver",
5435+
"serde",
54215436
"similar",
54225437
"termcolor",
54235438
"walkdir",

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ members = [
4747
"src/tools/coverage-dump",
4848
"src/tools/rustc-perf-wrapper",
4949
"src/tools/wasm-component-ld",
50+
"src/tools/features-status-dump",
5051
]
5152

5253
exclude = [

compiler/rustc_ast_lowering/src/expr.rs

+28-7
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
284284
ExprKind::Index(el, er, brackets_span) => {
285285
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er), *brackets_span)
286286
}
287-
ExprKind::Range(Some(e1), Some(e2), RangeLimits::Closed) => {
288-
self.lower_expr_range_closed(e.span, e1, e2)
289-
}
290287
ExprKind::Range(e1, e2, lims) => {
291288
self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), *lims)
292289
}
@@ -1512,15 +1509,39 @@ impl<'hir> LoweringContext<'_, 'hir> {
15121509

15131510
let lang_item = match (e1, e2, lims) {
15141511
(None, None, HalfOpen) => hir::LangItem::RangeFull,
1515-
(Some(..), None, HalfOpen) => hir::LangItem::RangeFrom,
1512+
(Some(..), None, HalfOpen) => {
1513+
if self.tcx.features().new_range() {
1514+
hir::LangItem::RangeFromCopy
1515+
} else {
1516+
hir::LangItem::RangeFrom
1517+
}
1518+
}
15161519
(None, Some(..), HalfOpen) => hir::LangItem::RangeTo,
1517-
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
1520+
(Some(..), Some(..), HalfOpen) => {
1521+
if self.tcx.features().new_range() {
1522+
hir::LangItem::RangeCopy
1523+
} else {
1524+
hir::LangItem::Range
1525+
}
1526+
}
15181527
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
1519-
(Some(..), Some(..), Closed) => unreachable!(),
1528+
(Some(e1), Some(e2), Closed) => {
1529+
if self.tcx.features().new_range() {
1530+
hir::LangItem::RangeInclusiveCopy
1531+
} else {
1532+
return self.lower_expr_range_closed(span, e1, e2);
1533+
}
1534+
}
15201535
(start, None, Closed) => {
15211536
self.dcx().emit_err(InclusiveRangeWithNoEnd { span });
15221537
match start {
1523-
Some(..) => hir::LangItem::RangeFrom,
1538+
Some(..) => {
1539+
if self.tcx.features().new_range() {
1540+
hir::LangItem::RangeFromCopy
1541+
} else {
1542+
hir::LangItem::RangeFrom
1543+
}
1544+
}
15241545
None => hir::LangItem::RangeFull,
15251546
}
15261547
}

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ declare_features! (
570570
(unstable, never_type, "1.13.0", Some(35121)),
571571
/// Allows diverging expressions to fall back to `!` rather than `()`.
572572
(unstable, never_type_fallback, "1.41.0", Some(65992)),
573+
/// Switch `..` syntax to use the new (`Copy + IntoIterator`) range types.
574+
(unstable, new_range, "CURRENT_RUSTC_VERSION", Some(123741)),
573575
/// Allows `#![no_core]`.
574576
(unstable, no_core, "1.3.0", Some(29639)),
575577
/// Allows the use of `no_sanitize` attribute.

compiler/rustc_hir/src/hir.rs

+40-1
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,18 @@ impl Expr<'_> {
23132313
[val2],
23142314
StructTailExpr::None,
23152315
),
2316+
)
2317+
| (
2318+
ExprKind::Struct(
2319+
QPath::LangItem(LangItem::RangeFromCopy, _),
2320+
[val1],
2321+
StructTailExpr::None,
2322+
),
2323+
ExprKind::Struct(
2324+
QPath::LangItem(LangItem::RangeFromCopy, _),
2325+
[val2],
2326+
StructTailExpr::None,
2327+
),
23162328
) => val1.expr.equivalent_for_indexing(val2.expr),
23172329
(
23182330
ExprKind::Struct(
@@ -2325,6 +2337,30 @@ impl Expr<'_> {
23252337
[val2, val4],
23262338
StructTailExpr::None,
23272339
),
2340+
)
2341+
| (
2342+
ExprKind::Struct(
2343+
QPath::LangItem(LangItem::RangeCopy, _),
2344+
[val1, val3],
2345+
StructTailExpr::None,
2346+
),
2347+
ExprKind::Struct(
2348+
QPath::LangItem(LangItem::RangeCopy, _),
2349+
[val2, val4],
2350+
StructTailExpr::None,
2351+
),
2352+
)
2353+
| (
2354+
ExprKind::Struct(
2355+
QPath::LangItem(LangItem::RangeInclusiveCopy, _),
2356+
[val1, val3],
2357+
StructTailExpr::None,
2358+
),
2359+
ExprKind::Struct(
2360+
QPath::LangItem(LangItem::RangeInclusiveCopy, _),
2361+
[val2, val4],
2362+
StructTailExpr::None,
2363+
),
23282364
) => {
23292365
val1.expr.equivalent_for_indexing(val2.expr)
23302366
&& val3.expr.equivalent_for_indexing(val4.expr)
@@ -2354,7 +2390,10 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
23542390
| LangItem::RangeTo
23552391
| LangItem::RangeFrom
23562392
| LangItem::RangeFull
2357-
| LangItem::RangeToInclusive,
2393+
| LangItem::RangeToInclusive
2394+
| LangItem::RangeCopy
2395+
| LangItem::RangeFromCopy
2396+
| LangItem::RangeInclusiveCopy,
23582397
..
23592398
)
23602399
),

compiler/rustc_hir/src/lang_items.rs

+5
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ language_item_table! {
416416
RangeToInclusive, sym::RangeToInclusive, range_to_inclusive_struct, Target::Struct, GenericRequirement::None;
417417
RangeTo, sym::RangeTo, range_to_struct, Target::Struct, GenericRequirement::None;
418418

419+
// `new_range` types that are `Copy + IntoIterator`
420+
RangeFromCopy, sym::RangeFromCopy, range_from_copy_struct, Target::Struct, GenericRequirement::None;
421+
RangeCopy, sym::RangeCopy, range_copy_struct, Target::Struct, GenericRequirement::None;
422+
RangeInclusiveCopy, sym::RangeInclusiveCopy, range_inclusive_copy_struct, Target::Struct, GenericRequirement::None;
423+
419424
String, sym::String, string, Target::Struct, GenericRequirement::None;
420425
CStr, sym::CStr, c_str, Target::Struct, GenericRequirement::None;
421426
}

compiler/rustc_hir_typeck/src/method/suggest.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23952395
let lang_item = match parent_expr.kind {
23962396
ExprKind::Struct(qpath, _, _) => match *qpath {
23972397
QPath::LangItem(LangItem::Range, ..) => Some(LangItem::Range),
2398+
QPath::LangItem(LangItem::RangeCopy, ..) => Some(LangItem::RangeCopy),
2399+
QPath::LangItem(LangItem::RangeInclusiveCopy, ..) => {
2400+
Some(LangItem::RangeInclusiveCopy)
2401+
}
23982402
QPath::LangItem(LangItem::RangeTo, ..) => Some(LangItem::RangeTo),
23992403
QPath::LangItem(LangItem::RangeToInclusive, ..) => {
24002404
Some(LangItem::RangeToInclusive)

compiler/rustc_span/src/symbol.rs

+4
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,12 @@ symbols! {
294294
ProceduralMasqueradeDummyType,
295295
Range,
296296
RangeBounds,
297+
RangeCopy,
297298
RangeFrom,
299+
RangeFromCopy,
298300
RangeFull,
299301
RangeInclusive,
302+
RangeInclusiveCopy,
300303
RangeTo,
301304
RangeToInclusive,
302305
Rc,
@@ -1364,6 +1367,7 @@ symbols! {
13641367
new_lower_hex,
13651368
new_octal,
13661369
new_pointer,
1370+
new_range,
13671371
new_unchecked,
13681372
new_upper_exp,
13691373
new_upper_hex,

library/core/src/ffi/mod.rs

+7-168
Original file line numberDiff line numberDiff line change
@@ -37,175 +37,14 @@ pub use self::va_list::{VaList, VaListImpl};
3737
)]
3838
pub mod va_list;
3939

40-
macro_rules! type_alias {
41-
{
42-
$Docfile:tt, $Alias:ident = $Real:ty;
43-
$( $Cfg:tt )*
44-
} => {
45-
#[doc = include_str!($Docfile)]
46-
$( $Cfg )*
47-
#[stable(feature = "core_ffi_c", since = "1.64.0")]
48-
pub type $Alias = $Real;
49-
}
50-
}
51-
52-
type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] }
53-
54-
type_alias! { "c_schar.md", c_schar = i8; }
55-
type_alias! { "c_uchar.md", c_uchar = u8; }
56-
type_alias! { "c_short.md", c_short = i16; }
57-
type_alias! { "c_ushort.md", c_ushort = u16; }
58-
59-
type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(all()))] }
60-
type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(all()))] }
61-
62-
type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(all()))] }
63-
type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(all()))] }
64-
65-
type_alias! { "c_longlong.md", c_longlong = i64; }
66-
type_alias! { "c_ulonglong.md", c_ulonglong = u64; }
67-
68-
type_alias! { "c_float.md", c_float = f32; }
69-
type_alias! { "c_double.md", c_double = f64; }
70-
71-
/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
72-
///
73-
/// This type is currently always [`usize`], however in the future there may be
74-
/// platforms where this is not the case.
75-
#[unstable(feature = "c_size_t", issue = "88345")]
76-
pub type c_size_t = usize;
77-
78-
/// Equivalent to C's `ptrdiff_t` type, from `stddef.h` (or `cstddef` for C++).
79-
///
80-
/// This type is currently always [`isize`], however in the future there may be
81-
/// platforms where this is not the case.
40+
mod primitives;
41+
#[stable(feature = "core_ffi_c", since = "1.64.0")]
42+
pub use self::primitives::{
43+
c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint,
44+
c_ulong, c_ulonglong, c_ushort,
45+
};
8246
#[unstable(feature = "c_size_t", issue = "88345")]
83-
pub type c_ptrdiff_t = isize;
84-
85-
/// Equivalent to C's `ssize_t` (on POSIX) or `SSIZE_T` (on Windows) type.
86-
///
87-
/// This type is currently always [`isize`], however in the future there may be
88-
/// platforms where this is not the case.
89-
#[unstable(feature = "c_size_t", issue = "88345")]
90-
pub type c_ssize_t = isize;
91-
92-
mod c_char_definition {
93-
cfg_if! {
94-
// These are the targets on which c_char is unsigned. Usually the
95-
// signedness is the same for all target_os values on a given architecture
96-
// but there are some exceptions (see isSignedCharDefault() in clang).
97-
//
98-
// aarch64:
99-
// Section 10 "Arm C and C++ language mappings" in Procedure Call Standard for the Arm®
100-
// 64-bit Architecture (AArch64) says C/C++ char is unsigned byte.
101-
// https://github.com/ARM-software/abi-aa/blob/2024Q3/aapcs64/aapcs64.rst#arm-c-and-c-language-mappings
102-
// arm:
103-
// Section 8 "Arm C and C++ Language Mappings" in Procedure Call Standard for the Arm®
104-
// Architecture says C/C++ char is unsigned byte.
105-
// https://github.com/ARM-software/abi-aa/blob/2024Q3/aapcs32/aapcs32.rst#arm-c-and-c-language-mappings
106-
// csky:
107-
// Section 2.1.2 "Primary Data Type" in C-SKY V2 CPU Applications Binary Interface
108-
// Standards Manual says ANSI C char is unsigned byte.
109-
// https://github.com/c-sky/csky-doc/blob/9f7121f7d40970ba5cc0f15716da033db2bb9d07/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf
110-
// Note: this doesn't seem to match Clang's default (https://github.com/rust-lang/rust/issues/129945).
111-
// hexagon:
112-
// Section 3.1 "Basic data type" in Qualcomm Hexagon™ Application
113-
// Binary Interface User Guide says "By default, the `char` data type is unsigned."
114-
// https://docs.qualcomm.com/bundle/publicresource/80-N2040-23_REV_K_Qualcomm_Hexagon_Application_Binary_Interface_User_Guide.pdf
115-
// msp430:
116-
// Section 2.1 "Basic Types" in MSP430 Embedded Application Binary
117-
// Interface says "The char type is unsigned by default".
118-
// https://www.ti.com/lit/an/slaa534a/slaa534a.pdf
119-
// powerpc/powerpc64:
120-
// - PPC32 SysV: "Table 3-1 Scalar Types" in System V Application Binary Interface PowerPC
121-
// Processor Supplement says ANSI C char is unsigned byte
122-
// https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf
123-
// - PPC64 ELFv1: Section 3.1.4 "Fundamental Types" in 64-bit PowerPC ELF Application
124-
// Binary Interface Supplement 1.9 says ANSI C is unsigned byte
125-
// https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUND-TYPE
126-
// - PPC64 ELFv2: Section 2.1.2.2 "Fundamental Types" in 64-Bit ELF V2 ABI Specification
127-
// says char is unsigned byte
128-
// https://openpowerfoundation.org/specifications/64bitelfabi/
129-
// - AIX: XL C for AIX Language Reference says "By default, char behaves like an unsigned char."
130-
// https://www.ibm.com/docs/en/xl-c-aix/13.1.3?topic=specifiers-character-types
131-
// riscv32/riscv64:
132-
// C/C++ type representations section in RISC-V Calling Conventions
133-
// page in RISC-V ELF psABI Document says "char is unsigned."
134-
// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/draft-20240829-13bfa9f54634cb60d86b9b333e109f077805b4b3/riscv-cc.adoc#cc-type-representations
135-
// s390x:
136-
// - ELF: "Table 1.1.: Scalar types" in ELF Application Binary Interface s390x Supplement
137-
// Version 1.6.1 categorize ISO C char in unsigned integer
138-
// https://github.com/IBM/s390x-abi/releases/tag/v1.6.1
139-
// - z/OS: XL C/C++ Language Reference says: "By default, char behaves like an unsigned char."
140-
// https://www.ibm.com/docs/en/zos/3.1.0?topic=specifiers-character-types
141-
// xtensa:
142-
// Section 2.17.1 "Data Types and Alignment" of Xtensa LX Microprocessor Overview handbook
143-
// says "`char` type is unsigned by default".
144-
// https://loboris.eu/ESP32/Xtensa_lx%20Overview%20handbook.pdf
145-
//
146-
// On the following operating systems, c_char is signed by default, regardless of architecture.
147-
// Darwin (macOS, iOS, etc.):
148-
// Apple targets' c_char is signed by default even on arm
149-
// https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Handle-data-types-and-data-alignment-properly
150-
// Windows:
151-
// Windows MSVC C++ Language Reference says "Microsoft-specific: Variables of type char
152-
// are promoted to int as if from type signed char by default, unless the /J compilation
153-
// option is used."
154-
// https://learn.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp?view=msvc-170#character-types
155-
// L4Re:
156-
// The kernel builds with -funsigned-char on all targets (but useserspace follows the
157-
// architecture defaults). As we only have a target for userspace apps so there are no
158-
// special cases for L4Re below.
159-
// https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240
160-
if #[cfg(all(
161-
not(windows),
162-
not(target_vendor = "apple"),
163-
any(
164-
target_arch = "aarch64",
165-
target_arch = "arm",
166-
target_arch = "csky",
167-
target_arch = "hexagon",
168-
target_arch = "msp430",
169-
target_arch = "powerpc",
170-
target_arch = "powerpc64",
171-
target_arch = "riscv32",
172-
target_arch = "riscv64",
173-
target_arch = "s390x",
174-
target_arch = "xtensa",
175-
)
176-
))] {
177-
pub(super) type c_char = u8;
178-
} else {
179-
// On every other target, c_char is signed.
180-
pub(super) type c_char = i8;
181-
}
182-
}
183-
}
184-
185-
mod c_int_definition {
186-
cfg_if! {
187-
if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
188-
pub(super) type c_int = i16;
189-
pub(super) type c_uint = u16;
190-
} else {
191-
pub(super) type c_int = i32;
192-
pub(super) type c_uint = u32;
193-
}
194-
}
195-
}
196-
197-
mod c_long_definition {
198-
cfg_if! {
199-
if #[cfg(all(target_pointer_width = "64", not(windows)))] {
200-
pub(super) type c_long = i64;
201-
pub(super) type c_ulong = u64;
202-
} else {
203-
// The minimal size of `long` in the C standard is 32 bits
204-
pub(super) type c_long = i32;
205-
pub(super) type c_ulong = u32;
206-
}
207-
}
208-
}
47+
pub use self::primitives::{c_ptrdiff_t, c_size_t, c_ssize_t};
20948

21049
// N.B., for LLVM to recognize the void pointer type and by extension
21150
// functions like malloc(), we need to have it represented as i8* in

0 commit comments

Comments
 (0)