Skip to content

Commit 7dd00c3

Browse files
committed
Auto merge of #124730 - fmease:rollup-uciy8d8, r=fmease
Rollup of 7 pull requests Successful merges: - #122253 (Support Result<T, E> across FFI when niche optimization can be used) - #123892 (Document That `f16` And `f128` Hardware Support is Limited) - #124458 (Implement lldb formattter for "clang encoded" enums (LLDB 18.1+)) - #124459 (Stabilize exclusive_range_pattern) - #124711 (Migrate `run-make/doctests-runtool` to rmake) - #124725 (Meta: Enable the brand new triagebot transfer command) - #124727 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e82c861 + 242fb92 commit 7dd00c3

File tree

214 files changed

+2355
-1529
lines changed

Some content is hidden

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

214 files changed

+2355
-1529
lines changed

Cargo.lock

+79-9
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,28 @@ dependencies = [
512512
"windows-targets 0.52.4",
513513
]
514514

515+
[[package]]
516+
name = "chrono-tz"
517+
version = "0.9.0"
518+
source = "registry+https://github.com/rust-lang/crates.io-index"
519+
checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
520+
dependencies = [
521+
"chrono",
522+
"chrono-tz-build",
523+
"phf 0.11.2",
524+
]
525+
526+
[[package]]
527+
name = "chrono-tz-build"
528+
version = "0.3.0"
529+
source = "registry+https://github.com/rust-lang/crates.io-index"
530+
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
531+
dependencies = [
532+
"parse-zoneinfo",
533+
"phf 0.11.2",
534+
"phf_codegen 0.11.2",
535+
]
536+
515537
[[package]]
516538
name = "cipher"
517539
version = "0.4.4"
@@ -2318,8 +2340,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
23182340
checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
23192341
dependencies = [
23202342
"log",
2321-
"phf",
2322-
"phf_codegen",
2343+
"phf 0.10.1",
2344+
"phf_codegen 0.10.0",
23232345
"string_cache",
23242346
"string_cache_codegen",
23252347
"tendril",
@@ -2480,6 +2502,7 @@ version = "0.1.0"
24802502
dependencies = [
24812503
"aes",
24822504
"chrono",
2505+
"chrono-tz",
24832506
"colored",
24842507
"ctrlc",
24852508
"directories",
@@ -2835,6 +2858,15 @@ dependencies = [
28352858
"windows-targets 0.48.5",
28362859
]
28372860

2861+
[[package]]
2862+
name = "parse-zoneinfo"
2863+
version = "0.3.1"
2864+
source = "registry+https://github.com/rust-lang/crates.io-index"
2865+
checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24"
2866+
dependencies = [
2867+
"regex",
2868+
]
2869+
28382870
[[package]]
28392871
name = "pathdiff"
28402872
version = "0.2.1"
@@ -2907,7 +2939,16 @@ version = "0.10.1"
29072939
source = "registry+https://github.com/rust-lang/crates.io-index"
29082940
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
29092941
dependencies = [
2910-
"phf_shared",
2942+
"phf_shared 0.10.0",
2943+
]
2944+
2945+
[[package]]
2946+
name = "phf"
2947+
version = "0.11.2"
2948+
source = "registry+https://github.com/rust-lang/crates.io-index"
2949+
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
2950+
dependencies = [
2951+
"phf_shared 0.11.2",
29112952
]
29122953

29132954
[[package]]
@@ -2916,8 +2957,18 @@ version = "0.10.0"
29162957
source = "registry+https://github.com/rust-lang/crates.io-index"
29172958
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
29182959
dependencies = [
2919-
"phf_generator",
2920-
"phf_shared",
2960+
"phf_generator 0.10.0",
2961+
"phf_shared 0.10.0",
2962+
]
2963+
2964+
[[package]]
2965+
name = "phf_codegen"
2966+
version = "0.11.2"
2967+
source = "registry+https://github.com/rust-lang/crates.io-index"
2968+
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
2969+
dependencies = [
2970+
"phf_generator 0.11.2",
2971+
"phf_shared 0.11.2",
29212972
]
29222973

29232974
[[package]]
@@ -2926,7 +2977,17 @@ version = "0.10.0"
29262977
source = "registry+https://github.com/rust-lang/crates.io-index"
29272978
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
29282979
dependencies = [
2929-
"phf_shared",
2980+
"phf_shared 0.10.0",
2981+
"rand",
2982+
]
2983+
2984+
[[package]]
2985+
name = "phf_generator"
2986+
version = "0.11.2"
2987+
source = "registry+https://github.com/rust-lang/crates.io-index"
2988+
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
2989+
dependencies = [
2990+
"phf_shared 0.11.2",
29302991
"rand",
29312992
]
29322993

@@ -2939,6 +3000,15 @@ dependencies = [
29393000
"siphasher",
29403001
]
29413002

3003+
[[package]]
3004+
name = "phf_shared"
3005+
version = "0.11.2"
3006+
source = "registry+https://github.com/rust-lang/crates.io-index"
3007+
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
3008+
dependencies = [
3009+
"siphasher",
3010+
]
3011+
29423012
[[package]]
29433013
name = "pin-project-lite"
29443014
version = "0.2.14"
@@ -5285,7 +5355,7 @@ dependencies = [
52855355
"new_debug_unreachable",
52865356
"once_cell",
52875357
"parking_lot",
5288-
"phf_shared",
5358+
"phf_shared 0.10.0",
52895359
"precomputed-hash",
52905360
"serde",
52915361
]
@@ -5296,8 +5366,8 @@ version = "0.5.2"
52965366
source = "registry+https://github.com/rust-lang/crates.io-index"
52975367
checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
52985368
dependencies = [
5299-
"phf_generator",
5300-
"phf_shared",
5369+
"phf_generator 0.10.0",
5370+
"phf_shared 0.10.0",
53015371
"proc-macro2",
53025372
"quote",
53035373
]

compiler/rustc_ast_passes/src/feature_gate.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast as ast;
22
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
33
use rustc_ast::{attr, AssocConstraint, AssocConstraintKind, NodeId};
4-
use rustc_ast::{token, PatKind, RangeEnd};
4+
use rustc_ast::{token, PatKind};
55
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
77
use rustc_session::Session;
@@ -418,15 +418,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
418418
PatKind::Box(..) => {
419419
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
420420
}
421-
PatKind::Range(_, Some(_), Spanned { node: RangeEnd::Excluded, .. }) => {
422-
gate!(
423-
&self,
424-
exclusive_range_pattern,
425-
pattern.span,
426-
"exclusive range pattern syntax is experimental",
427-
"use an inclusive range pattern, like N..=M"
428-
);
429-
}
430421
_ => {}
431422
}
432423
visit::walk_pat(self, pattern)
@@ -619,10 +610,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
619610
// be too.
620611
gate_all_legacy_dont_use!(return_type_notation, "return type notation is experimental");
621612
gate_all_legacy_dont_use!(decl_macro, "`macro` is experimental");
622-
gate_all_legacy_dont_use!(
623-
exclusive_range_pattern,
624-
"exclusive range pattern syntax is experimental"
625-
);
626613
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
627614
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");
628615

compiler/rustc_error_codes/src/error_codes/E0579.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ A lower range wasn't less than the upper range.
33
Erroneous code example:
44

55
```compile_fail,E0579
6-
#![feature(exclusive_range_pattern)]
76
87
fn main() {
98
match 5u32 {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ declare_features! (
162162
(accepted, drop_types_in_const, "1.22.0", Some(33156)),
163163
/// Allows using `dyn Trait` as a syntax for trait objects.
164164
(accepted, dyn_trait, "1.27.0", Some(44662)),
165+
/// Allows `X..Y` patterns.
166+
(accepted, exclusive_range_pattern, "CURRENT_RUSTC_VERSION", Some(37854)),
165167
/// Allows integer match exhaustiveness checking (RFC 2591).
166168
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907)),
167169
/// Allows explicit generic arguments specification with `impl Trait` present.

compiler/rustc_feature/src/unstable.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,6 @@ declare_features! (
454454
(incomplete, dyn_star, "1.65.0", Some(102425)),
455455
/// Uses generic effect parameters for ~const bounds
456456
(unstable, effects, "1.72.0", Some(102090)),
457-
/// Allows `X..Y` patterns.
458-
(unstable, exclusive_range_pattern, "1.11.0", Some(37854)),
459457
/// Allows exhaustive pattern matching on types that contain uninhabited types.
460458
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
461459
/// Allows explicit tail calls via `become` expression.
@@ -581,6 +579,9 @@ declare_features! (
581579
(incomplete, repr128, "1.16.0", Some(56071)),
582580
/// Allows `repr(simd)` and importing the various simd intrinsics.
583581
(unstable, repr_simd, "1.4.0", Some(27731)),
582+
/// Allows enums like Result<T, E> to be used across FFI, if T's niche value can
583+
/// be used to describe E or vise-versa.
584+
(unstable, result_ffi_guarantees, "CURRENT_RUSTC_VERSION", Some(110503)),
584585
/// Allows bounding the return type of AFIT/RPITIT.
585586
(incomplete, return_type_notation, "1.70.0", Some(109417)),
586587
/// Allows `extern "rust-cold"`.

compiler/rustc_lint/src/types.rs

+56-13
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,32 @@ fn get_nullable_type<'tcx>(
11011101
})
11021102
}
11031103

1104+
/// A type is niche-optimization candidate iff:
1105+
/// - Is a zero-sized type with alignment 1 (a “1-ZST”).
1106+
/// - Has no fields.
1107+
/// - Does not have the `#[non_exhaustive]` attribute.
1108+
fn is_niche_optimization_candidate<'tcx>(
1109+
tcx: TyCtxt<'tcx>,
1110+
param_env: ty::ParamEnv<'tcx>,
1111+
ty: Ty<'tcx>,
1112+
) -> bool {
1113+
if tcx.layout_of(param_env.and(ty)).is_ok_and(|layout| !layout.is_1zst()) {
1114+
return false;
1115+
}
1116+
1117+
match ty.kind() {
1118+
ty::Adt(ty_def, _) => {
1119+
let non_exhaustive = ty_def.is_variant_list_non_exhaustive();
1120+
let empty = (ty_def.is_struct() && ty_def.all_fields().next().is_none())
1121+
|| (ty_def.is_enum() && ty_def.variants().is_empty());
1122+
1123+
!non_exhaustive && empty
1124+
}
1125+
ty::Tuple(tys) => tys.is_empty(),
1126+
_ => false,
1127+
}
1128+
}
1129+
11041130
/// Check if this enum can be safely exported based on the "nullable pointer optimization". If it
11051131
/// can, return the type that `ty` can be safely converted to, otherwise return `None`.
11061132
/// Currently restricted to function pointers, boxes, references, `core::num::NonZero`,
@@ -1117,6 +1143,22 @@ pub(crate) fn repr_nullable_ptr<'tcx>(
11171143
let field_ty = match &ty_def.variants().raw[..] {
11181144
[var_one, var_two] => match (&var_one.fields.raw[..], &var_two.fields.raw[..]) {
11191145
([], [field]) | ([field], []) => field.ty(tcx, args),
1146+
([field1], [field2]) => {
1147+
if !tcx.features().result_ffi_guarantees {
1148+
return None;
1149+
}
1150+
1151+
let ty1 = field1.ty(tcx, args);
1152+
let ty2 = field2.ty(tcx, args);
1153+
1154+
if is_niche_optimization_candidate(tcx, param_env, ty1) {
1155+
ty2
1156+
} else if is_niche_optimization_candidate(tcx, param_env, ty2) {
1157+
ty1
1158+
} else {
1159+
return None;
1160+
}
1161+
}
11201162
_ => return None,
11211163
},
11221164
_ => return None,
@@ -1202,7 +1244,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
12021244
args: GenericArgsRef<'tcx>,
12031245
) -> FfiResult<'tcx> {
12041246
use FfiResult::*;
1205-
12061247
let transparent_with_all_zst_fields = if def.repr().transparent() {
12071248
if let Some(field) = transparent_newtype_field(self.cx.tcx, variant) {
12081249
// Transparent newtypes have at most one non-ZST field which needs to be checked..
@@ -1329,27 +1370,29 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
13291370
return FfiSafe;
13301371
}
13311372

1373+
if def.is_variant_list_non_exhaustive() && !def.did().is_local() {
1374+
return FfiUnsafe {
1375+
ty,
1376+
reason: fluent::lint_improper_ctypes_non_exhaustive,
1377+
help: None,
1378+
};
1379+
}
1380+
13321381
// Check for a repr() attribute to specify the size of the
13331382
// discriminant.
13341383
if !def.repr().c() && !def.repr().transparent() && def.repr().int.is_none()
13351384
{
1336-
// Special-case types like `Option<extern fn()>`.
1337-
if repr_nullable_ptr(self.cx.tcx, self.cx.param_env, ty, self.mode)
1338-
.is_none()
1385+
// Special-case types like `Option<extern fn()>` and `Result<extern fn(), ()>`
1386+
if let Some(ty) =
1387+
repr_nullable_ptr(self.cx.tcx, self.cx.param_env, ty, self.mode)
13391388
{
1340-
return FfiUnsafe {
1341-
ty,
1342-
reason: fluent::lint_improper_ctypes_enum_repr_reason,
1343-
help: Some(fluent::lint_improper_ctypes_enum_repr_help),
1344-
};
1389+
return self.check_type_for_ffi(cache, ty);
13451390
}
1346-
}
13471391

1348-
if def.is_variant_list_non_exhaustive() && !def.did().is_local() {
13491392
return FfiUnsafe {
13501393
ty,
1351-
reason: fluent::lint_improper_ctypes_non_exhaustive,
1352-
help: None,
1394+
reason: fluent::lint_improper_ctypes_enum_repr_reason,
1395+
help: Some(fluent::lint_improper_ctypes_enum_repr_help),
13531396
};
13541397
}
13551398

compiler/rustc_lint_defs/src/builtin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@ declare_lint! {
844844
/// ### Example
845845
///
846846
/// ```rust
847-
/// # #![feature(exclusive_range_pattern)]
848847
/// let x = 123u32;
849848
/// match x {
850849
/// 0..100 => { println!("small"); }

compiler/rustc_pattern_analysis/src/usefulness.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
//! This is enough to compute usefulness: a pattern in a `match` expression is redundant iff it is
4343
//! not useful w.r.t. the patterns above it:
4444
//! ```compile_fail,E0004
45-
//! # #![feature(exclusive_range_pattern)]
4645
//! # fn foo() {
4746
//! match Some(0u32) {
4847
//! Some(0..100) => {},

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ symbols! {
15111511
require,
15121512
residual,
15131513
result,
1514+
result_ffi_guarantees,
15141515
resume,
15151516
return_position_impl_trait_in_trait,
15161517
return_type_notation,

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
//
166166
// Language features:
167167
// tidy-alphabetical-start
168+
#![cfg_attr(bootstrap, feature(exclusive_range_pattern))]
168169
#![cfg_attr(not(test), feature(coroutine_trait))]
169170
#![cfg_attr(test, feature(panic_update_hook))]
170171
#![cfg_attr(test, feature(test))]
@@ -179,7 +180,6 @@
179180
#![feature(const_try)]
180181
#![feature(decl_macro)]
181182
#![feature(dropck_eyepatch)]
182-
#![feature(exclusive_range_pattern)]
183183
#![feature(fundamental)]
184184
#![feature(hashmap_internals)]
185185
#![feature(lang_items)]

0 commit comments

Comments
 (0)