about summary refs log tree commit diff
path: root/tests/ui/impl-trait/precise-capturing
AgeCommit message (Collapse)AuthorLines
2025-09-28reword noteEsteban Küber-4/+4
2025-09-28Point at lifetime requirement origin in more casesEsteban Küber-4/+4
2025-09-28Point at fn bound that introduced lifetime obligationEsteban Küber-22/+34
``` error[E0597]: `c` does not live long enough --> $DIR/without-precise-captures-we-are-powerless.rs:19:20 | LL | fn simple<'a>(x: &'a i32) { | -- lifetime `'a` defined here ... LL | let c = async move || { println!("{}", *x); }; | - binding `c` declared here LL | outlives::<'a>(c()); | ---------------^--- | | | | | borrowed value does not live long enough | argument requires that `c` is borrowed for `'a` LL | outlives::<'a>(call_once(c)); LL | } | - `c` dropped here while still borrowed | note: requirement that `c` is borrowed for `'a` introduced here --> $DIR/without-precise-captures-we-are-powerless.rs:7:33 | LL | fn outlives<'a>(_: impl Sized + 'a) {} | ^^ ``` When encountering a `ConstraintCategory::Predicate` in a funtion call, point at the `Span` for that `Predicate` to explain where the lifetime obligation originates from.
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-0/+1
2025-08-16Properly recover from parenthesized use-bounds (precise capturing)León Orell Valerian Liehr-0/+22
2025-07-16future-incompat lints: don't link to the nightly edition-guide versiondianne-9/+9
2025-07-13update issue number for `const_trait_impl`Deadbeef-1/+1
2025-06-26Auto merge of #143057 - matthiaskrgr:rollup-bulih8o, r=matthiaskrgrbors-3/+6
Rollup of 8 pull requests Successful merges: - rust-lang/rust#124595 (Suggest cloning `Arc` moved into closure) - rust-lang/rust#139594 (Simplify `ObligationCauseCode::IfExpression`) - rust-lang/rust#141311 (make `tidy-alphabetical` use a natural sort) - rust-lang/rust#141648 ([rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion) - rust-lang/rust#142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats) - rust-lang/rust#142393 (Don't give APITs names with macro expansion placeholder fragments in it) - rust-lang/rust#142884 (StableMIR: Add method to retrieve body of coroutine) - rust-lang/rust#142981 (Make missing lifetime suggestion verbose) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-25Add edition checks for some tests that had divergent outputEsteban Küber-16/+104
In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while looking at something else.
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-3/+6
2025-06-18Bless/update tests.Mara Bos-6/+6
2025-03-23Stabilize precise_capturing_in_traitsMichael Goulet-29/+14
2025-03-03Do not recover missing lifetime with random in-scope lifetimeMichael Goulet-10/+3
2025-02-22Rollup merge of #136787 - compiler-errors:lt2024feat, r=oli-obkMatthias Krüger-4/+2
Remove `lifetime_capture_rules_2024` feature Just use edition 2024 instead
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-12/+18
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-09Remove lifetime_capture_rules_2024 featureMichael Goulet-4/+2
2025-02-06Add opt_alias_variances and use it in outlives codeMichael Goulet-0/+37
2025-01-13Make sure to mark IMPL_TRAIT_REDUNDANT_CAPTURES as Allow in edition 2024Michael Goulet-11/+15
2025-01-06`best_blame_constraint`: don't filter constraints by sup SCCdianne-10/+10
The SCCs of the region graph are not a reliable heuristic to use for blaming an interesting constraint for diagnostics. For region errors, if the outlived region is `'static`, or the involved types are invariant in their lifetiems, there will be cycles in the constraint graph containing both the target region and the most interesting constraints to blame. To get better diagnostics in these cases, this commit removes that heuristic.
2024-12-10Rudimentary heuristic to insert parentheses when needed for RPIT ↵Michael Goulet-1/+28
overcaptures lint
2024-12-02Gate async fn trait bound modifier on async_trait_boundsMichael Goulet-4/+4
2024-11-28Auto merge of #133540 - ehuss:compiletest-proc-macro, r=jieyouxubors-6/+1
Compiletest: add proc-macro header This adds a `proc-macro` header to simplify using proc-macros, and to reduce boilerplate. This header works similar to the `aux-build` header where you pass a path for a proc-macro to be built. This allows the `force-host`, `no-prefer-dynamic` headers, and `crate_type` attribute to be removed. Additionally it uses `--extern` like `aux_crate` (allows implicit `extern crate` in 2018) and `--extern proc_macro` (to place in the prelude in 2018). ~~This also includes a secondary change which defaults the edition of proc-macros to 2024. This further reduces boilerplate (removing `extern crate proc_macro;`), and allows using modern Rust syntax. I was a little on the fence including this. I personally prefer it, but I can imagine it might be confusing to others.~~ EDIT: Removed Some tests were changed so that when there is a chain of dependencies A→B→C, that the `@ proc-macro` is placed in `B` instead of `A` so that the `--extern` flag works correctly (previously it depended on `-L` to find `C`). I think this is better to make the dependencies more explicit. None of these tests looked like the were actually testing this behavior. There is one test that had an unexplained output change: `tests/ui/macros/same-sequence-span.rs`. I do not know why it changed, but it didn't look like it was particularly important. Perhaps there was a normalization issue? This is currently not compatible with the rustdoc `build-aux-docs` header. It can probably be fixed, I'm just not feeling motivated to do that right now. ### Implementation steps - [x] Document this new behavior in rustc-dev-guide once we figure out the specifics. https://github.com/rust-lang/rustc-dev-guide/pull/2149
2024-11-27Update tests to use new proc-macro headerEric Huss-6/+1
2024-11-24Actually use placeholder regions for trait method late bound regions in ↵Michael Goulet-3/+4
collect_return_position_impl_trait_in_trait_tys
2024-11-22Stabilize the 2024 editionEric Huss-35/+31
2024-11-15Rollup merge of #133080 - ehuss:edition-desugar-span, r=compiler-errorsGuillaume Gomez-0/+75
Fix span edition for 2024 RPIT coming from an external macro This fixes a problem where code generated by an external macro with an RPIT would end up using the call-site edition instead of the macro's edition for the RPIT. When used from a 2024 crate, this caused the code to change behavior to the 2024 capturing rules, which we don't want. This was caused by the impl-trait lowering code would replace the span with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it was also overriding the edition of the span with the edition of the local crate. Instead it should be using the edition of the span itself. Fixes https://github.com/rust-lang/rust/issues/132917
2024-11-15Fix span edition for 2024 RPIT coming from an external macroEric Huss-93/+1
This fixes a problem where code generated by an external macro with an RPIT would end up using the call-site edition instead of the macro's edition for the RPIT. When used from a 2024 crate, this caused the code to change behavior to the 2024 capturing rules, which we don't want. This was caused by the impl-trait lowering code would replace the span with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it was also overriding the edition of the span with the edition of the local crate. Instead it should be using the edition of the span itself. Fixes https://github.com/rust-lang/rust/issues/132917
2024-11-15Rollup merge of #132817 - compiler-errors:impl-trait-overcaptures-apit, ↵Matthias Krüger-16/+45
r=BoxyUwU Recurse into APITs in `impl_trait_overcaptures` We were previously not detecting cases where an RPIT was located in the return type of an async function, leading to underfiring of the `impl_trait_overcaptures`. This PR does this recursion properly now. cc https://github.com/rust-lang/rust/issues/132809
2024-11-15Add test for precise-capturing from an external macroEric Huss-0/+167
2024-11-12Make precise capturing suggestion machine-applicable only if it has not APITsMichael Goulet-0/+52
2024-11-11Recurse into APITs in impl_trait_overcapturesMichael Goulet-16/+45
2024-11-09Dont suggest use<APIT>Michael Goulet-12/+61
2024-11-09Suggest turning APITs into generics in opaque overcapturesMichael Goulet-1/+65
2024-10-31Rollup merge of #132209 - compiler-errors:modifiers, r=fmeaseJubilee-25/+9
Fix validation when lowering `?` trait bounds Pass the unlowered (`rustc_hir`) polarity to `lower_poly_trait_ref`. This allows us to actually *validate* that generic args are actually valid on `?Trait` paths. This actually regressed in #113671 because that PR changed the behavior where we were inadvertently re-lowering paths as `BoundPolarity::Positive`, which was also coincidentally the only place we were enforcing the generics on `?Trait` paths were correct.
2024-10-31Try to point out when edition 2024 lifetime capture rules cause borrowck issuesMichael Goulet-0/+521
2024-10-30Actually do validation for poly trait refs with ? modifierMichael Goulet-25/+9
2024-10-19Make sure that outer opaques capture inner opaques's lifetimes even with ↵Michael Goulet-0/+37
precise capturing syntax
2024-10-10Clarify implicit captures for RPITITMichael Goulet-2/+2
2024-10-10Add variances to RPITITsMichael Goulet-141/+141
2024-10-10Add gate for precise capturing in traitsMichael Goulet-0/+18
2024-10-10Move ty::Error branch into super_combine_tysMichael Goulet-19/+1
2024-09-16Auto merge of #130439 - matthiaskrgr:rollup-1lkzo74, r=matthiaskrgrbors-0/+58
Rollup of 4 pull requests Successful merges: - #123436 (linker: Allow MSVC to use import libraries following the Meson/MinGW convention) - #130410 (Don't ICE when generating `Fn` shim for async closure with borrowck error) - #130412 (Don't ICE when RPITIT captures more method args than trait definition) - #130436 (Ignore reduce-fadd-unordered on SGX platform) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-16Don't ICE when RPITIT captures more method args than trait definitionMichael Goulet-0/+58
2024-09-16Introduce distinct error codes for precise capturingMichael Goulet-5/+5
2024-09-16Do precise capturing arg validation in resolveMichael Goulet-13/+22
2024-09-05Don't worry about uncaptured contravariant lifetimes if they outlive a ↵Michael Goulet-0/+15
captured lifetime
2024-08-26Tie `impl_trait_overcaptures` lint to Rust 2024Travis Cross-6/+22
The `impl_trait_overcaptures` lint is part of the migration to Rust 2024 and the Lifetime Capture Rules 2024. Now that we've stabilized precise capturing (RFC 3617), let's tie this lint to the `rust_2024_compatibility` lint group.
2024-08-17Bless test falloutMichael Goulet-10/+8
2024-08-17Stabilize opaque type precise capturingMichael Goulet-100/+66
2024-07-17Fix precise capturing suggestion for hidden type when APITs are involvedMichael Goulet-1/+55