Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit eb3707e

Browse files
Stabilize precise_capturing_in_traits
1 parent 97fc1f6 commit eb3707e

24 files changed

+22
-91
lines changed

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ ast_lowering_never_pattern_with_guard =
141141
142142
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
143143
144-
ast_lowering_no_precise_captures_on_rpitit = `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits
145-
.note = currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope
146-
147144
ast_lowering_previously_used_here = previously used here
148145
149146
ast_lowering_register1 = register `{$reg1_name}`

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,6 @@ pub(crate) struct NoPreciseCapturesOnApit {
444444
pub span: Span,
445445
}
446446

447-
#[derive(Diagnostic)]
448-
#[diag(ast_lowering_no_precise_captures_on_rpitit)]
449-
#[note]
450-
pub(crate) struct NoPreciseCapturesOnRpitit {
451-
#[primary_span]
452-
pub span: Span,
453-
}
454-
455447
#[derive(Diagnostic)]
456448
#[diag(ast_lowering_yield_in_closure)]
457449
pub(crate) struct YieldInClosure {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,28 +1438,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14381438
// frequently opened issues show.
14391439
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
14401440

1441-
// Feature gate for RPITIT + use<..>
1442-
match origin {
1443-
rustc_hir::OpaqueTyOrigin::FnReturn { in_trait_or_impl: Some(_), .. } => {
1444-
if !self.tcx.features().precise_capturing_in_traits()
1445-
&& let Some(span) = bounds.iter().find_map(|bound| match *bound {
1446-
ast::GenericBound::Use(_, span) => Some(span),
1447-
_ => None,
1448-
})
1449-
{
1450-
let mut diag =
1451-
self.tcx.dcx().create_err(errors::NoPreciseCapturesOnRpitit { span });
1452-
add_feature_diagnostics(
1453-
&mut diag,
1454-
self.tcx.sess,
1455-
sym::precise_capturing_in_traits,
1456-
);
1457-
diag.emit();
1458-
}
1459-
}
1460-
_ => {}
1461-
}
1462-
14631441
self.lower_opaque_inner(opaque_ty_node_id, origin, opaque_ty_span, |this| {
14641442
this.lower_param_bounds(bounds, itctx)
14651443
})

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ declare_features! (
331331
(accepted, pattern_parentheses, "1.31.0", Some(51087)),
332332
/// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args.
333333
(accepted, precise_capturing, "1.82.0", Some(123432)),
334+
/// Allows `use<..>` precise capturign on impl Trait in traits.
335+
(accepted, precise_capturing_in_traits, "CURRENT_RUSTC_VERSION", Some(130044)),
334336
/// Allows procedural macros in `proc-macro` crates.
335337
(accepted, proc_macro, "1.29.0", Some(38356)),
336338
/// Allows multi-segment paths in attributes and derives.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,6 @@ declare_features! (
600600
(incomplete, pin_ergonomics, "1.83.0", Some(130494)),
601601
/// Allows postfix match `expr.match { ... }`
602602
(unstable, postfix_match, "1.79.0", Some(121618)),
603-
/// Allows `use<..>` precise capturign on impl Trait in traits.
604-
(unstable, precise_capturing_in_traits, "1.83.0", Some(130044)),
605603
/// Allows macro attributes on expressions, statements and non-inline modules.
606604
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
607605
/// Allows the use of raw-dylibs on ELF platforms

tests/ui/feature-gates/feature-gate-precise_capturing_in_traits.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-precise_capturing_in_traits.stderr

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/impl-trait/in-trait/dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ compile-flags: -Zverbose-internals
22

3-
#![feature(precise_capturing_in_traits, rustc_attrs)]
3+
#![feature(rustc_attrs)]
44
#![rustc_hidden_type_of_opaques]
55

66
trait Foo {

tests/ui/impl-trait/in-trait/refine-captures.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(precise_capturing_in_traits)]
2-
31
trait LifetimeParam<'a> {
42
fn test() -> impl Sized;
53
}

tests/ui/impl-trait/in-trait/refine-captures.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: impl trait in impl method captures fewer lifetimes than in trait
2-
--> $DIR/refine-captures.rs:8:31
2+
--> $DIR/refine-captures.rs:6:31
33
|
44
LL | fn test() -> impl Sized + use<> {}
55
| ^^^^^
@@ -13,7 +13,7 @@ LL | fn test() -> impl Sized + use<'a> {}
1313
| ++
1414

1515
warning: impl trait in impl method captures fewer lifetimes than in trait
16-
--> $DIR/refine-captures.rs:22:31
16+
--> $DIR/refine-captures.rs:20:31
1717
|
1818
LL | fn test() -> impl Sized + use<> {}
1919
| ^^^^^
@@ -26,7 +26,7 @@ LL | fn test() -> impl Sized + use<'a> {}
2626
| ++
2727

2828
warning: impl trait in impl method captures fewer lifetimes than in trait
29-
--> $DIR/refine-captures.rs:27:31
29+
--> $DIR/refine-captures.rs:25:31
3030
|
3131
LL | fn test() -> impl Sized + use<'b> {}
3232
| ^^^^^^^
@@ -39,7 +39,7 @@ LL | fn test() -> impl Sized + use<'a, 'b> {}
3939
| ++++
4040

4141
error: `impl Trait` must mention all type parameters in scope in `use<...>`
42-
--> $DIR/refine-captures.rs:32:18
42+
--> $DIR/refine-captures.rs:30:18
4343
|
4444
LL | impl<T> TypeParam<T> for u64 {
4545
| - type parameter is implicitly captured by this `impl Trait`

0 commit comments

Comments
 (0)