about summary refs log tree commit diff
path: root/tests/ui/traits
AgeCommit message (Collapse)AuthorLines
2023-06-09Rollup merge of #112428 - compiler-errors:next-solver-struct-resolv-pat, r=lcnrMatthias Krüger-0/+11
Structurally resolve pointee in `check_pat_lit` Gotta make sure to eager norm the pointee of the match scrutinee with the new solver. r? ``@lcnr``
2023-06-08deduplicate identical region constraintsMichael Goulet-0/+31
2023-06-08Structurally resolve correctly in check_pat_litMichael Goulet-0/+11
2023-06-08Do fix_*_builtin_expr hacks on the writeback resultsMichael Goulet-0/+11
2023-06-07Instantiate closure synthetic substs in root universeMichael Goulet-0/+7
2023-06-06Fall back to bidirectional normalizes-to if no subst-eq in alias-eq goalMichael Goulet-0/+73
2023-06-02Normalize anon consts in new solverMichael Goulet-24/+50
2023-06-01Rollup merge of #111980 - compiler-errors:unmapped-substs, r=lcnrDylan DPC-0/+19
Preserve substs in opaques recorded in typeck results This means that we now prepopulate MIR with opaques with the right substs. The first commit is a hack that I think we discussed, having to do with `DefiningAnchor::Bubble` basically being equivalent to `DefiningAnchor::Error` in the new solver, so having to use `DefiningAnchor::Bind` instead, lol. r? `@lcnr`
2023-05-31update test to not rely on super_relate_consts hackBoxy-2/+24
2023-05-30coinductive cycle leak check testlcnr-0/+33
2023-05-26Wait until type_of to remap HIR opaques back to their defn paramsMichael Goulet-0/+19
2023-05-25Strongly prefer alias and param-env boundsMichael Goulet-20/+6
2023-05-23Auto merge of #110204 - compiler-errors:new-solver-hir-typeck-hacks, r=lcnrbors-0/+38
Deal with unnormalized projections when structurally resolving types with new solver 1. Normalize types in `structurally_resolved_type` when the new solver is enabled 2. Normalize built-in autoderef targets in `Autoderef` when the new solver is enabled 3. Normalize-erasing-regions in `resolve_type` in writeback This is motivated by the UI test provided, which currently fails with: ``` error[E0609]: no field `x` on type `<usize as SliceIndex<[Foo]>>::Output` --> <source>:9:11 | 9 | xs[0].x = 1; | ^ ``` I'm pretty happy with the approach in (1.) and (2.) and think we'll inevitably need something like this in the long-term, but (3.) seems like a hack to me. It's a *lot* of work to add tons of new calls to every user of these typeck results though (mir build, late lints, etc). Happy to discuss further. r? `@lcnr`
2023-05-22Structurally normalize in the new solverMichael Goulet-0/+38
2023-05-22Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPCbors-3/+3
Rollup of 6 pull requests Successful merges: - #111501 (MIR drive-by cleanups) - #111609 (Mark internal functions and traits unsafe to reflect preconditions) - #111612 (Give better error when collecting into `&[T]`) - #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming) - #111843 (move lcnr to only review types stuff) - #111844 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-21Rename `drop_ref` lint to `dropping_references`Urgau-1/+1
2023-05-21Rename `drop_copy` lint to `dropping_copy_types`Urgau-2/+2
2023-05-19add testlcnr-1/+75
2023-05-19Auto merge of #110100 - compiler-errors:no-infer-pred-must-hold, r=jackh726bors-2/+15
do not allow inference in `predicate_must_hold` (alternative approach) See the FCP description for more info, but tl;dr is that we should not return `EvaluatedToOkModuloRegions` if an obligation may hold only with some choice of inference vars being constrained. Attempts to solve this in the approach laid out by lcnr here: https://github.com/rust-lang/rust/pull/109558#discussion_r1147318134, rather than by eagerly replacing infer vars with placeholders which is a bit too restrictive. r? `@ghost`
2023-05-17Rollup merge of #111588 - MU001999:diag/improve-e0782, r=fee1-deadDylan DPC-11/+2
Emits E0599 when meeting `MyTrait::missing_method` Fixes #111312
2023-05-17Emits E0599 when meeting MyTrait::missing_methodmu001999-11/+2
2023-05-15Tweaks and a testMichael Goulet-0/+45
2023-05-13Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naberDylan DPC-16/+11
Note user-facing types of coercion failure When coercing, for example, `Box<A>` into `Box<dyn B>`, make sure that any failure notes mention *those* specific types, rather than mentioning inner types, like "the cast from `A` to `dyn B`". I expect end-users are often confused when we skip layers of types and only mention the "innermost" part of a coercion, especially when other notes point at HIR, e.g. #111406.
2023-05-12do not allow inference in `pred_known_to_hold_modulo_regions`Michael Goulet-2/+15
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-3/+9
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12Note base types of coercionMichael Goulet-16/+11
2023-05-10Adjust tests for new drop and forget lintsUrgau-3/+9
2023-05-09Make alias bounds sound in the new solverMichael Goulet-0/+71
2023-05-08Rollup merge of #111211 - compiler-errors:negative-bounds-super, r=TaKO8KiYuki Okushi-0/+19
Don't compute trait super bounds unless they're positive Fixes #111207 The comment is modified to explain the rationale for why we even have this recursive call to supertraits in the first place, which doesn't apply to negative bounds since they don't elaborate at all.
2023-05-04Add test for #110557Michael Goulet-0/+60
2023-05-04Don't compute trait super bounds unless they're positiveMichael Goulet-0/+19
2023-05-03Rollup merge of #111146 - petrochenkov:decident, r=compiler-errorsManish Goregaokar-3/+6
rustc_middle: Fix `opt_item_ident` for non-local def ids Noticed while working on https://github.com/rust-lang/rust/pull/110855.
2023-05-03rustc_middle: Fix `opt_item_ident` for non-local def idsVadim Petrochenkov-3/+6
2023-05-02Make negative trait bounds work with the old trait solverMichael Goulet-14/+2
2023-05-02Disallow associated type constraints on negative boundsMichael Goulet-0/+54
2023-05-02Implement negative boundsMichael Goulet-0/+124
2023-05-01Don't use implied trait predicates in gather_explicit_predicates_ofMichael Goulet-1/+16
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-2/+2
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-27Tweak await spanMichael Goulet-2/+2
2023-04-26Clear response values for overflow in new solverMichael Goulet-0/+43
2023-04-25Auto merge of #110811 - compiler-errors:vars-are-question-mark, r=WaffleLapkinbors-4/+4
Use `?0` notation for ty/ct/int/float/region vars Aligns the notation for infer vars that T-types and friends most often uses for inference variables with the notation in the compiler (which is kinda a sigil nightmare IMO: `_#`) by adopting `?0` style infer vars. This mostly affects debug output since verbose infer vars shouldn't show up in user-facing places. Does this need an MCP? It's debug output, so I'm thinking no, but happy to open one. :thinking: r? types
2023-04-25vars are ?Michael Goulet-4/+4
2023-04-25Negative coherence testMichael Goulet-0/+52
2023-04-22Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjaybors-0/+23
Clone region var origins instead of taking them in borrowck Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`. This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver. Fixes compiler-errors/next-solver-hir-issues#12. ---- This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
2023-04-21Clone region var origins instead of taking in borrowckMichael Goulet-0/+23
2023-04-20Move test filesCaio-0/+17
2023-04-14Rollup merge of #110180 - lcnr:canonicalize, r=compiler-errorsMatthias Krüger-0/+12
don't uniquify regions when canonicalizing uniquifying causes a bunch of issues, most notably it causes `AliasEq(<?x as Trait<'a>>::Assoc, <?x as Trait<'a>>::Assoc)` to result in ambiguity because both `normalizes-to` paths result in ambiguity and substs equate should trivially succeed but doesn't because we uniquified `'a` to two different regions. I originally added uniquification to make it easier to deal with requirement 6 from the dev-guide: https://rustc-dev-guide.rust-lang.org/solve/trait-solving.html#requirements > ### 6. Trait solving must be (free) lifetime agnostic > > Trait solving during codegen should have the same result as during typeck. As we erase > all free regions during codegen we must not rely on them during typeck. A noteworthy example > is special behavior for `'static`. cc https://github.com/rust-lang/rustc-dev-guide/pull/1671 Relying on regions being identical may cause ICE during MIR typeck, but even without this PR we can end up relying on that as type inference vars can resolve to types which contain an identical region. Let's land this and deal with any ICE that crop up as we go. Will look at this issue again before stabilization. r? ```@compiler-errors```
2023-04-14Add test for uniquifying regionsMichael Goulet-0/+12
2023-04-13Rollup merge of #110195 - compiler-errors:issue-110052, r=aliemjayMatthias Krüger-1/+6
Erase lifetimes above `ty::INNERMOST` when probing ambiguous types Turns out that `TyCtxt::replace_escaping_bound_vars_uncached` only erases bound vars exactly at `ty::INNERMOST`, and not everything above. This regresses the suggestions for non-lifetime binders, but oh well, I don't really care about those. Fixes #110052
2023-04-13Auto merge of #109786 - estebank:tweak-add-line-sugg, r=compiler-errorsbors-7/+9
Tweak output for 'add line' suggestion Closes #108174