about summary refs log tree commit diff
path: root/tests/ui/traits
AgeCommit message (Collapse)AuthorLines
2023-07-18add links to query documentation for E0391nxya-2/+2
2023-07-16Check GAT, IAT, and weak type where clauses during projectionMichael Goulet-7/+67
2023-07-15Rollup merge of #113625 - compiler-errors:structurally-norm-in-selection, r=lcnrMatthias Krüger-0/+18
Structurally normalize in selection We need to do this because of the fact that we're checking the `Ty::kind` on a type during selection, but goals passed into select are not necessarily normalized. Right now, we're (kinda) unnecessarily normalizing the RHS of a trait upcasting goal, which is broken for different reasons (#113393). But I'm waiting for this PR to land before discussing that one. r? `@lcnr`
2023-07-14Structurally normalize in selectionMichael Goulet-0/+18
2023-07-14Allow escaping bound vars during normalize_erasing_regions in new solverMichael Goulet-0/+18
2023-07-13add test for incomplete alias bound preferencelcnr-0/+39
2023-07-13Rollup merge of #113353 - compiler-errors:select-better, r=lcnrMatthias Krüger-0/+52
Implement selection for `Unsize` for better coercion behavior In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of `Unsize` traits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs#L126 This implements a proper "rematch" procedure for dealing with built-in `Unsize` goals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_hir_typeck/src/coercion.rs#L702 Second commit just moves a `resolve_vars_if_possible` call to fix a bug where we weren't detecting a trait upcasting to occur. r? ``@lcnr``
2023-07-08Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgrbors-3/+3
Rollup of 6 pull requests Successful merges: - #113005 (Don't call `query_normalize` when reporting similar impls) - #113064 (std: edit [T]::swap docs) - #113138 (Add release notes for 1.71.0) - #113217 (resolve typerelative ctors to adt) - #113254 (Use consistent formatting in Readme) - #113482 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-08Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillotMatthias Krüger-3/+3
Don't call `query_normalize` when reporting similar impls Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well. The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions: ``` error[E0277]: the trait bound `[X; 35]: Default` is not satisfied --> /home/gh-compiler-errors/test.rs:4:5 | 4 | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: &[T] &mut [T] [T; 32] [T; core::::array::{impl#30}::{constant#0}] [T; core::::array::{impl#31}::{constant#0}] [T; core::::array::{impl#32}::{constant#0}] [T; core::::array::{impl#33}::{constant#0}] [T; core::::array::{impl#34}::{constant#0}] and 27 others ``` So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-08Rollup merge of #113399 - compiler-errors:next-solver-byte-pat-again, r=oli-obkMatthias Krüger-12/+1
Structurally normalize again for byte string lit pat checking We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic. Fixes rust-lang/trait-system-refactor-initiative#38 [^1]: #112428 [^2]: #112993 [^3]: #113086
2023-07-08Eagerly resolve vars in predicate during coercion loopMichael Goulet-0/+37
2023-07-08Implement selection for unsize for better coercion behaviorMichael Goulet-0/+15
2023-07-07Require TAITs to be mentioned in the signatures of functions that register ↵Oli Scherer-10/+15
hidden types for them
2023-07-06Rollup merge of #113397 - compiler-errors:new-select-prefer-obj, r=lcnrMichael Goulet-0/+13
Prefer object candidates in new selection `dyn Any` shouldn't be using [this implementation](https://doc.rust-lang.org/std/any/trait.Any.html#impl-Any-for-T) during codegen. Prefer object candidates over other candidates, except for other object candidates.
2023-07-06Don't call type_of on TAIT in defining scope in new solverMichael Goulet-100/+39
2023-07-06Structurally normalize again for byte string lit pat checkingMichael Goulet-12/+1
2023-07-06Prefer object candidates over impl candidates in new selectionMichael Goulet-0/+13
2023-07-05Winnow specializing implsMichael Goulet-0/+22
2023-07-03update testslcnr-95/+285
2023-06-30Rollup merge of #113071 - ↵Matthias Krüger-0/+28
compiler-errors:no-parent-non-lifetime-args-in-apit, r=eholk Account for late-bound vars from parent arg-position impl trait We should be reporting an error like we do for late-bound args coming from a parent APIT. Fixes #113016
2023-06-29Rollup merge of #112929 - ↵Matthias Krüger-0/+182
oli-obk:what_if_an_impl_item_just_doesnt_wanna_be_impld, r=compiler-errors Test that we require implementing trait items whose bounds don't hold in the current impl I initially tried to make most of these pass, but that's a big can of worms, so I'm just adding them as tests, considering we have no tests for these things.
2023-06-28Rollup merge of #112867 - compiler-errors:more-impl-source-nits, r=lcnrDylan DPC-0/+1
More `ImplSource` nits Even more clean-ups, I'll put this up in parallel with the `select_in_new_trait_solver` PR. r? ``@lcnr``
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-3/+3
2023-06-27Rollup merge of #113020 - ↵Matthias Krüger-0/+45
AnthonyKalaitzis:add-tests-impl-via-obj-unless-denied, r=compiler-errors Add tests impl via obj unless denied Fixes #112737 Add simple tests to check feature change in #112320 is performing as expected. Note: - Unsure about filenames, locations & function signature names (tried to make them something sensible)
2023-06-27Add passing & failing test for bultin dyn trait generationAnthony Kalaitzis-0/+45
2023-06-26Account for late-bound vars from parent arg-position impl traitMichael Goulet-0/+28
2023-06-26Add some tests around where bounds on associated items and their lack of ↵Oli Scherer-0/+182
effect on impls
2023-06-25Rollup merge of #113007 - ↵Matthias Krüger-1/+12
compiler-errors:dont-structural-resolve-byte-str-pat, r=oli-obk Revert "Structurally resolve correctly in check_pat_lit" This reverts commit 54fb5a48b968b3a329ceeb57226d9ac60f983f04. Also adds a couple of tests, and downgrades the existing `-Ztrait-solver=next` test to a known-bug. Fixes #112993
2023-06-24Revert "Structurally resolve correctly in check_pat_lit"Michael Goulet-1/+12
This reverts commit 54fb5a48b968b3a329ceeb57226d9ac60f983f04.
2023-06-24Rollup merge of #112703 - aliemjay:next-solver-root-var, r=compiler-errorsGuillaume Gomez-0/+17
[-Ztrait-solver=next, mir-typeck] instantiate hidden types in the root universe Fixes an ICE in the test `member-constraints-in-root-universe`. Main motivation is to make #112691 pass under the new solver. r? ``@compiler-errors``
2023-06-24instantiate hidden types in root universeAli MJ Al-Nasrawy-0/+17
2023-06-23Resolve vars when reporting WF errorMichael Goulet-4/+4
2023-06-23Don't emit same goal as input during wf obligationsMichael Goulet-1/+15
2023-06-20Remove unnecessary call to select_from_obligationMichael Goulet-0/+1
The only regression is one ambiguity in the new trait solver, having to do with two param-env candidates that may apply. I think this is fine, since the error message already kinda sucks.
2023-06-20Rollup merge of #112786 - lcnr:early-binder, r=NilstriebGuillaume Gomez-22/+22
change binders from tuple structs to named fields
2023-06-20Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnrbors-0/+50
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code. Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above. The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits: https://github.com/rust-lang/rust/blob/2f896da247e0ee8f0bef7cd7c54cfbea255b9f68/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L61-L132 However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well. r? `@lcnr`
2023-06-20Merge attrs, better validationMichael Goulet-0/+50
2023-06-19update testslcnr-22/+22
2023-06-19Don't ICE on bound var in reject_fn_ptr_implsMichael Goulet-0/+40
2023-06-16Rollup merge of #112443 - ↵Dylan DPC-0/+19
compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr Opportunistically resolve regions in new solver Use `opportunistic_resolve_var` during canonicalization to collapse some regions. We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response... There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation. r? ```@lcnr```
2023-06-16Rollup merge of #112399 - compiler-errors:closure-substs-root-universe, r=lcnrDylan DPC-0/+7
Instantiate closure synthetic substs in root universe In the UI test example, we end up generalizing an associated type (something like `<Map<Option<i32>, [closure upvars=?0]> as IntoIterator>::Item` generalizes into `<Map<Option<i32>, [closure upvars=?1]> as IntoIterator>::Item`) then assigning it to itself, emitting an alias-relate goal. This trivially holds via one of the normalizes-to candidates, instead of relating substs, so when closure analysis eventually sets `?0` to the actual upvars, `?1` never gets constrained. This ends up being reported as an ambiguity error during writeback. Instead, we can take advantage of the fact that we *know* the closure substs live in the root universe. This will prevent them being generalized, since they always can be named, and the alias-relate above never gets emitted at all. We can probably do this to a handful of other `next_ty_var` calls in typeck for variables that are clearly associated with the body of the program, but I wanted to limit this for now. Eventually, if we end up representing universes more faithfully like a tree or whatever, we can remove this and turn it back to just a call to `next_ty_var`. Note: This is incredibly order-dependent -- we need to be assigning a type variable that was created *before* the closure substs, and we also need to actually have an unnormalized type at the time of the assignment. This currently seems easiest to trigger during call argument analysis just due to the fact that we instantiate the call's substs, normalize, THEN check args. r? ```@lcnr```
2023-06-16Rollup merge of #112163 - bvanjoi:fix-105231-2, r=compiler-errorsDylan DPC-0/+38
fix: inline `predicate_may_hold_fatal` and remove expect call in it - Fixes #105231 - Discussion: https://github.com/rust-lang/rust/pull/111985#discussion_r1208888821 r? ``@compiler-errors``
2023-06-16fix: inline `predicate_may_hold_fatal`bohan-0/+38
2023-06-15change `std::marker::Sized` to just `Sized`Lukas Markeffsky-2/+2
2023-06-14Auto merge of #112400 - WaffleLapkin:vtable_stats, r=compiler-errorsbors-0/+72
Collect VTable stats & add `-Zprint-vtable-sizes` This is a bit hacky/buggy, but I'm not entirely sure how to fix it, so I want to ask reviewers for help... To try this, use either of those: - `cargo clean && RUSTFLAGS="-Zprint-vtable-sizes" cargo +toolchain b` - `cargo clean && cargo rustc +toolchain -Zprint-vtable-sizes` - `rustc +toolchain -Zprint-vtable-sizes ./file.rs`
2023-06-13opportunistically resolve regionsMichael Goulet-0/+19
2023-06-13Add a test for `-Zprint-vtable-sizes`Maybe Waffle-0/+72
2023-06-12Adjust UI tests for `unit_bindings`许杰友 Jieyou Xu (Joe)-1/+1
- Either explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Fix disjoint-capture-in-same-closure test
2023-06-09Ignore tests that hang in new solverMichael Goulet-2/+3
2023-06-09Rollup merge of #112442 - ↵Guillaume Gomez-0/+31
compiler-errors:next-solver-deduplicate-region-constraints, r=lcnr Deduplicate identical region constraints in new solver the new solver doesn't track whether we've already proven a goal like the fulfillment context's obligation forest does, so we may be instantiating a canonical response (and specifically, its nested region obligations) quite a few times. This may lead to exponentially gathering up identical region constraints for things like auto traits, so let's deduplicate region constraints when in `compute_external_query_constraints`. r? ``@lcnr``