Remove the capture_disjoint_fields
feature
This commit is contained in:
parent
7281249a19
commit
f83ce99c32
7 changed files with 17 additions and 29 deletions
|
@ -317,8 +317,6 @@ declare_features! (
|
||||||
(active, c_unwind, "1.52.0", Some(74990), None),
|
(active, c_unwind, "1.52.0", Some(74990), None),
|
||||||
/// Allows using C-variadics.
|
/// Allows using C-variadics.
|
||||||
(active, c_variadic, "1.34.0", Some(44930), None),
|
(active, c_variadic, "1.34.0", Some(44930), None),
|
||||||
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
|
|
||||||
(incomplete, capture_disjoint_fields, "1.49.0", Some(53488), None),
|
|
||||||
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
|
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
|
||||||
(active, cfg_sanitize, "1.41.0", Some(39699), None),
|
(active, cfg_sanitize, "1.41.0", Some(39699), None),
|
||||||
/// Allows `cfg(target_abi = "...")`.
|
/// Allows `cfg(target_abi = "...")`.
|
||||||
|
|
|
@ -52,6 +52,8 @@ declare_features! (
|
||||||
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
|
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
|
||||||
(removed, await_macro, "1.38.0", Some(50547), None,
|
(removed, await_macro, "1.38.0", Some(50547), None,
|
||||||
Some("subsumed by `.await` syntax")),
|
Some("subsumed by `.await` syntax")),
|
||||||
|
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
|
||||||
|
(removed, capture_disjoint_fields, "1.49.0", Some(53488), None, Some("stabilized in Rust 2021")),
|
||||||
/// Allows comparing raw pointers during const eval.
|
/// Allows comparing raw pointers during const eval.
|
||||||
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
|
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
|
||||||
Some("cannot be allowed in const eval in any meaningful way")),
|
Some("cannot be allowed in const eval in any meaningful way")),
|
||||||
|
|
|
@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
// We now fake capture information for all variables that are mentioned within the closure
|
// We now fake capture information for all variables that are mentioned within the closure
|
||||||
// We do this after handling migrations so that min_captures computes before
|
// We do this after handling migrations so that min_captures computes before
|
||||||
if !enable_precise_capture(self.tcx, span) {
|
if !enable_precise_capture(span) {
|
||||||
let mut capture_information: InferredCaptureInformation<'tcx> = Default::default();
|
let mut capture_information: InferredCaptureInformation<'tcx> = Default::default();
|
||||||
|
|
||||||
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
|
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
|
||||||
|
@ -265,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
// If we have an origin, store it.
|
// If we have an origin, store it.
|
||||||
if let Some(origin) = origin {
|
if let Some(origin) = origin {
|
||||||
let origin = if enable_precise_capture(self.tcx, span) {
|
let origin = if enable_precise_capture(span) {
|
||||||
(origin.0, origin.1)
|
(origin.0, origin.1)
|
||||||
} else {
|
} else {
|
||||||
(origin.0, Place { projections: vec![], ..origin.1 })
|
(origin.0, Place { projections: vec![], ..origin.1 })
|
||||||
|
@ -1240,8 +1240,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
///
|
///
|
||||||
/// This will make more sense with an example:
|
/// This will make more sense with an example:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust,edition2021
|
||||||
/// #![feature(capture_disjoint_fields)]
|
|
||||||
///
|
///
|
||||||
/// struct FancyInteger(i32); // This implements Drop
|
/// struct FancyInteger(i32); // This implements Drop
|
||||||
///
|
///
|
||||||
|
@ -2247,12 +2246,10 @@ fn truncate_capture_for_optimization(
|
||||||
(place, curr_mode)
|
(place, curr_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
|
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
|
||||||
/// user is using Rust Edition 2021 or higher.
|
|
||||||
///
|
|
||||||
/// `span` is the span of the closure.
|
/// `span` is the span of the closure.
|
||||||
fn enable_precise_capture(tcx: TyCtxt<'_>, span: Span) -> bool {
|
fn enable_precise_capture(span: Span) -> bool {
|
||||||
// We use span here to ensure that if the closure was generated by a macro with a different
|
// We use span here to ensure that if the closure was generated by a macro with a different
|
||||||
// edition.
|
// edition.
|
||||||
tcx.features().capture_disjoint_fields || span.rust_2021()
|
span.rust_2021()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_middle::mir::AssertKind::BoundsCheck;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::thir::*;
|
use rustc_middle::thir::*;
|
||||||
use rustc_middle::ty::AdtDef;
|
use rustc_middle::ty::AdtDef;
|
||||||
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
|
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ fn to_upvars_resolved_place_builder<'tcx>(
|
||||||
&projection,
|
&projection,
|
||||||
) else {
|
) else {
|
||||||
let closure_span = cx.tcx.def_span(closure_def_id);
|
let closure_span = cx.tcx.def_span(closure_def_id);
|
||||||
if !enable_precise_capture(cx.tcx, closure_span) {
|
if !enable_precise_capture(closure_span) {
|
||||||
bug!(
|
bug!(
|
||||||
"No associated capture found for {:?}[{:#?}] even though \
|
"No associated capture found for {:?}[{:#?}] even though \
|
||||||
capture_disjoint_fields isn't enabled",
|
capture_disjoint_fields isn't enabled",
|
||||||
|
@ -745,8 +745,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
|
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
|
||||||
/// user is using Rust Edition 2021 or higher.
|
fn enable_precise_capture(closure_span: Span) -> bool {
|
||||||
fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
|
closure_span.rust_2021()
|
||||||
tcx.features().capture_disjoint_fields || closure_span.rust_2021()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// compile-flags:-g
|
// compile-flags:-g
|
||||||
|
// edition:2021
|
||||||
// === GDB TESTS ===================================================================================
|
// === GDB TESTS ===================================================================================
|
||||||
|
|
||||||
// gdb-command:run
|
// gdb-command:run
|
||||||
|
@ -44,7 +44,6 @@
|
||||||
// lldbg-check:(captured_fields_1::main::{closure_env#5}) $5 = { my_var = { my_field1 = 11 my_field2 = 22 } }
|
// lldbg-check:(captured_fields_1::main::{closure_env#5}) $5 = { my_var = { my_field1 = 11 my_field2 = 22 } }
|
||||||
// lldb-command:continue
|
// lldb-command:continue
|
||||||
|
|
||||||
#![feature(capture_disjoint_fields)]
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// compile-flags:-g
|
// compile-flags:-g
|
||||||
|
// edition:2021
|
||||||
// === GDB TESTS ===================================================================================
|
// === GDB TESTS ===================================================================================
|
||||||
|
|
||||||
// gdb-command:run
|
// gdb-command:run
|
||||||
|
@ -20,7 +20,6 @@
|
||||||
// lldbg-check:(unsigned int) $1 = 22
|
// lldbg-check:(unsigned int) $1 = 22
|
||||||
// lldb-command:continue
|
// lldb-command:continue
|
||||||
|
|
||||||
#![feature(capture_disjoint_fields)]
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
|
@ -29,10 +28,7 @@ struct MyStruct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut my_var = MyStruct {
|
let mut my_var = MyStruct { my_field1: 11, my_field2: 22 };
|
||||||
my_field1: 11,
|
|
||||||
my_field2: 22,
|
|
||||||
};
|
|
||||||
let my_ref = &mut my_var;
|
let my_ref = &mut my_var;
|
||||||
|
|
||||||
let test = || {
|
let test = || {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
// Regression test for #88118. Used to ICE.
|
// Regression test for #88118. Used to ICE.
|
||||||
//
|
// edition:2021
|
||||||
// check-pass
|
// check-pass
|
||||||
|
|
||||||
#![allow(incomplete_features)]
|
|
||||||
#![feature(capture_disjoint_fields)]
|
|
||||||
|
|
||||||
fn foo<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
|
fn foo<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
|
||||||
Box::new(move |value| {
|
Box::new(move |value| {
|
||||||
(|_| handler.clone()())(value);
|
(|_| handler.clone()())(value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue