Skip to content

Commit 78f9bb1

Browse files
authored
Rollup merge of #108550 - clubby789:remove-disjoint, r=compiler-errors
Remove the `capture_disjoint_fields` feature As best I can tell, this was stabilized for Edition 2021 in #88126 but the feature was never removed.
2 parents 5857666 + f83ce99 commit 78f9bb1

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ declare_features! (
316316
(active, c_unwind, "1.52.0", Some(74990), None),
317317
/// Allows using C-variadics.
318318
(active, c_variadic, "1.34.0", Some(44930), None),
319-
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
320-
(incomplete, capture_disjoint_fields, "1.49.0", Some(53488), None),
321319
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
322320
(active, cfg_sanitize, "1.41.0", Some(39699), None),
323321
/// Allows `cfg(target_abi = "...")`.

compiler/rustc_feature/src/removed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ declare_features! (
5252
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
5353
(removed, await_macro, "1.38.0", Some(50547), None,
5454
Some("subsumed by `.await` syntax")),
55+
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
56+
(removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")),
5557
/// Allows comparing raw pointers during const eval.
5658
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
5759
Some("cannot be allowed in const eval in any meaningful way")),

compiler/rustc_hir_typeck/src/upvar.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
231231

232232
// We now fake capture information for all variables that are mentioned within the closure
233233
// We do this after handling migrations so that min_captures computes before
234-
if !enable_precise_capture(self.tcx, span) {
234+
if !enable_precise_capture(span) {
235235
let mut capture_information: InferredCaptureInformation<'tcx> = Default::default();
236236

237237
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
@@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
265265

266266
// If we have an origin, store it.
267267
if let Some(origin) = origin {
268-
let origin = if enable_precise_capture(self.tcx, span) {
268+
let origin = if enable_precise_capture(span) {
269269
(origin.0, origin.1)
270270
} else {
271271
(origin.0, Place { projections: vec![], ..origin.1 })
@@ -1243,8 +1243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12431243
///
12441244
/// This will make more sense with an example:
12451245
///
1246-
/// ```rust
1247-
/// #![feature(capture_disjoint_fields)]
1246+
/// ```rust,edition2021
12481247
///
12491248
/// struct FancyInteger(i32); // This implements Drop
12501249
///
@@ -2250,12 +2249,10 @@ fn truncate_capture_for_optimization(
22502249
(place, curr_mode)
22512250
}
22522251

2253-
/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
2254-
/// user is using Rust Edition 2021 or higher.
2255-
///
2252+
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
22562253
/// `span` is the span of the closure.
2257-
fn enable_precise_capture(tcx: TyCtxt<'_>, span: Span) -> bool {
2254+
fn enable_precise_capture(span: Span) -> bool {
22582255
// We use span here to ensure that if the closure was generated by a macro with a different
22592256
// edition.
2260-
tcx.features().capture_disjoint_fields || span.rust_2021()
2257+
span.rust_2021()
22612258
}

compiler/rustc_mir_build/src/build/expr/as_place.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::mir::AssertKind::BoundsCheck;
1111
use rustc_middle::mir::*;
1212
use rustc_middle::thir::*;
1313
use rustc_middle::ty::AdtDef;
14-
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
14+
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance};
1515
use rustc_span::Span;
1616
use rustc_target::abi::VariantIdx;
1717

@@ -183,7 +183,7 @@ fn to_upvars_resolved_place_builder<'tcx>(
183183
&projection,
184184
) else {
185185
let closure_span = cx.tcx.def_span(closure_def_id);
186-
if !enable_precise_capture(cx.tcx, closure_span) {
186+
if !enable_precise_capture(closure_span) {
187187
bug!(
188188
"No associated capture found for {:?}[{:#?}] even though \
189189
capture_disjoint_fields isn't enabled",
@@ -745,8 +745,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
745745
}
746746
}
747747

748-
/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
749-
/// user is using Rust Edition 2021 or higher.
750-
fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
751-
tcx.features().capture_disjoint_fields || closure_span.rust_2021()
748+
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
749+
fn enable_precise_capture(closure_span: Span) -> bool {
750+
closure_span.rust_2021()
752751
}

tests/debuginfo/captured-fields-1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// compile-flags:-g
2-
2+
// edition:2021
33
// === GDB TESTS ===================================================================================
44

55
// gdb-command:run
@@ -44,7 +44,6 @@
4444
// lldbg-check:(captured_fields_1::main::{closure_env#5}) $5 = { my_var = { my_field1 = 11 my_field2 = 22 } }
4545
// lldb-command:continue
4646

47-
#![feature(capture_disjoint_fields)]
4847
#![allow(unused)]
4948

5049
struct MyStruct {

tests/debuginfo/captured-fields-2.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// compile-flags:-g
2-
2+
// edition:2021
33
// === GDB TESTS ===================================================================================
44

55
// gdb-command:run
@@ -20,7 +20,6 @@
2020
// lldbg-check:(unsigned int) $1 = 22
2121
// lldb-command:continue
2222

23-
#![feature(capture_disjoint_fields)]
2423
#![allow(unused)]
2524

2625
struct MyStruct {
@@ -29,10 +28,7 @@ struct MyStruct {
2928
}
3029

3130
fn main() {
32-
let mut my_var = MyStruct {
33-
my_field1: 11,
34-
my_field2: 22,
35-
};
31+
let mut my_var = MyStruct { my_field1: 11, my_field2: 22 };
3632
let my_ref = &mut my_var;
3733

3834
let test = || {

tests/ui/closures/2229_closure_analysis/issue_88118.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Regression test for #88118. Used to ICE.
2-
//
2+
// edition:2021
33
// check-pass
44

5-
#![allow(incomplete_features)]
6-
#![feature(capture_disjoint_fields)]
7-
85
fn foo<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
96
Box::new(move |value| {
107
(|_| handler.clone()())(value);

0 commit comments

Comments
 (0)