diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 5ab99fbac866f..45e397a58c098 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -556,7 +556,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { gate_all!(fn_delegation, "functions delegation is not yet fully implemented"); gate_all!(postfix_match, "postfix match is experimental"); gate_all!(mut_ref, "mutable by-reference bindings are experimental"); - gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental"); gate_all!(global_registration, "global registration is experimental"); gate_all!(return_type_notation, "return type notation is experimental"); diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 7838abca9b890..a4a2028e26e5c 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -309,6 +309,8 @@ declare_features! ( (accepted, param_attrs, "1.39.0", Some(60406)), /// Allows parentheses in patterns. (accepted, pattern_parentheses, "1.31.0", Some(51087)), + /// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args. + (accepted, precise_capturing, "CURRENT_RUSTC_VERSION", Some(123432)), /// Allows procedural macros in `proc-macro` crates. (accepted, proc_macro, "1.29.0", Some(38356)), /// Allows multi-segment paths in attributes and derives. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 14e353f13ca49..a1741ac33ca5d 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -561,8 +561,6 @@ declare_features! ( (unstable, patchable_function_entry, "1.81.0", Some(123115)), /// Allows postfix match `expr.match { ... }` (unstable, postfix_match, "1.79.0", Some(121618)), - /// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args. - (unstable, precise_capturing, "1.79.0", Some(123432)), /// Allows macro attributes on expressions, statements and non-inline modules. (unstable, proc_macro_hygiene, "1.30.0", Some(54727)), /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024. diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 6c7125b75dbad..57c47d29857c3 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -2773,7 +2773,6 @@ impl PreciseCapturingArg<'_> { /// resolution to. Lifetimes don't have this problem, and for them, it's actually /// kind of detrimental to use a custom node type versus just using [`Lifetime`], /// since resolve_bound_vars operates on `Lifetime`s. -// FIXME(precise_capturing): Investigate storing this as a path instead? #[derive(Debug, Clone, Copy, HashStable_Generic)] pub struct PreciseCapturingNonLifetimeArg { pub hir_id: HirId, diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index e914169f4c373..990fb2d16f9dd 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -27,8 +27,6 @@ declare_lint! { /// ### Example /// /// ```rust,compile_fail - /// # #![feature(precise_capturing)] - /// # #![allow(incomplete_features)] /// # #![deny(impl_trait_overcaptures)] /// # use std::fmt::Display; /// let mut x = vec![]; @@ -56,7 +54,6 @@ declare_lint! { pub IMPL_TRAIT_OVERCAPTURES, Allow, "`impl Trait` will capture more lifetimes than possibly intended in edition 2024", - @feature_gate = precise_capturing; //@future_incompatible = FutureIncompatibleInfo { // reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024), // reference: "", @@ -75,8 +72,7 @@ declare_lint! { /// ### Example /// /// ```rust,compile_fail - /// # #![feature(precise_capturing, lifetime_capture_rules_2024)] - /// # #![allow(incomplete_features)] + /// # #![feature(lifetime_capture_rules_2024)] /// # #![deny(impl_trait_redundant_captures)] /// fn test<'a>(x: &'a i32) -> impl Sized + use<'a> { x } /// ``` @@ -90,7 +86,6 @@ declare_lint! { pub IMPL_TRAIT_REDUNDANT_CAPTURES, Warn, "redundant precise-capturing `use<...>` syntax on an `impl Trait`", - @feature_gate = precise_capturing; } declare_lint_pass!( diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index a8e8270673afb..52f0b1c1b04aa 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -851,7 +851,6 @@ impl<'a> Parser<'a> { // lifetimes and ident params (including SelfUpper). These are validated later // for order, duplication, and whether they actually reference params. let use_span = self.prev_token.span; - self.psess.gated_spans.gate(sym::precise_capturing, use_span); let (args, args_span) = self.parse_precise_capturing_args()?; GenericBound::Use(args, use_span.to(args_span)) } else { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 3cee8ff5f4c07..877a8a23d7f2b 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -17,8 +17,8 @@ use rustc_span::{BytePos, ErrorGuaranteed, Span, Symbol}; use rustc_type_ir::Upcast as _; use super::nice_region_error::find_anon_type; -use super::{nice_region_error, ObligationCauseAsDiagArg}; -use crate::error_reporting::infer::ObligationCauseExt as _; +use super::ObligationCauseAsDiagArg; +use crate::error_reporting::infer::ObligationCauseExt; use crate::error_reporting::TypeErrCtxt; use crate::errors::{ self, note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, @@ -1212,22 +1212,8 @@ pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>( hidden_region, "", ); - if let Some(reg_info) = tcx.is_suitable_region(generic_param_scope, hidden_region) { - if infcx.tcx.features().precise_capturing { - suggest_precise_capturing(tcx, opaque_ty_key.def_id, hidden_region, &mut err); - } else { - let fn_returns = tcx.return_type_impl_or_dyn_traits(reg_info.def_id); - nice_region_error::suggest_new_region_bound( - tcx, - &mut err, - fn_returns, - hidden_region.to_string(), - None, - format!("captures `{hidden_region}`"), - None, - Some(reg_info.def_id), - ) - } + if let Some(_) = tcx.is_suitable_region(generic_param_scope, hidden_region) { + suggest_precise_capturing(tcx, opaque_ty_key.def_id, hidden_region, &mut err); } } ty::RePlaceholder(_) => { diff --git a/tests/rustdoc-json/impl-trait-precise-capturing.rs b/tests/rustdoc-json/impl-trait-precise-capturing.rs index f9fee788ffe6e..0c116a1029019 100644 --- a/tests/rustdoc-json/impl-trait-precise-capturing.rs +++ b/tests/rustdoc-json/impl-trait-precise-capturing.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - //@ is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[0]" \"\'a\" //@ is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[1]" \"T\" //@ is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[2]" \"N\" diff --git a/tests/rustdoc/impl-trait-precise-capturing.rs b/tests/rustdoc/impl-trait-precise-capturing.rs index a964a1f8518f5..3ec8c5780139a 100644 --- a/tests/rustdoc/impl-trait-precise-capturing.rs +++ b/tests/rustdoc/impl-trait-precise-capturing.rs @@ -1,7 +1,6 @@ //@ aux-build:precise-capturing.rs #![crate_name = "foo"] -#![feature(precise_capturing)] extern crate precise_capturing; diff --git a/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr b/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr index 5ae1d78a92b78..167b5ee4425f8 100644 --- a/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr +++ b/tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr @@ -26,10 +26,10 @@ LL | | (a, b) LL | | } | |_^ | -help: to declare that `impl Trait<'a>` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { - | ++++ +LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + use<'a, 'b> { + | +++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr index 73de58649536a..1a32d1200571c 100644 --- a/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr +++ b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr @@ -7,6 +7,11 @@ LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static { | hidden type `impl Trait + 'static` captures the lifetime `'a` as defined here LL | bar(s) | ^^^^^^ + | +help: add a `use<...>` bound to explicitly capture `'a` + | +LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static + use<'a> { + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr index 7a9572d000d5a..24f3ed7cdf15e 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr @@ -30,10 +30,10 @@ LL | fn a(&self) -> impl Iterator { LL | self.0.iter_mut() | ^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn a(&self) -> impl Iterator + '_ { - | ++++ +LL | fn a(&self) -> impl Iterator + use<'_> { + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr b/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr index 173e3dc02cc89..d0b18df6a5e47 100644 --- a/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr +++ b/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr @@ -8,10 +8,10 @@ LL | fn foo(x: &Vec) -> impl Sized { LL | x | ^ | -help: to declare that `impl Sized` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn foo(x: &Vec) -> impl Sized + '_ { - | ++++ +LL | fn foo(x: &Vec) -> impl Sized + use<'_> { + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-precise-capturing.rs b/tests/ui/feature-gates/feature-gate-precise-capturing.rs deleted file mode 100644 index 47a21539d3779..0000000000000 --- a/tests/ui/feature-gates/feature-gate-precise-capturing.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn hello() -> impl Sized + use<> {} -//~^ ERROR precise captures on `impl Trait` are experimental - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-precise-capturing.stderr b/tests/ui/feature-gates/feature-gate-precise-capturing.stderr deleted file mode 100644 index 04365408880d7..0000000000000 --- a/tests/ui/feature-gates/feature-gate-precise-capturing.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: precise captures on `impl Trait` are experimental - --> $DIR/feature-gate-precise-capturing.rs:1:28 - | -LL | fn hello() -> impl Sized + use<> {} - | ^^^ - | - = note: see issue #123432 for more information - = help: add `#![feature(precise_capturing)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr index 825682c52f9f3..a2d00edbb6d95 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr @@ -8,10 +8,10 @@ LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a { LL | step1::<'a, 'b>() | ^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Sized + 'a` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + 'b { - | ++++ +LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + use<'a, 'b> { + | +++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr index b87e31acc1253..a1e92e5338469 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr @@ -8,10 +8,10 @@ LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl Swap + 'a { LL | x | ^ | -help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl Swap + 'a + 'b { - | ++++ +LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl Swap + 'a + use<'a, 'b, T> { + | ++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/call_method_ambiguous.next.stderr b/tests/ui/impl-trait/call_method_ambiguous.next.stderr index a1f9a8b40a899..5251555f57421 100644 --- a/tests/ui/impl-trait/call_method_ambiguous.next.stderr +++ b/tests/ui/impl-trait/call_method_ambiguous.next.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/call_method_ambiguous.rs:28:13 + --> $DIR/call_method_ambiguous.rs:26:13 | LL | let mut iter = foo(n - 1, m); | ^^^^^^^^ diff --git a/tests/ui/impl-trait/call_method_ambiguous.rs b/tests/ui/impl-trait/call_method_ambiguous.rs index 4dac605d6b812..8fd6f727b73f6 100644 --- a/tests/ui/impl-trait/call_method_ambiguous.rs +++ b/tests/ui/impl-trait/call_method_ambiguous.rs @@ -2,8 +2,6 @@ //@[next] compile-flags: -Znext-solver //@[current] run-pass -#![feature(precise_capturing)] - trait Get { fn get(&mut self) -> u32; } diff --git a/tests/ui/impl-trait/hidden-lifetimes.stderr b/tests/ui/impl-trait/hidden-lifetimes.stderr index bc8f559fdee9e..70d8c816ecb44 100644 --- a/tests/ui/impl-trait/hidden-lifetimes.stderr +++ b/tests/ui/impl-trait/hidden-lifetimes.stderr @@ -8,10 +8,10 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { LL | x | ^ | -help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b { - | ++++ +LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + use<'a, 'b, T> { + | ++++++++++++++++ error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds --> $DIR/hidden-lifetimes.rs:46:5 @@ -23,10 +23,10 @@ LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl S LL | x | ^ | -help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl Swap + 'a + 'b { - | ++++ +LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc>) -> impl Swap + 'a + use<'a, 'b, T> { + | ++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs index d7b62436d2d34..e00214fe8e06b 100644 --- a/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs +++ b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - use std::future::Future; use std::pin::Pin; diff --git a/tests/ui/impl-trait/in-trait/cannot-capture-intersection.stderr b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.stderr index 92ef66c55043c..a8f5bfc94c1cd 100644 --- a/tests/ui/impl-trait/in-trait/cannot-capture-intersection.stderr +++ b/tests/ui/impl-trait/in-trait/cannot-capture-intersection.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Future` captures lifetime that does not appear in bounds - --> $DIR/cannot-capture-intersection.rs:24:9 + --> $DIR/cannot-capture-intersection.rs:22:9 | LL | fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future { | ------------------------- opaque type defined here diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 273f51ddbe35c..f620bf6dc389c 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -7,10 +7,10 @@ LL | fn elided(x: &i32) -> impl Copy { x } | | opaque type defined here | hidden type `&i32` captures the anonymous lifetime defined here | -help: to declare that `impl Copy` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn elided(x: &i32) -> impl Copy + '_ { x } - | ++++ +LL | fn elided(x: &i32) -> impl Copy + use<'_> { x } + | +++++++++ error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds --> $DIR/must_outlive_least_region_or_bound.rs:6:44 @@ -21,10 +21,10 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | | opaque type defined here | hidden type `&'a i32` captures the lifetime `'a` as defined here | -help: to declare that `impl Copy` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } - | ++++ +LL | fn explicit<'a>(x: &'a i32) -> impl Copy + use<'a> { x } + | +++++++++ error: lifetime may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:9:46 @@ -108,10 +108,10 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Fn(&'a u32)` captures `'b`, you can add an explicit `'b` lifetime bound +help: add a `use<...>` bound to explicitly capture `'b` | -LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) + 'b { - | ++++ +LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) + use<'a, 'b> { + | +++++++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:47:5 diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index f1e3b97be0283..407800eff1894 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -8,14 +8,10 @@ LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future` captures `'s`, you can add an explicit `'s` lifetime bound +help: add a `use<...>` bound to explicitly capture `'s` | -LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future + 's { - | ++++ -help: to declare that `impl Sized` captures `'s`, you can add an explicit `'s` lifetime bound - | -LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { - | ++++ +LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future + use<'s> { + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/precise-capturing/apit.rs b/tests/ui/impl-trait/precise-capturing/apit.rs index 64c15d6df96c8..447d8fdf2cd76 100644 --- a/tests/ui/impl-trait/precise-capturing/apit.rs +++ b/tests/ui/impl-trait/precise-capturing/apit.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn hello(_: impl Sized + use<>) {} //~^ ERROR `use<...>` precise capturing syntax not allowed in argument-position `impl Trait` diff --git a/tests/ui/impl-trait/precise-capturing/apit.stderr b/tests/ui/impl-trait/precise-capturing/apit.stderr index 1d6225a1ff8d2..7573e0838ab46 100644 --- a/tests/ui/impl-trait/precise-capturing/apit.stderr +++ b/tests/ui/impl-trait/precise-capturing/apit.stderr @@ -1,5 +1,5 @@ error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait` - --> $DIR/apit.rs:3:26 + --> $DIR/apit.rs:1:26 | LL | fn hello(_: impl Sized + use<>) {} | ^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs index d2d4570c570eb..161fe23c89995 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs +++ b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn no_elided_lt() -> impl Sized + use<'_> {} //~^ ERROR missing lifetime specifier //~| ERROR expected lifetime parameter in `use<...>` precise captures list, found `'_` diff --git a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr index 550996ab5e57c..a8acecf10c7b2 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr +++ b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/bad-lifetimes.rs:3:39 + --> $DIR/bad-lifetimes.rs:1:39 | LL | fn no_elided_lt() -> impl Sized + use<'_> {} | ^^ expected named lifetime parameter @@ -11,7 +11,7 @@ LL | fn no_elided_lt() -> impl Sized + use<'static> {} | ~~~~~~~ error[E0261]: use of undeclared lifetime name `'missing` - --> $DIR/bad-lifetimes.rs:10:37 + --> $DIR/bad-lifetimes.rs:8:37 | LL | fn missing_lt() -> impl Sized + use<'missing> {} | - ^^^^^^^^ undeclared lifetime @@ -19,13 +19,13 @@ LL | fn missing_lt() -> impl Sized + use<'missing> {} | help: consider introducing lifetime `'missing` here: `<'missing>` error: expected lifetime parameter in `use<...>` precise captures list, found `'_` - --> $DIR/bad-lifetimes.rs:3:39 + --> $DIR/bad-lifetimes.rs:1:39 | LL | fn no_elided_lt() -> impl Sized + use<'_> {} | ^^ error: expected lifetime parameter in `use<...>` precise captures list, found `'static` - --> $DIR/bad-lifetimes.rs:7:36 + --> $DIR/bad-lifetimes.rs:5:36 | LL | fn static_lt() -> impl Sized + use<'static> {} | ^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/bad-params.rs b/tests/ui/impl-trait/precise-capturing/bad-params.rs index 08eee67c0e579..17b517abd74e4 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-params.rs +++ b/tests/ui/impl-trait/precise-capturing/bad-params.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn missing() -> impl Sized + use {} //~^ ERROR cannot find type `T` in this scope diff --git a/tests/ui/impl-trait/precise-capturing/bad-params.stderr b/tests/ui/impl-trait/precise-capturing/bad-params.stderr index e104f115aa3f2..06ccf35694811 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-params.stderr +++ b/tests/ui/impl-trait/precise-capturing/bad-params.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `T` in this scope - --> $DIR/bad-params.rs:3:34 + --> $DIR/bad-params.rs:1:34 | LL | fn missing() -> impl Sized + use {} | ^ not found in this scope @@ -10,7 +10,7 @@ LL | fn missing() -> impl Sized + use {} | +++ error[E0411]: cannot find type `Self` in this scope - --> $DIR/bad-params.rs:6:39 + --> $DIR/bad-params.rs:4:39 | LL | fn missing_self() -> impl Sized + use {} | ------------ ^^^^ `Self` is only available in impls, traits, and type definitions @@ -18,7 +18,7 @@ LL | fn missing_self() -> impl Sized + use {} | `Self` not allowed in a function error: `Self` can't be captured in `use<...>` precise captures list, since it is an alias - --> $DIR/bad-params.rs:11:48 + --> $DIR/bad-params.rs:9:48 | LL | impl MyType { | ----------- `Self` is not a generic argument, but an alias to the type of the implementation @@ -26,7 +26,7 @@ LL | fn self_is_not_param() -> impl Sized + use {} | ^^^^ error: expected type or const parameter in `use<...>` precise captures list, found function - --> $DIR/bad-params.rs:15:32 + --> $DIR/bad-params.rs:13:32 | LL | fn hello() -> impl Sized + use {} | ^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/bound-modifiers.rs b/tests/ui/impl-trait/precise-capturing/bound-modifiers.rs index 15f2188262869..4769581466898 100644 --- a/tests/ui/impl-trait/precise-capturing/bound-modifiers.rs +++ b/tests/ui/impl-trait/precise-capturing/bound-modifiers.rs @@ -1,7 +1,5 @@ //@ edition: 2021 -#![feature(precise_capturing)] - fn polarity() -> impl Sized + ?use<> {} //~^ ERROR expected identifier, found keyword `use` //~| ERROR cannot find trait `r#use` in this scope diff --git a/tests/ui/impl-trait/precise-capturing/bound-modifiers.stderr b/tests/ui/impl-trait/precise-capturing/bound-modifiers.stderr index 4602225e7b922..aaebfe2a86e55 100644 --- a/tests/ui/impl-trait/precise-capturing/bound-modifiers.stderr +++ b/tests/ui/impl-trait/precise-capturing/bound-modifiers.stderr @@ -1,53 +1,53 @@ error: expected identifier, found keyword `use` - --> $DIR/bound-modifiers.rs:5:32 + --> $DIR/bound-modifiers.rs:3:32 | LL | fn polarity() -> impl Sized + ?use<> {} | ^^^ expected identifier, found keyword error: expected identifier, found keyword `use` - --> $DIR/bound-modifiers.rs:11:38 + --> $DIR/bound-modifiers.rs:9:38 | LL | fn asyncness() -> impl Sized + async use<> {} | ^^^ expected identifier, found keyword error: expected identifier, found keyword `use` - --> $DIR/bound-modifiers.rs:16:38 + --> $DIR/bound-modifiers.rs:14:38 | LL | fn constness() -> impl Sized + const use<> {} | ^^^ expected identifier, found keyword error: expected identifier, found keyword `use` - --> $DIR/bound-modifiers.rs:21:37 + --> $DIR/bound-modifiers.rs:19:37 | LL | fn binder() -> impl Sized + for<'a> use<> {} | ^^^ expected identifier, found keyword error[E0405]: cannot find trait `r#use` in this scope - --> $DIR/bound-modifiers.rs:5:32 + --> $DIR/bound-modifiers.rs:3:32 | LL | fn polarity() -> impl Sized + ?use<> {} | ^^^ not found in this scope error[E0405]: cannot find trait `r#use` in this scope - --> $DIR/bound-modifiers.rs:11:38 + --> $DIR/bound-modifiers.rs:9:38 | LL | fn asyncness() -> impl Sized + async use<> {} | ^^^ not found in this scope error[E0405]: cannot find trait `r#use` in this scope - --> $DIR/bound-modifiers.rs:16:38 + --> $DIR/bound-modifiers.rs:14:38 | LL | fn constness() -> impl Sized + const use<> {} | ^^^ not found in this scope error[E0405]: cannot find trait `r#use` in this scope - --> $DIR/bound-modifiers.rs:21:37 + --> $DIR/bound-modifiers.rs:19:37 | LL | fn binder() -> impl Sized + for<'a> use<> {} | ^^^ not found in this scope error[E0658]: async closures are unstable - --> $DIR/bound-modifiers.rs:11:32 + --> $DIR/bound-modifiers.rs:9:32 | LL | fn asyncness() -> impl Sized + async use<> {} | ^^^^^ @@ -58,7 +58,7 @@ LL | fn asyncness() -> impl Sized + async use<> {} = help: to use an async block, remove the `||`: `async {` error[E0658]: const trait impls are experimental - --> $DIR/bound-modifiers.rs:16:32 + --> $DIR/bound-modifiers.rs:14:32 | LL | fn constness() -> impl Sized + const use<> {} | ^^^^^ @@ -68,13 +68,13 @@ LL | fn constness() -> impl Sized + const use<> {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default - --> $DIR/bound-modifiers.rs:5:31 + --> $DIR/bound-modifiers.rs:3:31 | LL | fn polarity() -> impl Sized + ?use<> {} | ^^^^^^ warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default - --> $DIR/bound-modifiers.rs:5:31 + --> $DIR/bound-modifiers.rs:3:31 | LL | fn polarity() -> impl Sized + ?use<> {} | ^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/capture-parent-arg.rs b/tests/ui/impl-trait/precise-capturing/capture-parent-arg.rs index 82b953bfed4b4..c41f136b96f10 100644 --- a/tests/ui/impl-trait/precise-capturing/capture-parent-arg.rs +++ b/tests/ui/impl-trait/precise-capturing/capture-parent-arg.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - trait Tr { type Assoc; } diff --git a/tests/ui/impl-trait/precise-capturing/capture-parent-arg.stderr b/tests/ui/impl-trait/precise-capturing/capture-parent-arg.stderr index b521ee0a90237..f02b8d7c85087 100644 --- a/tests/ui/impl-trait/precise-capturing/capture-parent-arg.stderr +++ b/tests/ui/impl-trait/precise-capturing/capture-parent-arg.stderr @@ -1,5 +1,5 @@ error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/capture-parent-arg.rs:27:31 + --> $DIR/capture-parent-arg.rs:25:31 | LL | impl<'a> W<'a> { | -- this lifetime parameter is captured @@ -7,7 +7,7 @@ LL | fn bad1() -> impl Into< as Tr>::Assoc> + use<> {} | -------------^^------------------------ lifetime captured due to being mentioned in the bounds of the `impl Trait` error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/capture-parent-arg.rs:33:18 + --> $DIR/capture-parent-arg.rs:31:18 | LL | impl<'a> W<'a> { | -- this lifetime parameter is captured diff --git a/tests/ui/impl-trait/precise-capturing/duplicated-use.real.stderr b/tests/ui/impl-trait/precise-capturing/duplicated-use.real.stderr index d8edd672b48c6..95132c611e51b 100644 --- a/tests/ui/impl-trait/precise-capturing/duplicated-use.real.stderr +++ b/tests/ui/impl-trait/precise-capturing/duplicated-use.real.stderr @@ -1,5 +1,5 @@ error: duplicate `use<...>` precise capturing syntax - --> $DIR/duplicated-use.rs:7:32 + --> $DIR/duplicated-use.rs:5:32 | LL | fn hello<'a>() -> impl Sized + use<'a> + use<'a> {} | ^^^^^^^ ------- second `use<...>` here diff --git a/tests/ui/impl-trait/precise-capturing/duplicated-use.rs b/tests/ui/impl-trait/precise-capturing/duplicated-use.rs index bfbdcdbf311d3..b5632dc157766 100644 --- a/tests/ui/impl-trait/precise-capturing/duplicated-use.rs +++ b/tests/ui/impl-trait/precise-capturing/duplicated-use.rs @@ -1,8 +1,6 @@ //@ revisions: real pre_expansion //@[pre_expansion] check-pass -#![feature(precise_capturing)] - #[cfg(real)] fn hello<'a>() -> impl Sized + use<'a> + use<'a> {} //[real]~^ ERROR duplicate `use<...>` precise capturing syntax diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.rs b/tests/ui/impl-trait/precise-capturing/dyn-use.rs index ce7a0f3c7b211..fb2f83e2d21cf 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.rs +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.rs @@ -1,4 +1,2 @@ -#![feature(precise_capturing)] - fn dyn() -> &'static dyn use<> { &() } //~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr b/tests/ui/impl-trait/precise-capturing/dyn-use.stderr index 5519633de1f7b..d8903fc412910 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.stderr @@ -1,5 +1,5 @@ error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` - --> $DIR/dyn-use.rs:3:26 + --> $DIR/dyn-use.rs:1:26 | LL | fn dyn() -> &'static dyn use<> { &() } | ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` diff --git a/tests/ui/impl-trait/precise-capturing/elided.rs b/tests/ui/impl-trait/precise-capturing/elided.rs index 34d1ba620dce1..472bac9d722dd 100644 --- a/tests/ui/impl-trait/precise-capturing/elided.rs +++ b/tests/ui/impl-trait/precise-capturing/elided.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(precise_capturing)] - fn elided(x: &()) -> impl Sized + use<'_> { x } fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.rs b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.rs index 26d29e456eaa2..2bf2e5fef18f5 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.rs +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn constant() -> impl Sized + use<> {} //~^ ERROR `impl Trait` must mention all const parameters in scope diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.stderr b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.stderr index 989ed136d4c37..e8fab0a8ad6c9 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.stderr +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.stderr @@ -1,5 +1,5 @@ error: `impl Trait` must mention all const parameters in scope in `use<...>` - --> $DIR/forgot-to-capture-const.rs:3:34 + --> $DIR/forgot-to-capture-const.rs:1:34 | LL | fn constant() -> impl Sized + use<> {} | -------------- ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.rs b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.rs index f18dbca6c5efc..64bac0c8acaad 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.rs +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x } //~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr index 979c0ca6d7b6e..907ed00f8c049 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.stderr @@ -1,5 +1,5 @@ error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/forgot-to-capture-lifetime.rs:3:52 + --> $DIR/forgot-to-capture-lifetime.rs:1:52 | LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x } | -- -----------^^------------ @@ -8,7 +8,7 @@ LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x } | this lifetime parameter is captured error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/forgot-to-capture-lifetime.rs:6:62 + --> $DIR/forgot-to-capture-lifetime.rs:4:62 | LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<> { x } | -- ------------------ ^ diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs index 0028a45cbf3f2..9d68819f657db 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn type_param() -> impl Sized + use<> {} //~^ ERROR `impl Trait` must mention all type parameters in scope diff --git a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr index 89bd4df443106..d9be9d543e450 100644 --- a/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr +++ b/tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.stderr @@ -1,5 +1,5 @@ error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits - --> $DIR/forgot-to-capture-type.rs:7:30 + --> $DIR/forgot-to-capture-type.rs:5:30 | LL | fn bar() -> impl Sized + use<>; | ^^^^^ @@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized + use<>; = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope error: `impl Trait` must mention all type parameters in scope in `use<...>` - --> $DIR/forgot-to-capture-type.rs:3:23 + --> $DIR/forgot-to-capture-type.rs:1:23 | LL | fn type_param() -> impl Sized + use<> {} | - ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn type_param() -> impl Sized + use<> {} = note: currently, all type parameters are required to be mentioned in the precise captures list error: `impl Trait` must mention the `Self` type of the trait in `use<...>` - --> $DIR/forgot-to-capture-type.rs:7:17 + --> $DIR/forgot-to-capture-type.rs:5:17 | LL | trait Foo { | --------- `Self` type parameter is implicitly captured by this `impl Trait` diff --git a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs index b50780643f1cc..d34c613559611 100644 --- a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs +++ b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { //~^ HELP add `'a` to the `use<...>` bound x diff --git a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr index 1007a835894e1..b0c4cc2fea0e7 100644 --- a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr +++ b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:5:5 + --> $DIR/hidden-type-suggestion.rs:3:5 | LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { | -- -------------------- opaque type defined here @@ -15,7 +15,7 @@ LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b, 'a> { | ++++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:11:5 + --> $DIR/hidden-type-suggestion.rs:9:5 | LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use { | -- ------------------- opaque type defined here @@ -31,7 +31,7 @@ LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<'a, T> { | +++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:17:5 + --> $DIR/hidden-type-suggestion.rs:15:5 | LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<> { | -- ------------------ opaque type defined here @@ -47,7 +47,7 @@ LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<'a> { | ++ error[E0700]: hidden type for `impl Captures<'captured>` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:26:5 + --> $DIR/hidden-type-suggestion.rs:24:5 | LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> { | -- ------------------------ opaque type defined here @@ -63,7 +63,7 @@ LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captu | ++++++++++++++++++++++++++++++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:32:5 + --> $DIR/hidden-type-suggestion.rs:30:5 | LL | fn no_params_yet(_: impl Sized, y: &()) -> impl Sized { | --- ---------- opaque type defined here @@ -74,7 +74,7 @@ LL | y | ^ | note: you could use a `use<...>` bound to explicitly capture `'_`, but argument-position `impl Trait`s are not nameable - --> $DIR/hidden-type-suggestion.rs:30:21 + --> $DIR/hidden-type-suggestion.rs:28:21 | LL | fn no_params_yet(_: impl Sized, y: &()) -> impl Sized { | ^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | fn no_params_yet(_: T, y: &()) -> impl Sized + use<'_, T> { | ++++++++++ ~ ++++++++++++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:38:5 + --> $DIR/hidden-type-suggestion.rs:36:5 | LL | fn yes_params_yet<'a, T>(_: impl Sized, y: &'a ()) -> impl Sized { | -- ---------- opaque type defined here @@ -95,7 +95,7 @@ LL | y | ^ | note: you could use a `use<...>` bound to explicitly capture `'a`, but argument-position `impl Trait`s are not nameable - --> $DIR/hidden-type-suggestion.rs:36:29 + --> $DIR/hidden-type-suggestion.rs:34:29 | LL | fn yes_params_yet<'a, T>(_: impl Sized, y: &'a ()) -> impl Sized { | ^^^^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/higher-ranked.rs b/tests/ui/impl-trait/precise-capturing/higher-ranked.rs index 21ac19640bcdf..3dc8523e9635d 100644 --- a/tests/ui/impl-trait/precise-capturing/higher-ranked.rs +++ b/tests/ui/impl-trait/precise-capturing/higher-ranked.rs @@ -2,7 +2,7 @@ // Show how precise captures allow us to skip capturing a higher-ranked lifetime -#![feature(lifetime_capture_rules_2024, precise_capturing)] +#![feature(lifetime_capture_rules_2024)] trait Trait<'a> { type Item; diff --git a/tests/ui/impl-trait/precise-capturing/illegal-positions.real.stderr b/tests/ui/impl-trait/precise-capturing/illegal-positions.real.stderr index 2b234bcb6a50f..95eb49daf28d8 100644 --- a/tests/ui/impl-trait/precise-capturing/illegal-positions.real.stderr +++ b/tests/ui/impl-trait/precise-capturing/illegal-positions.real.stderr @@ -1,53 +1,53 @@ error: `use<...>` precise capturing syntax not allowed in supertrait bounds - --> $DIR/illegal-positions.rs:8:12 + --> $DIR/illegal-positions.rs:6:12 | LL | trait Foo: use<> { | ^^^^^ error: `use<...>` precise capturing syntax not allowed in bounds - --> $DIR/illegal-positions.rs:10:33 + --> $DIR/illegal-positions.rs:8:33 | LL | type Assoc: use<> where (): use<>; | ^^^^^ error: `use<...>` precise capturing syntax not allowed in bounds - --> $DIR/illegal-positions.rs:10:17 + --> $DIR/illegal-positions.rs:8:17 | LL | type Assoc: use<> where (): use<>; | ^^^^^ error: `use<...>` precise capturing syntax not allowed in bounds - --> $DIR/illegal-positions.rs:16:11 + --> $DIR/illegal-positions.rs:14:11 | LL | fn fun>(_: impl use<>) where (): use<> {} | ^^^^^ error: `use<...>` precise capturing syntax not allowed in bounds - --> $DIR/illegal-positions.rs:16:43 + --> $DIR/illegal-positions.rs:14:43 | LL | fn fun>(_: impl use<>) where (): use<> {} | ^^^^^ error: at least one trait must be specified - --> $DIR/illegal-positions.rs:16:21 + --> $DIR/illegal-positions.rs:14:21 | LL | fn fun>(_: impl use<>) where (): use<> {} | ^^^^^^^^^^ error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds - --> $DIR/illegal-positions.rs:23:25 + --> $DIR/illegal-positions.rs:21:25 | LL | fn dynamic() -> Box> {} | ^^^^^ error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait` - --> $DIR/illegal-positions.rs:16:26 + --> $DIR/illegal-positions.rs:14:26 | LL | fn fun>(_: impl use<>) where (): use<> {} | ^^^^^ error[E0224]: at least one trait is required for an object type - --> $DIR/illegal-positions.rs:23:21 + --> $DIR/illegal-positions.rs:21:21 | LL | fn dynamic() -> Box> {} | ^^^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/illegal-positions.rs b/tests/ui/impl-trait/precise-capturing/illegal-positions.rs index 681458e25f801..d446a50d92d3b 100644 --- a/tests/ui/impl-trait/precise-capturing/illegal-positions.rs +++ b/tests/ui/impl-trait/precise-capturing/illegal-positions.rs @@ -2,8 +2,6 @@ //@[pre_expansion] check-pass //@ edition: 2021 -#![feature(precise_capturing)] - #[cfg(real)] trait Foo: use<> { //[real]~^ ERROR `use<...>` precise capturing syntax not allowed diff --git a/tests/ui/impl-trait/precise-capturing/ordering.rs b/tests/ui/impl-trait/precise-capturing/ordering.rs index eb570a120cc46..20638e0a623ea 100644 --- a/tests/ui/impl-trait/precise-capturing/ordering.rs +++ b/tests/ui/impl-trait/precise-capturing/ordering.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - fn lt<'a>() -> impl Sized + use<'a, 'a> {} //~^ ERROR cannot capture parameter `'a` twice diff --git a/tests/ui/impl-trait/precise-capturing/ordering.stderr b/tests/ui/impl-trait/precise-capturing/ordering.stderr index ecd47159059b4..05dec2d5c5ac9 100644 --- a/tests/ui/impl-trait/precise-capturing/ordering.stderr +++ b/tests/ui/impl-trait/precise-capturing/ordering.stderr @@ -1,23 +1,23 @@ error: cannot capture parameter `'a` twice - --> $DIR/ordering.rs:3:33 + --> $DIR/ordering.rs:1:33 | LL | fn lt<'a>() -> impl Sized + use<'a, 'a> {} | ^^ -- parameter captured again here error: cannot capture parameter `T` twice - --> $DIR/ordering.rs:6:32 + --> $DIR/ordering.rs:4:32 | LL | fn ty() -> impl Sized + use {} | ^ - parameter captured again here error: cannot capture parameter `N` twice - --> $DIR/ordering.rs:9:45 + --> $DIR/ordering.rs:7:45 | LL | fn ct() -> impl Sized + use {} | ^ - parameter captured again here error: lifetime parameter `'a` must be listed before non-lifetime parameters - --> $DIR/ordering.rs:12:45 + --> $DIR/ordering.rs:10:45 | LL | fn ordering<'a, T>() -> impl Sized + use {} | - ^^ diff --git a/tests/ui/impl-trait/precise-capturing/outlives.rs b/tests/ui/impl-trait/precise-capturing/outlives.rs index 26ac922b5b9d7..f86a61be1e078 100644 --- a/tests/ui/impl-trait/precise-capturing/outlives.rs +++ b/tests/ui/impl-trait/precise-capturing/outlives.rs @@ -2,7 +2,7 @@ // Show that precise captures allow us to skip a lifetime param for outlives -#![feature(lifetime_capture_rules_2024, precise_capturing)] +#![feature(lifetime_capture_rules_2024)] fn hello<'a: 'a, 'b: 'b>() -> impl Sized + use<'a> { } diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed index 5ac296a9cbdf0..6bca8ef12ecc3 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed @@ -1,7 +1,6 @@ //@ run-rustfix -#![feature(precise_capturing)] -#![allow(unused, incomplete_features)] +#![allow(unused)] #![deny(impl_trait_overcaptures)] fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x } diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs index e4b7828d60ffd..5b6726b49e025 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.rs @@ -1,7 +1,6 @@ //@ run-rustfix -#![feature(precise_capturing)] -#![allow(unused, incomplete_features)] +#![allow(unused)] #![deny(impl_trait_overcaptures)] fn named<'a>(x: &'a i32) -> impl Sized { *x } diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr index f8bb7f099af9e..fec640aa83aa9 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr @@ -1,17 +1,17 @@ error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 - --> $DIR/overcaptures-2024.rs:7:29 + --> $DIR/overcaptures-2024.rs:6:29 | LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^^^^^^^^^ | note: specifically, this lifetime is in scope but not mentioned in the type's bounds - --> $DIR/overcaptures-2024.rs:7:10 + --> $DIR/overcaptures-2024.rs:6:10 | LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 note: the lint level is defined here - --> $DIR/overcaptures-2024.rs:5:9 + --> $DIR/overcaptures-2024.rs:4:9 | LL | #![deny(impl_trait_overcaptures)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,13 +21,13 @@ LL | fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x } | +++++++ error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 - --> $DIR/overcaptures-2024.rs:10:25 + --> $DIR/overcaptures-2024.rs:9:25 | LL | fn implicit(x: &i32) -> impl Sized { *x } | ^^^^^^^^^^ | note: specifically, this lifetime is in scope but not mentioned in the type's bounds - --> $DIR/overcaptures-2024.rs:10:16 + --> $DIR/overcaptures-2024.rs:9:16 | LL | fn implicit(x: &i32) -> impl Sized { *x } | ^ @@ -38,13 +38,13 @@ LL | fn implicit(x: &i32) -> impl Sized + use<> { *x } | +++++++ error: `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024 - --> $DIR/overcaptures-2024.rs:15:33 + --> $DIR/overcaptures-2024.rs:14:33 | LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ^^^^^^^^^^^^^^^ | note: specifically, this lifetime is in scope but not mentioned in the type's bounds - --> $DIR/overcaptures-2024.rs:15:24 + --> $DIR/overcaptures-2024.rs:14:24 | LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ^ @@ -55,13 +55,13 @@ LL | fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self } | +++++++++ error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 - --> $DIR/overcaptures-2024.rs:26:47 + --> $DIR/overcaptures-2024.rs:25:47 | LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ^^^^^^^^^^ | note: specifically, this lifetime is in scope but not mentioned in the type's bounds - --> $DIR/overcaptures-2024.rs:26:23 + --> $DIR/overcaptures-2024.rs:25:23 | LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ^^ diff --git a/tests/ui/impl-trait/precise-capturing/redundant.normal.stderr b/tests/ui/impl-trait/precise-capturing/redundant.normal.stderr index 44bc9f7daad8d..d1bcbaa33ae2b 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.normal.stderr +++ b/tests/ui/impl-trait/precise-capturing/redundant.normal.stderr @@ -1,5 +1,5 @@ warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant - --> $DIR/redundant.rs:7:19 + --> $DIR/redundant.rs:5:19 | LL | fn hello<'a>() -> impl Sized + use<'a> {} | ^^^^^^^^^^^^^------- @@ -9,7 +9,7 @@ LL | fn hello<'a>() -> impl Sized + use<'a> {} = note: `#[warn(impl_trait_redundant_captures)]` on by default warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant - --> $DIR/redundant.rs:12:27 + --> $DIR/redundant.rs:10:27 | LL | fn inherent(&self) -> impl Sized + use<'_> {} | ^^^^^^^^^^^^^------- diff --git a/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr b/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr index 9aa73353126cd..213888356e572 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr +++ b/tests/ui/impl-trait/precise-capturing/redundant.rpitit.stderr @@ -1,5 +1,5 @@ error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits - --> $DIR/redundant.rs:18:35 + --> $DIR/redundant.rs:16:35 | LL | fn in_trait() -> impl Sized + use<'a, Self>; | ^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn in_trait() -> impl Sized + use<'a, Self>; = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits - --> $DIR/redundant.rs:23:35 + --> $DIR/redundant.rs:21:35 | LL | fn in_trait() -> impl Sized + use<'a> {} | ^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/redundant.rs b/tests/ui/impl-trait/precise-capturing/redundant.rs index ef4f05bd7e458..4a08ffb61be03 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.rs +++ b/tests/ui/impl-trait/precise-capturing/redundant.rs @@ -2,8 +2,6 @@ //@ revisions: normal rpitit //@[normal] check-pass -#![feature(precise_capturing)] - fn hello<'a>() -> impl Sized + use<'a> {} //[normal]~^ WARN all possible in-scope parameters are already captured diff --git a/tests/ui/impl-trait/precise-capturing/rpitit.rs b/tests/ui/impl-trait/precise-capturing/rpitit.rs index 4eb053573e1f2..feeeb1461e827 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit.rs +++ b/tests/ui/impl-trait/precise-capturing/rpitit.rs @@ -5,8 +5,6 @@ // To fix this soundly, we need to make sure that all the trait header args // remain captured, since they affect trait selection. -#![feature(precise_capturing)] - trait Foo<'a> { fn hello() -> impl PartialEq + use; } diff --git a/tests/ui/impl-trait/precise-capturing/rpitit.stderr b/tests/ui/impl-trait/precise-capturing/rpitit.stderr index 45eceef2f494b..5a120df9f047a 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit.stderr +++ b/tests/ui/impl-trait/precise-capturing/rpitit.stderr @@ -1,5 +1,5 @@ error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits - --> $DIR/rpitit.rs:11:36 + --> $DIR/rpitit.rs:9:36 | LL | fn hello() -> impl PartialEq + use; | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | fn hello() -> impl PartialEq + use; = note: currently, return-position `impl Trait` in traits and trait implementations capture all lifetimes in scope error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list - --> $DIR/rpitit.rs:11:19 + --> $DIR/rpitit.rs:9:19 | LL | trait Foo<'a> { | -- this lifetime parameter is captured @@ -15,7 +15,7 @@ LL | fn hello() -> impl PartialEq + use; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait` error: lifetime may not live long enough - --> $DIR/rpitit.rs:15:5 + --> $DIR/rpitit.rs:13:5 | LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() { | -- -- lifetime `'b` defined here @@ -30,7 +30,7 @@ LL | | ); = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/rpitit.rs:15:5 + --> $DIR/rpitit.rs:13:5 | LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() { | -- -- lifetime `'b` defined here diff --git a/tests/ui/impl-trait/precise-capturing/self-capture.rs b/tests/ui/impl-trait/precise-capturing/self-capture.rs index 07bb417f9f7f1..a61a7f06edc1d 100644 --- a/tests/ui/impl-trait/precise-capturing/self-capture.rs +++ b/tests/ui/impl-trait/precise-capturing/self-capture.rs @@ -1,5 +1,3 @@ -#![feature(precise_capturing)] - trait Foo { fn bar<'a>() -> impl Sized + use; //~^ ERROR `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits diff --git a/tests/ui/impl-trait/precise-capturing/self-capture.stderr b/tests/ui/impl-trait/precise-capturing/self-capture.stderr index 351de86dd5fa6..c1974600f30c5 100644 --- a/tests/ui/impl-trait/precise-capturing/self-capture.stderr +++ b/tests/ui/impl-trait/precise-capturing/self-capture.stderr @@ -1,5 +1,5 @@ error: `use<...>` precise capturing syntax is currently not allowed in return-position `impl Trait` in traits - --> $DIR/self-capture.rs:4:34 + --> $DIR/self-capture.rs:2:34 | LL | fn bar<'a>() -> impl Sized + use; | ^^^^^^^^^ diff --git a/tests/ui/impl-trait/region-escape-via-bound.stderr b/tests/ui/impl-trait/region-escape-via-bound.stderr index 43f0eeeb55838..0518231cfe984 100644 --- a/tests/ui/impl-trait/region-escape-via-bound.stderr +++ b/tests/ui/impl-trait/region-escape-via-bound.stderr @@ -9,10 +9,10 @@ LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> LL | x | ^ | -help: to declare that `impl Trait<'y>` captures `'x`, you can add an explicit `'x` lifetime bound +help: add a `use<...>` bound to explicitly capture `'x` | -LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + 'x - | ++++ +LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + use<'y, 'x> + | +++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 4be244068d226..21e3187d01912 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -8,10 +8,10 @@ LL | fn iter_values_anon(&self) -> impl Iterator { LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn iter_values_anon(&self) -> impl Iterator + '_ { - | ++++ +LL | fn iter_values_anon(&self) -> impl Iterator + use<'_> { + | +++++++++ error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds --> $DIR/static-return-lifetime-infered.rs:11:9 @@ -23,10 +23,10 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator { LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn iter_values<'a>(&'a self) -> impl Iterator + 'a { - | ++++ +LL | fn iter_values<'a>(&'a self) -> impl Iterator + use<'a> { + | +++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/issue-105227.fixed b/tests/ui/lifetimes/issue-105227.fixed deleted file mode 100644 index ef64e1e654169..0000000000000 --- a/tests/ui/lifetimes/issue-105227.fixed +++ /dev/null @@ -1,26 +0,0 @@ -// Regression test for issue #105227. - -//@ run-rustfix -#![allow(warnings)] -fn chars0<'a>(v :(&'a str, &'a str)) -> impl Iterator + 'a { -//~^ HELP to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` - v.0.chars().chain(v.1.chars()) - //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bounds -} - -fn chars1<'a>(v0 : &'a str, v1 : &'a str) -> impl Iterator + 'a { -//~^ HELP to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` - v0.chars().chain(v1.chars()) - //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bound -} - -fn chars2<'b>(v0 : &'b str, v1 : &'b str, v2 : &'b str) -> -//~^ HELP to declare that `impl Iterator` captures `'_`, you can use the named lifetime parameter `'b` - (impl Iterator + 'b , &'b str) -{ - (v0.chars().chain(v1.chars()), v2) - //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bound -} - -fn main() { -} diff --git a/tests/ui/lifetimes/issue-105227.rs b/tests/ui/lifetimes/issue-105227.rs index f37765ffafa1b..8a0a49e8f0c48 100644 --- a/tests/ui/lifetimes/issue-105227.rs +++ b/tests/ui/lifetimes/issue-105227.rs @@ -1,23 +1,23 @@ // Regression test for issue #105227. -//@ run-rustfix -#![allow(warnings)] +// FIXME(precise_capturing): Add rustfix here after dealing w/ elided lifetimes + +#![allow(unused)] + fn chars0(v :(& str, &str)) -> impl Iterator { -//~^ HELP to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` + //~^ HELP add a `use<...>` bound v.0.chars().chain(v.1.chars()) //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bounds } fn chars1(v0 : & str, v1 : &str) -> impl Iterator { -//~^ HELP to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` + //~^ HELP add a `use<...>` bound v0.chars().chain(v1.chars()) //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bound } -fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> -//~^ HELP to declare that `impl Iterator` captures `'_`, you can use the named lifetime parameter `'b` - (impl Iterator, &'b str) -{ +fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> (impl Iterator, &'b str) { + //~^ HELP add a `use<...>` bound (v0.chars().chain(v1.chars()), v2) //~^ ERROR hidden type for `impl Iterator` captures lifetime that does not appear in bound } diff --git a/tests/ui/lifetimes/issue-105227.stderr b/tests/ui/lifetimes/issue-105227.stderr index b514db461b478..35c05f2885479 100644 --- a/tests/ui/lifetimes/issue-105227.stderr +++ b/tests/ui/lifetimes/issue-105227.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds - --> $DIR/issue-105227.rs:7:5 + --> $DIR/issue-105227.rs:9:5 | LL | fn chars0(v :(& str, &str)) -> impl Iterator { | ----- -------------------------- opaque type defined here @@ -9,13 +9,13 @@ LL | LL | v.0.chars().chain(v.1.chars()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn chars0<'a>(v :(&'a str, &'a str)) -> impl Iterator + 'a { - | ++++ ++ ++ ++++ +LL | fn chars0(v :(& str, &str)) -> impl Iterator + use<'_> { + | +++++++++ error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds - --> $DIR/issue-105227.rs:13:5 + --> $DIR/issue-105227.rs:15:5 | LL | fn chars1(v0 : & str, v1 : &str) -> impl Iterator { | ----- -------------------------- opaque type defined here @@ -25,29 +25,26 @@ LL | LL | v0.chars().chain(v1.chars()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'_`, you can introduce a named lifetime parameter `'a` +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn chars1<'a>(v0 : &'a str, v1 : &'a str) -> impl Iterator + 'a { - | ++++ ++ ++ ++++ +LL | fn chars1(v0 : & str, v1 : &str) -> impl Iterator + use<'_> { + | +++++++++ error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds --> $DIR/issue-105227.rs:21:5 | -LL | fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> - | ---- hidden type `std::iter::Chain, Chars<'_>>` captures the anonymous lifetime defined here +LL | fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> (impl Iterator, &'b str) { + | ---- -------------------------- opaque type defined here + | | + | hidden type `std::iter::Chain, Chars<'_>>` captures the anonymous lifetime defined here LL | -LL | (impl Iterator, &'b str) - | -------------------------- opaque type defined here -LL | { LL | (v0.chars().chain(v1.chars()), v2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl Iterator` captures `'_`, you can use the named lifetime parameter `'b` - | -LL ~ fn chars2<'b>(v0 : &'b str, v1 : &'b str, v2 : &'b str) -> -LL | -LL ~ (impl Iterator + 'b , &'b str) +help: add a `use<...>` bound to explicitly capture `'_` | +LL | fn chars2<'b>(v0 : &str, v1 : &'_ str, v2 : &'b str) -> (impl Iterator + use<'_>, &'b str) { + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/nll/issue-73159-rpit-static.stderr b/tests/ui/nll/issue-73159-rpit-static.stderr index 472db30fbeb10..7c564b84a566c 100644 --- a/tests/ui/nll/issue-73159-rpit-static.stderr +++ b/tests/ui/nll/issue-73159-rpit-static.stderr @@ -7,6 +7,11 @@ LL | fn make_it(&self) -> impl Iterator { | ------------------------ opaque type defined here LL | self.0.iter().copied() | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `use<...>` bound to explicitly capture `'a` + | +LL | fn make_it(&self) -> impl Iterator + use<'a> { + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr b/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr index cab75e630a7c8..911ddd3dc805a 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr +++ b/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr @@ -37,10 +37,10 @@ LL | fn test_ambiguous<'a, 'b, 'c>(s: &'a u8) -> impl Cap<'b> + Cap<'c> LL | s | ^ | -help: to declare that `impl Cap<'b> + Cap<'c>` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn test_ambiguous<'a, 'b, 'c>(s: &'a u8) -> impl Cap<'b> + Cap<'c> + 'a - | ++++ +LL | fn test_ambiguous<'a, 'b, 'c>(s: &'a u8) -> impl Cap<'b> + Cap<'c> + use<'b, 'c, 'a> + | +++++++++++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr b/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr index 483b5822b9d35..1a0611e715e19 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr +++ b/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr @@ -9,14 +9,10 @@ LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b>>` captures `'s`, you can add an explicit `'s` lifetime bound +help: add a `use<...>` bound to explicitly capture `'s` | -LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b>> + 's - | ++++ -help: to declare that `impl Cap<'a> + Cap<'b>` captures `'s`, you can add an explicit `'s` lifetime bound - | -LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b> + 's> - | ++++ +LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b>> + use<'a, 'b, 's> + | +++++++++++++++++ error[E0700]: hidden type for `impl Cap<'a> + Cap<'b>` captures lifetime that does not appear in bounds --> $DIR/nested-impl-trait-fail.rs:17:5 @@ -29,14 +25,10 @@ LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b>>` captures `'s`, you can add an explicit `'s` lifetime bound - | -LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b>> + 's - | ++++ -help: to declare that `impl Cap<'a> + Cap<'b>` captures `'s`, you can add an explicit `'s` lifetime bound +help: add a `use<...>` bound to explicitly capture `'s` | -LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b> + 's> - | ++++ +LL | fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator + Cap<'b> + use<'a, 'b, 's>> + | +++++++++++++++++ error[E0700]: hidden type for `impl IntoIterator + Cap<'b>>` captures lifetime that does not appear in bounds --> $DIR/nested-impl-trait-fail.rs:28:5 @@ -49,14 +41,10 @@ LL | ) -> impl IntoIterator + Cap<'b>> { LL | [a] | ^^^ | -help: to declare that `impl IntoIterator + Cap<'b>>` captures `'s`, you can add an explicit `'s` lifetime bound +help: add a `use<...>` bound to explicitly capture `'s` | -LL | ) -> impl IntoIterator + Cap<'b>> + 's { - | ++++ -help: to declare that `impl Cap<'a> + Cap<'b>` captures `'s`, you can add an explicit `'s` lifetime bound - | -LL | ) -> impl IntoIterator + Cap<'b> + 's> { - | ++++ +LL | ) -> impl IntoIterator + Cap<'b>> + use<'a, 'b, 's> { + | +++++++++++++++++ error[E0700]: hidden type for `impl Cap<'a> + Cap<'b>` captures lifetime that does not appear in bounds --> $DIR/nested-impl-trait-fail.rs:28:5 @@ -69,14 +57,10 @@ LL | ) -> impl IntoIterator + Cap<'b>> { LL | [a] | ^^^ | -help: to declare that `impl IntoIterator + Cap<'b>>` captures `'s`, you can add an explicit `'s` lifetime bound - | -LL | ) -> impl IntoIterator + Cap<'b>> + 's { - | ++++ -help: to declare that `impl Cap<'a> + Cap<'b>` captures `'s`, you can add an explicit `'s` lifetime bound +help: add a `use<...>` bound to explicitly capture `'s` | -LL | ) -> impl IntoIterator + Cap<'b> + 's> { - | ++++ +LL | ) -> impl IntoIterator + Cap<'b> + use<'a, 'b, 's>> { + | +++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr index 6f9b330316378..cdf394505a25b 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr @@ -25,10 +25,10 @@ LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { LL | <&mut i32 as Callable>::call(y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { - | ++++ +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<'a> { + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr index 6f9b330316378..cdf394505a25b 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr @@ -25,10 +25,10 @@ LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { LL | <&mut i32 as Callable>::call(y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { - | ++++ +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<'a> { + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr index 48569d1446dd4..3ceefbc40660c 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -8,10 +8,10 @@ LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { LL | x | ^ | -help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#2])` captures `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound +help: add a `use<...>` bound to explicitly capture `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` | -LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) { - | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + use<'a, ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)), T> { + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index e04ec8bb3bca4..216b705348899 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -7,10 +7,10 @@ LL | async fn f(self: Pin<&Self>) -> impl Clone { self } | | opaque type defined here | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here | -help: to declare that `impl Clone` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self } - | ++++ +LL | async fn f(self: Pin<&Self>) -> impl Clone + use<'_> { self } + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr index a2964881d58a7..7a2ce110a3897 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr @@ -7,10 +7,10 @@ LL | fn f(self: Pin<&Self>) -> impl Clone { self } | | opaque type defined here | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here | -help: to declare that `impl Clone` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self } - | ++++ +LL | fn f(self: Pin<&Self>) -> impl Clone + use<'_> { self } + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 64af17c830e2e..88a18e9d06da2 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -20,10 +20,10 @@ LL | | *dest = g.get(); LL | | } | |_____^ | -help: to declare that `impl FnOnce()` captures `'_`, you can add an explicit `'_` lifetime bound +help: add a `use<...>` bound to explicitly capture `'_` | -LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ - | ++++ +LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + use<'_, G, T> + | +++++++++++++++ error[E0311]: the parameter type `G` may not live long enough --> $DIR/missing-lifetimes-in-signature.rs:30:5 diff --git a/tests/ui/type-alias-impl-trait/different_args_considered_equal2.stderr b/tests/ui/type-alias-impl-trait/different_args_considered_equal2.stderr index 1104c2c498a5a..213272f5f3451 100644 --- a/tests/ui/type-alias-impl-trait/different_args_considered_equal2.stderr +++ b/tests/ui/type-alias-impl-trait/different_args_considered_equal2.stderr @@ -9,11 +9,6 @@ LL | fn get_one<'a>(a: *mut &'a str) -> impl IntoIterator> { ... LL | None::> | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: to declare that `impl IntoIterator>` captures `'a`, you can add an explicit `'a` lifetime bound - | -LL | fn get_one<'a>(a: *mut &'a str) -> impl IntoIterator> + 'a { - | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr index 9bffa94fda165..0bf9dccfad85e 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr @@ -8,10 +8,10 @@ LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { LL | <&'a mut i32 as Callable>::call(y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound +help: add a `use<...>` bound to explicitly capture `'a` | -LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { - | ++++ +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<'a> { + | +++++++++ error: aborting due to 1 previous error