Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dc97326
Update docs to show [expr; N] can repeat const expr
Coca162 Feb 27, 2023
22b65fc
Clarify that Copy is a trait in array docs
Coca162 Feb 27, 2023
48af38f
Bump rust-installer
Mark-Simulacrum Feb 27, 2023
8732fcd
Update books
rustbot Feb 27, 2023
f83ce99
Remove the `capture_disjoint_fields` feature
clubby789 Feb 28, 2023
ecac8fd
Descriptive error when users try to combine RPITIT/AFIT with speciali…
compiler-errors Feb 28, 2023
f851a8a
Only look for param in generics if it actually comes from generics
compiler-errors Feb 28, 2023
10b08e3
Fix a race in the query system
Zoxc Feb 8, 2023
f01d0c0
Exit when there are unmatched delims to avoid noisy diagnostics
chenyukang Feb 28, 2023
65ad5f8
remove duplicated diagnostic for unclosed delimiter
chenyukang Feb 28, 2023
9ce7472
rename unmatched_braces to unmatched_delims
chenyukang Feb 21, 2023
88de2e1
no need to return unmatched_delims from tokentrees
chenyukang Feb 22, 2023
f808877
refactor parse_token_trees to not return unmatched_delims
chenyukang Feb 22, 2023
229aef1
add missing feature in core/tests
RalfJung Feb 28, 2023
d33bbfd
Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petro…
matthiaskrgr Feb 28, 2023
62e6286
Rollup merge of #108531 - Coca162:rustdoc-repeat-const-array, r=thomcc
matthiaskrgr Feb 28, 2023
68b86f7
Rollup merge of #108534 - Mark-Simulacrum:compression, r=pietroalbini
matthiaskrgr Feb 28, 2023
70357cb
Rollup merge of #108536 - rustbot:docs-update, r=ehuss
matthiaskrgr Feb 28, 2023
5ed4614
Rollup merge of #108550 - clubby789:remove-disjoint, r=compiler-errors
matthiaskrgr Feb 28, 2023
a91bda5
Rollup merge of #108551 - compiler-errors:rpitit-bad-spec, r=oli-obk
matthiaskrgr Feb 28, 2023
38aa943
Rollup merge of #108554 - compiler-errors:late-bound-object-default, …
matthiaskrgr Feb 28, 2023
0beb3a1
Rollup merge of #108555 - Zoxc:par-fix, r=cjgillot
matthiaskrgr Feb 28, 2023
415258f
Rollup merge of #108558 - RalfJung:core-tests, r=thomcc
matthiaskrgr Feb 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove the capture_disjoint_fields feature
  • Loading branch information
clubby789 committed Feb 28, 2023
commit f83ce99c326ae13eabd5b4f6bd5459a5a764c13b
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ declare_features! (
(active, c_unwind, "1.52.0", Some(74990), None),
/// Allows using C-variadics.
(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.
(active, cfg_sanitize, "1.41.0", Some(39699), None),
/// Allows `cfg(target_abi = "...")`.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ declare_features! (
(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,
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.
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
Some("cannot be allowed in const eval in any meaningful way")),
Expand Down
15 changes: 6 additions & 9 deletions compiler/rustc_hir_typeck/src/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 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();

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

// If we have an origin, store it.
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)
} else {
(origin.0, Place { projections: vec![], ..origin.1 })
Expand Down Expand Up @@ -1240,8 +1240,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
///
/// This will make more sense with an example:
///
/// ```rust
/// #![feature(capture_disjoint_fields)]
/// ```rust,edition2021
///
/// struct FancyInteger(i32); // This implements Drop
///
Expand Down Expand Up @@ -2247,12 +2246,10 @@ fn truncate_capture_for_optimization(
(place, curr_mode)
}

/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
/// user is using Rust Edition 2021 or higher.
///
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
/// `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
// edition.
tcx.features().capture_disjoint_fields || span.rust_2021()
span.rust_2021()
}
11 changes: 5 additions & 6 deletions compiler/rustc_mir_build/src/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_middle::mir::AssertKind::BoundsCheck;
use rustc_middle::mir::*;
use rustc_middle::thir::*;
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_target::abi::VariantIdx;

Expand Down Expand Up @@ -183,7 +183,7 @@ fn to_upvars_resolved_place_builder<'tcx>(
&projection,
) else {
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!(
"No associated capture found for {:?}[{:#?}] even though \
capture_disjoint_fields isn't enabled",
Expand Down Expand Up @@ -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
/// user is using Rust Edition 2021 or higher.
fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
tcx.features().capture_disjoint_fields || closure_span.rust_2021()
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
fn enable_precise_capture(closure_span: Span) -> bool {
closure_span.rust_2021()
}
3 changes: 1 addition & 2 deletions tests/debuginfo/captured-fields-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// compile-flags:-g

// edition:2021
// === GDB TESTS ===================================================================================

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

#![feature(capture_disjoint_fields)]
#![allow(unused)]

struct MyStruct {
Expand Down
8 changes: 2 additions & 6 deletions tests/debuginfo/captured-fields-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// compile-flags:-g

// edition:2021
// === GDB TESTS ===================================================================================

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

#![feature(capture_disjoint_fields)]
#![allow(unused)]

struct MyStruct {
Expand All @@ -29,10 +28,7 @@ struct MyStruct {
}

fn main() {
let mut my_var = MyStruct {
my_field1: 11,
my_field2: 22,
};
let mut my_var = MyStruct { my_field1: 11, my_field2: 22 };
let my_ref = &mut my_var;

let test = || {
Expand Down
5 changes: 1 addition & 4 deletions tests/ui/closures/2229_closure_analysis/issue_88118.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Regression test for #88118. Used to ICE.
//
// edition:2021
// check-pass

#![allow(incomplete_features)]
#![feature(capture_disjoint_fields)]

fn foo<MsU>(handler: impl FnOnce() -> MsU + Clone + 'static) {
Box::new(move |value| {
(|_| handler.clone()())(value);
Expand Down