about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-02-14fast_reject: remove `StripReferences`lcnr-30/+10
2022-02-14fuzzify `fuzzy_match_tys`lcnr-102/+38
2022-02-14Make `find_similar_impl_candidates` a little fuzzier.Ben Reeves-32/+115
2022-02-12Address review commentMatthew Jasper-1/+2
canonicalize_chalk_query -> canonicalize_query_preserving_universes
2022-02-11Renumber universes when canonicalizing for ChalkMatthew Jasper-2/+6
This is required to avoid creating large numbers of universes from each Chalk query, while still having enough universe information for lifetime errors.
2022-02-11Auto merge of #93893 - oli-obk:sad_revert, r=oli-obkbors-109/+37
Revert lazy TAIT PR Revert https://github.com/rust-lang/rust/pull/92306 (sorry `@Aaron1011,` will include your changes in the fix PR) Revert https://github.com/rust-lang/rust/pull/93783 Revert https://github.com/rust-lang/rust/pull/92007 fixes https://github.com/rust-lang/rust/issues/93788 fixes https://github.com/rust-lang/rust/issues/93794 fixes https://github.com/rust-lang/rust/issues/93821 fixes https://github.com/rust-lang/rust/issues/93831 fixes https://github.com/rust-lang/rust/issues/93841
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-84/+23
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-11Revert "Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk"Oli Scherer-25/+14
This reverts commit 1f0a96862ac9d4c6ca3e4bb500c8b9eac4d83049, reversing changes made to bf242bb1199e25ca2274df5c4114e0c9436b74e9.
2022-02-10only mark projection as ambiguous if GAT substs are constrainedMichael Goulet-33/+51
2022-02-11Rollup merge of #93853 - steffahn:map_by_value, r=wesleywiserMatthias Krüger-1/+1
Make all `hir::Map` methods consistently by-value `hir::Map` only consists of a single reference (as part of the contained `TyCtxt`) anyways, so copying is literally zero overhead compared to passing a reference
2022-02-10Remove further usage of `&hir::Map`Frank Steffahn-1/+1
2022-02-10Auto merge of #93511 - cjgillot:query-copy, r=oli-obkbors-3/+3
Ensure that queries only return Copy types. This should pervent the perf footgun of returning a result with an expensive `Clone` impl (like a `Vec` of a hash map). I went for the stupid solution of allocating on an arena everything that was not `Copy`. Some query results could be made Copy easily, but I did not really investigate.
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-3/+3
2022-02-09Allow substitutions in `rustc_on_unimplemented` predicateMichael Goulet-12/+36
2022-02-09Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obkbors-14/+25
Improve opaque type higher-ranked region error message under NLL Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-08Improve opaque type higher-ranked region error message under NLLAaron Hill-14/+25
Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-08Rollup merge of #92917 - jackh726:issue-91762-2, r=nikomatsakisMatthias Krüger-1/+11
Don't constrain projection predicates with inference vars in GAT substs cc #91762 Not a fix, but a mitigation to prevent a backwards-compatible hazard where we normalize using a predicate only because it's the only one available, but shouldn't. This would constrain an inference variable which didn't really want. We already do this when selecting a projection candidate, which isn't always correct. But changing that is a problem for a different day. Also found out that a suggestion for `await`ing a future was using the wrong substs. r? ``@nikomatsakis``
2022-02-08Rollup merge of #93728 - JulianKnodt:toterm, r=oli-obkMatthias Krüger-20/+5
Add in ValuePair::Term This adds in an enum when matching on positions which can either be types or consts. It will default to emitting old special cased error messages for types. r? `@oli-obk` cc `@matthiaskrgr` Fixes #93578
2022-02-07Change inference var check to be in project_typeJack Huey-11/+11
2022-02-07Don't match any projection predicates when the obligation has inference ↵Jack Huey-2/+12
types or consts in GAT substs
2022-02-07Rm ValuePairs::Ty/Constkadmin-20/+5
Remove old value pairs which is a strict subset of Terms.
2022-02-03compiler: clippy::complexity fixesMatthias Krüger-3/+2
useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-02-02Fix some doctests where the main function returns an opaque typeOli Scherer-0/+5
2022-02-02Bail out early if there already were errorsOli Scherer-10/+5
2022-02-02Make a span more usefulOli Scherer-0/+1
2022-02-02Guess head span of async blocksOli Scherer-0/+1
2022-02-02Make a comment more obviousOli Scherer-2/+4
2022-02-02Eagerly merge hidden types.Oli Scherer-3/+3
2022-02-02Register member constraints on the final merged hidden typeOli Scherer-1/+1
Previously we did this per hidden type candiate, which didn't always have all the information available.
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-12/+69
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-01Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obkbors-116/+128
Continue work on associated const equality This actually implements some more complex logic for assigning associated consts to values. Inside of projection candidates, it now defers to a separate function for either consts or types. To reduce amount of code, projections are now generic over T, where T is either a Type or a Const. I can add some comments back later, but this was the fastest way to implement it. It also now finds the correct type of consts in type_of. --- The current main TODO is finding the const of the def id for the LeafDef. Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection. I was hoping to get some help in getting the `&'tcx ty::Const<'tcx>`, in addition to a bunch of other `todo!()`s which I think may not be hit. r? `@oli-obk` Updates #92827
2022-02-01Fix w/ commentskadmin-59/+47
2022-02-01Rollup merge of #93290 - lcnr:same_type, r=jackh726Matthias Krüger-1/+1
remove `TyS::same_type` This function ignored regions and constants in adts, but didn't do so for references or any other types. cc https://github.com/rust-lang/rust/pull/93148#discussion_r791408057
2022-02-01remove `TyS::same_type`lcnr-1/+1
it ignored regions and constants in adts, but didn't do so for references or any other types. This seemed quite weird
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-31Add ValuePairs::Terms & Fix compile errorkadmin-39/+25
And use correct substs.
2022-01-31Auto merge of #93348 - spastorino:fix-perf-overlap-mode2, r=nikomatsakisbors-60/+30
Move overlap_mode into trait level attribute r? `@nikomatsakis` Should fix some performance regressions noted on https://github.com/rust-lang/rust/pull/93175
2022-01-31Do not store overlap_mode, just pass it down on insertSantiago Pastorino-3/+5
2022-01-31Move overlap_mode into trait level attribute + feature flagSantiago Pastorino-59/+27
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-6/+8
Improve terminology around "after typeck" Closes #70258.
2022-01-30Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-deadMatthias Krüger-7/+25
Add note suggesting that predicate may be satisfied, but is not `const` Not sure if we should be printing this in addition to, or perhaps _instead_ of the help message: ``` help: the trait `~const Add` is not implemented for `NonConstAdd` ``` Also added `ParamEnv::is_const` and `PolyTraitPredicate::is_const_if_const` and, in a separate commit, used those in other places instead of `== hir::Constness::Const`, etc. r? ````@fee1-dead````
2022-01-28Auto merge of #93343 - lqd:attrs, r=spastorinobors-18/+25
Only traverse attrs once while checking for coherence override attributes In coherence, while checking for negative impls override attributes: only traverse the `DefId`s' attributes once. This PR is an easy way to get back some of the small perf loss in #93175
2022-01-28Remove generalization over projectionkadmin-320/+99
Instead, just use a term everywhere.
2022-01-27Continue work on assoc const eqkadmin-108/+367
2022-01-26drive-by: use is_const and is_const_if_constMichael Goulet-8/+4
2022-01-26add note suggesting that predicate is satisfied but is not constMichael Goulet-0/+22
2022-01-26Rollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obkMatthias Krüger-148/+220
Improve selection errors for `~const` trait bounds
2022-01-26Only traverse attrs once while checking for coherence overrideRémy Rakic-18/+25
2022-01-25Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillotbors-13/+20
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-26Add a minimal working `append_const_msg` argumentDeadbeef-8/+50