summary refs log tree commit diff
path: root/tests/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2024-08-26Rollup merge of #129600 - ↵Matthias Krüger-6/+22
traviscross:TC/tie-impl_trait_overcaptures-to-rust-2024, r=compiler-errors Tie `impl_trait_overcaptures` lint to Rust 2024 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. Tracking: - https://github.com/rust-lang/rust/issues/117587 r? `@compiler-errors`
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-24Rollup merge of #129429 - cjgillot:named-variance, r=compiler-errorsTrevor Gross-34/+36
Print the generic parameter along with the variance in dumps. This allows to make sure we are testing what we think we are testing. While the tests are correct, I discovered that opaque duplicated args are in the reverse declaration order.
2024-08-23Print the generic parameter along with the variance in dumps.Camille GILLOT-34/+36
2024-08-22Don't trigger refinement lint if predicates reference errorsMichael Goulet-19/+24
2024-08-17Bless test falloutMichael Goulet-50/+42
2024-08-17Stabilize opaque type precise capturingMichael Goulet-103/+67
2024-08-13Use the right type when coercing fn items to pointersMichael Goulet-2/+2
2024-08-10Differentiate between methods and associated functionsEsteban Küber-2/+2
Accurately refer to assoc fn without receiver as assoc fn instead of methods. Add `AssocItem::descr` method to centralize where we call methods and associated functions.
2024-08-06Don't arbitrarily choose one upper bound for hidden captured regionMichael Goulet-14/+46
2024-08-05Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=compiler-errorsMatthias Krüger-0/+22
turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps` `````@rust-lang/types````` I assume the plan is still to disallow this? It has been a future-compat lint for a long time, seems ripe to go for hard error. However, turns out that outright removing it right now would lead to [tons of crater regressions](https://github.com/rust-lang/rust/pull/127655#issuecomment-2228285460), so for now this PR just makes this future-compat lint show up in cargo's reports, so people are warned when they use a dependency that is affected by this. Fixes https://github.com/rust-lang/rust/issues/27336 by removing the feature gate (so there's no way to silence the lint even on nightly) CC https://github.com/rust-lang/rust/issues/36887
2024-08-03Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"Michael Goulet-8/+4
This reverts commit 31fe9628cf830a08e7194a446f66c668aaea86e9, reversing changes made to f20307851ead9fbbb9fa88bbffb3258a069230a6.
2024-07-25Rollup merge of #127054 - compiler-errors:bound-ordering, r=fmeaseMatthias Krüger-5/+5
Reorder trait bound modifiers *after* `for<...>` binder in trait bounds This PR suggests changing the grammar of trait bounds from: ``` [CONSTNESS] [ASYNCNESS] [?] [BINDER] [TRAIT_PATH] const async ? for<'a> Sized ``` to ``` ([BINDER] [CONSTNESS] [ASYNCNESS] | [?]) [TRAIT_PATH] ``` i.e., either ``` ? Sized ``` or ``` for<'a> const async Sized ``` (but not both) ### Why? I think it's strange that the binder applies "more tightly" than the `?` trait polarity. This becomes even weirder when considering that we (or at least, I) want to have `async` trait bounds expressed like: ``` where T: for<'a> async Fn(&'a ()) -> i32, ``` and not: ``` where T: async for<'a> Fn(&'a ()) -> i32, ``` ### Fallout No crates on crater use this syntax, presumably because it's literally useless. This will require modifying the reference grammar, though. ### Alternatives If this is not desirable, then we can alternatively keep parsing `for<'a>` after the `?` but deprecate it with either an FCW (or an immediate hard error), and begin parsing `for<'a>` *before* the `?`.
2024-07-24Rollup merge of #122192 - oli-obk:type_of_opaque_for_const_checks, r=lcnrMatthias Krüger-62/+162
Do not try to reveal hidden types when trying to prove auto-traits in the defining scope fixes #99793 this avoids the cycle error by just causing a selection error, which is not fatal. We pessimistically assume that freeze does not hold, which is always a safe assumption.
2024-07-24Do not assemble candidates for auto traits of opaque types in their defining ↵Oli Scherer-43/+63
scope
2024-07-24Add regression testsOli Scherer-0/+88
2024-07-24Do not try to reveal hidden types when trying to prove Freeze in the ↵Oli Scherer-64/+7
defining scope
2024-07-24Add regression testOli Scherer-0/+49
2024-07-22Revert suggestion verbosity changeEsteban Küber-24/+12
2024-07-22On generic and lifetime removal suggestion, do not leave behind stray `,`Esteban Küber-1/+1
2024-07-22Change suggestion message wordingEsteban Küber-4/+4
2024-07-22Use verbose suggestion for "wrong # of generics"Esteban Küber-12/+24
2024-07-21Auto merge of #127722 - BoxyUwU:new_adt_const_params_limitations, ↵bors-2/+2
r=compiler-errors Forbid borrows and unsized types from being used as the type of a const generic under `adt_const_params` Fixes #112219 Fixes #112124 Fixes #112125 ### Motivation Currently the `adt_const_params` feature allows writing `Foo<const N: [u8]>` this is entirely useless as it is not possible to write an expression which evaluates to a type that is not `Sized`. In order to actually use unsized types in const generics they are typically written as `const N: &[u8]` which *is* possible to provide a value of. Unfortunately allowing the types of const parameters to contain references is non trivial (#120961) as it introduces a number of difficult questions about how equality of references in the type system should behave. References in the types of const generics is largely only useful for using unsized types in const generics. This PR introduces a new feature gate `unsized_const_parameters` and moves support for `const N: [u8]` and `const N: &...` from `adt_const_params` into it. The goal here hopefully is to experiment with allowing `const N: [u8]` to work without references and then eventually completely forbid references in const generics. Splitting this out into a new feature gate means that stabilization of `adt_const_params` does not have to resolve #120961 which is the only remaining "big" blocker for the feature. Remaining issues after this are a few ICEs and naming bikeshed for `ConstParamTy`. ### Implementation The implementation is slightly subtle here as we would like to ensure that a stabilization of `adt_const_params` is forwards compatible with any outcome of `unsized_const_parameters`. This is inherently tricky as we do not support unstable trait implementations and we determine whether a type is valid as the type of a const parameter via a trait bound. There are a few constraints here: - We would like to *allow for the possibility* of adding a `Sized` supertrait to `ConstParamTy` in the event that we wind up opting to not support unsized types and instead requiring people to write the 'sized version', e.g. `const N: [u8; M]` instead of `const N: [u8]`. - Crates should be able to enable `unsized_const_parameters` and write trait implementations of `ConstParamTy` for `!Sized` types without downstream crates that only enable `adt_const_params` being able to observe this (required for std to be able to `impl<T> ConstParamTy for [T]` Ultimately the way this is accomplished is via having two traits (sad), `ConstParamTy` and `UnsizedConstParamTy`. Depending on whether `unsized_const_parameters` is enabled or not we change which trait is used to check whether a type is allowed to be a const parameter. Long term (when stabilizing `UnsizedConstParamTy`) it should be possible to completely merge these traits (and derive macros), only having a single `trait ConstParamTy` and `macro ConstParamTy`. Under `adt_const_params` it is now illegal to directly refer to `ConstParamTy` it is only used as an internal impl detail by `derive(ConstParamTy)` and checking const parameters are well formed. This is necessary in order to ensure forwards compatibility with all possible future directions for `feature(unsized_const_parameters)`. Generally the intuition here should be that `ConstParamTy` is the stable trait that everything uses, and `UnsizedConstParamTy` is that plus unstable implementations (well, I suppose `ConstParamTy` isn't stable yet :P).
2024-07-19More accurate suggestion for `-> Box<dyn Trait>` or `-> impl Trait`Esteban Küber-35/+21
When encountering `-> Trait`, suggest `-> Box<dyn Trait>` (instead of `-> Box<Trait>`. If there's a single returned type within the `fn`, suggest `-> impl Trait`.
2024-07-17Rollup merge of #127664 - ↵Trevor Gross-1/+55
compiler-errors:precise-capturing-better-sugg-apit, r=oli-obk Fix precise capturing suggestion for hidden regions when we have APITs Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API. This is currently done via a note *and* a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation. Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy. Based on #127619, only the last commit is relevant. r? oli-obk Tracking: - https://github.com/rust-lang/rust/issues/123432
2024-07-17Fix precise capturing suggestion for hidden type when APITs are involvedMichael Goulet-1/+55
2024-07-17Remove invalid further restricting for type boundyukang-4/+0
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-2/+2
2024-07-15make invalid_type_param_default lint show up in cargo future-compat reportsRalf Jung-0/+22
and remove the feature gate that silenced the lint
2024-07-15Rollup merge of #127407 - estebank:parser-suggestions, r=oli-obkMatthias Krüger-12/+72
Make parse error suggestions verbose and fix spans Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-12Rollup merge of #127619 - compiler-errors:precise-capturing-better-sugg, ↵Jubilee-3/+100
r=oli-obk Suggest using precise capturing for hidden type that captures region Adjusts the "add `+ '_`" suggestion for opaques to instead suggest adding or reusing the `+ use<>` in the opaque. r? oli-obk or please re-roll if you're busy!
2024-07-12Make `impl` and `!` removal suggestion `short`Esteban Küber-12/+2
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-14/+84
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-07-11Suggest using precise capturing for hidden type that captures regionMichael Goulet-3/+100
2024-07-11Auto merge of #127311 - oli-obk:do_not_count_errors, r=compiler-errorsbors-12/+2
Avoid follow-up errors and ICEs after missing lifetime errors on data structures Tuple struct constructors are functions, so when we call them typeck will use the signature tuple struct constructor function to provide type hints. Since typeck mostly ignores and erases lifetimes, we end up never seeing the error lifetime in writeback, thus not tainting the typeck result. Now, we eagerly taint typeck results by tainting from `resolve_vars_if_possible`, which is called all over the place. I did not carry over all the `crashes` test suite tests, as they are really all the same cause (missing or unknown lifetime names in tuple struct definitions or generic arg lists). fixes #124262 fixes #124083 fixes #125155 fixes #125888 fixes #125992 fixes #126666 fixes #126648 fixes #127268 fixes #127266 fixes #127304
2024-07-11Avoid follow-up errors and ICEs after missing lifetime errors on data structuresOli Scherer-12/+2
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-1/+1
2024-07-10Improve error messageMichael Goulet-6/+39
2024-07-10Reorder modifiers and polarity to be *after* binder in trait boundsMichael Goulet-37/+4
2024-07-07Auto merge of #127172 - compiler-errors:full-can_eq-everywhere, r=lcnrbors-4/+4
Make `can_eq` process obligations (almost) everywhere Move `can_eq` to an extension trait on `InferCtxt` in `rustc_trait_selection`, and change it so that it processes obligations. This should strengthen it to be more accurate in some cases, but is most important for the new trait solver which delays relating aliases to `AliasRelate` goals. Without this, we always basically just return true when passing aliases to `can_eq`, which can lead to weird errors, for example #127149. I'm not actually certain if we should *have* `can_eq` be called on the good path. In cases where we need `can_eq`, we probably should just be using a regular probe. Fixes #127149 r? lcnr
2024-07-07Auto merge of #127404 - compiler-errors:rpitit-entailment-false-positive, ↵bors-0/+224
r=oli-obk Don't try to label `ObligationCauseCode::CompareImplItem` for an RPITIT, since it has no name The old (current) trait solver has a limitation that when a where clause in param-env must be normalized using the same where clause, then we get spurious errors in `normalize_param_env_or_error`. I don't think there's an issue tracking it, but it's the root cause for many of the "fixed-by-next-solver" labeled issues. Specifically, these errors may occur when checking predicate entailment of the GAT that comes out of desugaring RPITITs. Since we use `ObligationCauseCode::CompareImplItem` for these predicates, we try calling `item_name` on an RPITIT which fails, since the RPITIT has no name. We simply suppress this logic when we're reporting a predicate entailment error for an RPITIT. RPITITs should never have predicate entailment errors, *by construction*, but they may due to this bug in the old solver. Addresses the ICE in #127331, though doesn't fix the underlying issue (which is fundamental to the old solver). r? types
2024-07-06Don't try to label ObligationCauseCode::CompareImplItem for an RPITIT, since ↵Michael Goulet-0/+224
it has no name
2024-07-06show fnsig's output when there is differenceyukang-1/+1
2024-07-06show unit output when there is only output diff in diagnosticsyukang-1/+1
2024-07-05Rollup merge of #127392 - estebank:arg-type, r=jieyouxuJubilee-44/+57
Use verbose suggestion for changing arg type
2024-07-05Rollup merge of #127383 - estebank:arg-removal, r=compiler-errorsJubilee-8/+12
Use verbose style for argument removal suggestion
2024-07-05Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelixMichael Goulet-4/+8
Improve dead code analysis Fixes #120770 1. check impl items later if self ty is private although the trait method is public, cause we must use the ty firstly if it's private 2. mark the adt live if it appears in pattern, like generic argument, this implies the use of the adt 3. based on the above, we can handle the case that private adts impl Default, so that we don't need adding rustc_trivial_field_reads on Default, and the logic in should_ignore_item r? ``@pnkfelix``
2024-07-05Use verbose suggestion for changing arg typeEsteban Küber-44/+57
2024-07-05Use verbose style for argument removal suggestionEsteban Küber-8/+12
2024-07-05Actually just make can_eq process obligations (almost) everywhereMichael Goulet-4/+4