about summary refs log tree commit diff
path: root/tests/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2025-02-13Rollup merge of #136928 - lcnr:method-lookup-check-wf, r=compiler-errorsJubilee-21/+21
eagerly prove WF when resolving fully qualified paths fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/161. This hopefully shouldn't impact perf. I do think we need to deal with at least part of the fallout here, opening for vibes. r? ``@compiler-errors``
2025-02-14fallout :skull_emoji:lcnr-21/+21
2025-02-13adjust derive_errorlcnr-4/+18
2025-02-11Reject `impl Trait` bounds in various places where we unconditionally warned ↵Oli Scherer-0/+27
since 1.0
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-139/+211
``` 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-51/+19
2025-02-08Auto merge of #136713 - matthiaskrgr:rollup-sy6py39, r=matthiaskrgrbors-0/+37
Rollup of 7 pull requests Successful merges: - #135179 (Make sure to use `Receiver` trait when extracting object method candidate) - #136554 (Add `opt_alias_variances` and use it in outlives code) - #136556 ([AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes.) - #136589 (Enable "jump to def" feature on rustc docs) - #136615 (sys: net: Add UEFI stubs) - #136635 (Remove outdated `base_port` calculation in std net test) - #136682 (Move two windows process tests to tests/ui) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-07Rollup merge of #136554 - compiler-errors:opt-alias-variances, r=lcnrMatthias Krüger-0/+37
Add `opt_alias_variances` and use it in outlives code ...so to fix some subtle outlives bugs with precise capturing in traits, and eventually make it easier to compute variances for "forced unconstrained" trait lifetimes. r? lcnr
2025-02-06remove `feature(trait_upcasting)` from tests and bless themWaffle Lapkin-3/+1
2025-02-06Add opt_alias_variances and use it in outlives codeMichael Goulet-0/+37
2025-02-06Rollup merge of #136073 - compiler-errors:recursive-coro-always, r=oli-obkMatthias Krüger-5/+2
Always compute coroutine layout for eagerly emitting recursive layout errors Detect recursive coroutine layouts even if we don't detect opaque type recursion in the new solver. This is for two reasons: 1. It helps us detect (bad) recursive async function calls in the new solver, which due to its approach to normalization causes us to not detect this via a recursive RPIT (since the opaques are more eagerly revealed in the opaque body). * Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/137. 2. It helps us detect (bad) recursive async functions behind AFITs. See the AFIT test that changed for the old solver too. 3. It also greatly simplifies the recursive impl trait check, since I can remove some jankness around how it handles coroutines.
2025-02-05Rollup merge of #136550 - compiler-errors:rpitit-empty-body, r=oli-obkJubilee-0/+23
Fix `rustc_hidden_type_of_opaques` for RPITITs with no default body Needed this when debugging something
2025-02-05Eagerly detect coroutine recursion pre-mono when possibleMichael Goulet-5/+2
2025-02-04Fix rustc_hidden_type_of_opaques for RPITITs with no default bodyMichael Goulet-0/+23
2025-02-03Make error message less awkwardMichael Goulet-15/+15
2025-02-03Check Sizedness of return type in WFMichael Goulet-156/+186
2025-02-02Rollup merge of #136415 - estebank:highlight-clarification, r=compiler-errorsMatthias Krüger-4/+4
Highlight clarifying information in "expected/found" error When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful. ![Screenshot of the rustc highlighted output on the terminal](https://github.com/user-attachments/assets/aa4b9433-5332-4941-b2c2-1a43e5cadff7)
2025-02-02Highlight clarifying information in "expected/found" errorEsteban Küber-4/+4
When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful.
2025-02-01Rollup merge of #135900 - compiler-errors:derive-wf, r=lcnrMatthias Krüger-0/+5
Manually walk into WF obligations in `BestObligation` proof tree visitor When we encounter a `WellFormed` obligation in the `BestObligation` proof tree visitor, ignore the proof tree and call `wf::unnormalized_obligations` to derive well-formed obligations with the correct cause codes. This is to avoid having to replicate the somewhat delicate logic that `wf.rs` does to set up its obligation causes... Don't see a better way to do this. vibes?? r? lcnr
2025-01-31Auto merge of #136350 - matthiaskrgr:rollup-6eqfyvh, r=matthiaskrgrbors-12/+12
Rollup of 9 pull requests Successful merges: - #134531 ([rustdoc] Add `--extract-doctests` command-line flag) - #135860 (Compiler: Finalize dyn compatibility renaming) - #135992 (Improve documentation when adding a new target) - #136194 (Support clobber_abi in BPF inline assembly) - #136325 (Delay a bug when indexing unsized slices) - #136326 (Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`) - #136330 (Remove unnecessary hooks) - #136336 (Overhaul `rustc_middle::util`) - #136341 (Remove myself from vacation) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-31Manually walk into WF obligations in BestObligation proof tree visitorMichael Goulet-0/+5
2025-01-31Rollup merge of #135860 - fmease:compiler-mv-obj-save-dyn-compat-ii, r=jieyouxuMatthias Krüger-12/+12
Compiler: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #130826. Part of #130852. ~~Blocking it on #133372.~~ (merged) r? ghost
2025-01-30Filter out RPITITs when suggesting unconstrained assoc type on too many genericsMichael Goulet-0/+31
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-52/+0
2025-01-26Compiler: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-12/+12
2025-01-25Auto merge of #133154 - estebank:issue-133137, r=wesleywiserbors-7/+13
Reword resolve errors caused by likely missing crate in dep tree Reword label and add `help`: ``` error[E0432]: unresolved import `some_novel_crate` --> f704.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` | = help: if you wanted to use a crate named `some_novel_crate`, use `cargo add some_novel_crate` to add it to your `Cargo.toml` ``` Fix #133137.
2025-01-24Reword "crate not found" resolve messageEsteban Küber-7/+13
``` error[E0432]: unresolved import `some_novel_crate` --> file.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` ``` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From<nope::Thing> for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ```
2025-01-23Rollup merge of #135492 - metamuffin:bug-invalid-await-suggest, ↵Matthias Krüger-9/+0
r=compiler-errors Add missing check for async body when suggesting await on futures. Currently the compiler suggests adding `.await` to resolve some type conflicts without checking if the conflict happens in an async context. This can lead to the compiler suggesting `.await` in function signatures where it is invalid. Example: ```rs trait A { fn a() -> impl Future<Output = ()>; } struct B; impl A for B { fn a() -> impl Future<Output = impl Future<Output = ()>> { async { async { () } } } } ``` ``` error[E0271]: expected `impl Future<Output = impl Future<Output = ()>>` to be a future that resolves to `()`, but it resolves to `impl Future<Output = ()>` --> bug.rs:6:15 | 6 | fn a() -> impl Future<Output = impl Future<Output = ()>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found future | note: calling an async function returns a future --> bug.rs:6:15 | 6 | fn a() -> impl Future<Output = impl Future<Output = ()>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `A::{synthetic#0}` --> bug.rs:2:27 | 2 | fn a() -> impl Future<Output = ()>; | ^^^^^^^^^^^ required by this bound in `A::{synthetic#0}` help: consider `await`ing on the `Future` | 6 | fn a() -> impl Future<Output = impl Future<Output = ()>>.await { | ++++++ ``` The documentation of suggest_await_on_expect_found (`compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs:156`) even mentions such a check but does not actually implement it. This PR adds that check to ensure `.await` is only suggested within async blocks. There were 3 unit tests whose expected output needed to be changed because they had the suggestion outside of async. One of them (`tests/ui/async-await/dont-suggest-missing-await.rs`) actually tests that exact problem but expects it to be present. Thanks to `@llenck` for initially noticing the bug and helping with fixing it
2025-01-22Rollup merge of #135816 - BoxyUwU:root_normalizes_to_goal_ice, r=lcnrMatthias Krüger-5/+38
Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors r? `@lcnr` I added `structurally_normalize_term` so that code that is generic over ty or const can use the structurally normalize helpers. See `tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs` for a description of the reason for the (now fixed) ICEs
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-72/+92
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-22Use `structurally_normalize` instead of manual `normalizes-to` goalsBoxy-5/+38
2025-01-16Add missing check for async body when suggesting await on futures.metamuffin-9/+0
2025-01-15fix known-bug link in normalize-tait-in-constRalf Jung-4/+5
2025-01-13Rollup merge of #135441 - compiler-errors:redundant-captures-lint, r=lqdJacob Pratt-11/+15
Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024 I never got sign-off on #127672 for this lint being warn by default in edition 2024, so let's turn downgrade this lint to allow for now. Should be backported so it ships with the edition. ```@rustbot``` label: +beta-nominated
2025-01-13Make sure to mark IMPL_TRAIT_REDUNDANT_CAPTURES as Allow in edition 2024Michael Goulet-11/+15
2025-01-11Remove a bunch of diagnostic stashing that doesn't do anythingMichael Goulet-47/+60
2025-01-08Implement const Destruct in old solverMichael Goulet-17/+2
2025-01-06point out unblamed constraints from `Copy`/`Sized` bounds in region errorsdianne-0/+3
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.
2025-01-04Rollup merge of #135055 - compiler-errors:rpitit-infer-in-stricter-impl, ↵Matthias Krüger-38/+61
r=estebank Report impl method has stricter requirements even when RPITIT inference gets in the way See the comment I added in the code. Fixes #122506.
2025-01-03Do not project when there are unconstrained impl paramsMichael Goulet-27/+4
2025-01-03Report impl has stricter requirements even when RPITIT inference gets in the wayMichael Goulet-38/+61
2025-01-01Fix ICE when opaque captures a duplicated/invalid lifetimeMichael Goulet-0/+30
2024-12-27Rollup merge of #134798 - compiler-errors:err-auto, r=jackh726Matthias Krüger-0/+36
Make `ty::Error` implement all auto traits I have no idea what's up with the crashes test I fixed--I really don't want to look into it since it has to do something with borrowck and multiple layers of opaques. I think the underlying idea of allowing error types to implement all auto traits is justified though. Fixes #134796 Fixes #131050 r? lcnr
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-1/+1
2024-12-26Make ty::Error implement auto traitsMichael Goulet-0/+36
2024-12-16Regression test for RPIT inheriting lifetimeRyan Mehri-0/+24
2024-12-14Don't make a def id for impl_trait_in_bindingsMichael Goulet-0/+10
2024-12-14Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obkbors-0/+179
(Re-)Implement `impl_trait_in_bindings` This reimplements the `impl_trait_in_bindings` feature for local bindings. "`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference): ```rust let _: impl Fn(&u8) -> &u8 = |x| x; ``` They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes: ```rust trait Static: 'static {} impl<T> Static for T where T: 'static {} let local = 1; let x: impl Static = &local; //~^ ERROR `local` does not live long enough ``` r? oli-obk cc #63065 --- Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example: ```rust type TAIT = impl Display; let local = 0; let x: TAIT = &local; //~^ ERROR `local` does not live long enough ``` That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here. --- I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+179