about summary refs log tree commit diff
path: root/src/librustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2020-06-04Rollup merge of #72946 - lcnr:remove-fixme, r=Dylan-DPCDylan DPC-3/+0
remove outdated fixme This function now accepts `impl Iterator<Item = ty::Predicate<'tcx>>`.
2020-06-03remove outdated fixmeBastian Kauschke-3/+0
2020-06-03remove ignore-tidy-filelengthBastian Kauschke-2/+0
2020-06-03move confirmation into submoduleBastian Kauschke-804/+827
2020-06-03move candidate assembly into a submoduleBastian Kauschke-607/+613
2020-06-03move select into subfolderBastian Kauschke-0/+0
2020-06-03Auto merge of #70107 - lcnr:issue68977, r=eddybbors-74/+142
WF-check all ty::Const's, not just array lengths. fixes #68977 This PR removes the special case for array length in `wf::compute` and checks the well formedness of all consts. Changes `PredicateKind::WellFormed` to take a `GenericArg` and updates `wf::obligations`.
2020-06-02Rename the crates in source codeVadim Petrochenkov-3/+2
2020-06-02Make things build againVadim Petrochenkov-1/+1
2020-06-02update testsBastian Kauschke-3/+4
2020-06-02change WellFormed predicate to GenericArgBastian Kauschke-120/+78
2020-06-02add WellFormedConst predicateBastian Kauschke-11/+71
2020-06-02implement wf checking for constantsBastian Kauschke-38/+87
2020-06-02remove assertBastian Kauschke-2/+1
2020-06-02Rollup merge of #72775 - JohnTitor:await-sugg, r=estebankYuki Okushi-7/+6
Return early to avoid ICE Fixes #72766
2020-06-02normalize adt fields during structural match checkBastian Kauschke-1/+5
2020-06-01Call `skip_binder` or `no_bound_vars` before `self_ty`Dylan MacKenzie-19/+39
2020-06-01Rollup merge of #72776 - lcnr:stalled_on-smallvec, r=nnethercoteDylan DPC-3/+4
fulfill: try using SmallVec or Box for stalled_on Tested both `Box` and `SmallVec` for `stalled_on`, with both resulting in a perf loss. Adds a comment mentioning this and removes an now outdated FIXME. Logging the length of `stalled_on` resulted in the following distribution while building a part of stage 1 libs: ``` 22627647 counts: ( 1) 20983696 (92.7%, 92.7%): process_obligation_len: 1 ( 2) 959711 ( 4.2%, 97.0%): process_obligation_len: 2 ( 3) 682326 ( 3.0%,100.0%): process_obligation_len: 0 ( 4) 1914 ( 0.0%,100.0%): process_obligation_len: 3 ``` cc @eddyb r? @nnethercote
2020-05-31Rollup merge of #72807 - xiaotianrandom:fix-assoc-type-diagnostics, r=estebankDylan DPC-19/+12
Avoid setting wrong obligation cause span of associated type mismatch Removes code that sets wrong obligation cause span of associated type mismatch. See the linked issue for details. Closes #72806.
2020-05-31Rollup merge of #72715 - estebank:trailing-comma-where, r=petrochenkovRalf Jung-1/+1
Account for trailing comma when suggesting `where` clauses Fix #72693.
2020-05-31remove fixme for `stalled_on`Bastian Kauschke-3/+4
2020-05-31Fix associate type diagnosticsXIAO Tian-19/+12
2020-05-30Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, ↵Ralf Jung-8/+7
r=varkor mir: adjust conditional in recursion limit check Fixes #67552. This PR adjusts the condition used in the recursion limit check of the monomorphization collector, from `>` to `>=`. In #67552, the test case had infinite indirect recursion, repeating a handful of functions (from the perspective of the monomorphization collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold` -> `Iterator::next` -> `rec`. During this process, `resolve_associated_item` was invoked for `Iterator::fold` (during the construction of an `Instance`), and ICE'd due to substitutions needing inference. However, previous iterations of this recursion would have called this function for `Iterator::fold` - and did! - and succeeded in doing so (trivially checkable from debug logging, `()` is present where `_` is in the substs of the failing execution). The expected outcome of this test case would be a recursion limit error (which is present when the `identity` fn indirection is removed), and the recursion depth of `rec` is increasing (other functions finish collecting their neighbours and thus have their recursion depths reset). When the ICE occurs, the recursion depth of `rec` is 256 (which matches the recursion limit), which suggests perhaps that a different part of the compiler is using a `>=` comparison and returning a different result on this recursion rather than what it returned in every previous recursion, thus stopping the monomorphization collector from reporting an error on the next recursion, where `recursion_depth_of_rec > 256` would have been true. With grep and some educated guesses, we can determine that the recursion limit check at line 818 in `src/librustc_trait_selection/traits/project.rs` is the other check that is using a different comparison. Modifying either comparison to be `>` or `>=` respectively will fix the error, but changing the monomorphization collector produces the nicer error.
2020-05-30Return early to avoid ICEYuki Okushi-7/+6
2020-05-30Rollup merge of #72621 - Aaron1011:fix/trait-select-error, r=nikomatsakisYuki Okushi-11/+0
Don't bail out of trait selection when predicate references an error Fixes #72590 With PR #70551, observing a `ty::Error` guarantees that compilation is going to fail. Therefore, there are no soundness impliciations to continuing on when we encounter a `ty::Error` - we can only affect whether or not additional error messags are emitted. By not bailing out, we avoid incorrectly determining that types are `!Sized` when a type error is present, which allows us to avoid emitting additional spurious error messages. The original comment mentioned this code being shared by coherence - howver, this change resulted in no diagnostic changes in any of the existing tests.
2020-05-29Move common code to `WhereClause`Esteban Küber-10/+1
2020-05-29Rollup merge of #72466 - lzutao:stabilize_str-strip, r=dtolnayDylan DPC-1/+0
Stabilize str_strip feature This PR stabilizes these APIs: ```rust impl str { /// Returns a string slice with the prefix removed. /// /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly /// once. pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>; /// Returns a string slice with the suffix removed. /// /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly /// once. pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str> where P: Pattern<'a>, <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>; } ``` Closes #67302
2020-05-28Account for trailing comma when suggesting `where` clausesEsteban Küber-1/+10
Fix #72693.
2020-05-28standardize limit comparisons with `Limit` typeDavid Wood-8/+7
This commit introduces a `Limit` type which is used to ensure that all comparisons against limits within the compiler are consistent (which can result in ICEs if they aren't). Signed-off-by: David Wood <david@davidtw.co>
2020-05-28Auto merge of #72494 - lcnr:predicate-cleanup, r=nikomatsakisbors-33/+31
Pass more `Copy` types by value. There are a lot of locations where we pass `&T where T: Copy` by reference, which should both be slightly less performant and less readable IMO. This PR currently consists of three fairly self contained commits: - passes `ty::Predicate` by value and stops depending on `AsRef<ty::Predicate>`. - changes `<&List<_>>::into_iter` to iterate over the elements by value. This would break `List`s of non copy types. But as the only list constructor requires `T` to be copy anyways, I think the improved readability is worth this potential future restriction. - passes `mir::PlaceElem` by value. Mir currently has quite a few copy types which are passed by reference, e.g. `Local`. As I don't have a lot of experience working with MIR, I mostly did this to get some feedback from people who use MIR more frequently - tries to reuse `ty::Predicate` in case it did not change in some places, which should hopefully fix the regression caused by #72055 r? @nikomatsakis for the first commit, which continues the work of #72055 and makes adding `PredicateKind::ForAll` slightly more pleasant. Feel free to reassign though
2020-05-27Auto merge of #71996 - Marwes:detach_undo_log, r=nikomatsakisbors-12/+6
perf: Revert accidental inclusion of a part of #69218 This was accidentally included in #69464 after a rebase and given how much `inflate` and `keccak` stresses the obligation forest seems like a likely culprit to the regression in those benchmarks. (It is necessary in #69218 as obligation forest needs to accurately track the root variables or unifications will get lost)
2020-05-26Don't bail out of trait selection when predicate references an errorAaron Hill-11/+0
Fixes #72590 With PR #70551, observing a `ty::Error` guarantees that compilation is going to fail. Therefore, there are no soundness impliciations to continuing on when we encounter a `ty::Error` - we can only affect whether or not additional error messags are emitted. By not bailing out, we avoid incorrectly determining that types are `!Sized` when a type error is present, which allows us to avoid emitting additional spurious error messages. The original comment mentioned this code being shared by coherence - howver, this change resulted in no diagnostic changes in any of the existing tests.
2020-05-25Rollup merge of #72450 - csmoe:issue-72442, r=oli-obkDylan DPC-1/+5
Fix ice-#72442 Closes #72442 Closes #72426 r? @oli-obk
2020-05-25Rollup merge of #72061 - lcnr:const-inference-test, r=eddybDylan DPC-4/+4
add regression tests for stalled_on const vars closes #70180 Afaict this has been fixed sometime after #70213 `trait_ref_type_vars` correctly adds const infers and I did not find any remaining `FIXME`s which correspond to this issue. https://github.com/rust-lang/rust/blob/7c59a81a5fcbaaca311f744cd7c68d99bfbb05d3/src/librustc_trait_selection/traits/fulfill.rs#L555-L557 Added both examples from the issue as regression tests and renamed `trait_ref_type_vars` -> `trait_ref_infer_vars`. r? @eddyb
2020-05-25Rollup merge of #72153 - lcnr:exhaustively-match, r=pnkfelixDylan DPC-5/+48
exhaustively check `ty::Kind` during structural match checking This was prone to errors as we may forget new kinds in the future. I am also not yet sure about some kinds. `ty::GeneratorWitness(..) | ty::Infer(_) | ty::Placeholder(_) | ty::UnnormalizedProjection(..) | ty::Bound(..)` might be unreachable here. We may want to forbid `ty::Projection`, similar to `ty::Param`. `ty::Opaque` seems fine afaict, should not be possible in a match atm. I believe `ty::Foreign` should not be structurally match, as I don't even know what that would actually mean. r? @pnkfelix cc @eddyb
2020-05-25Rollup merge of #72544 - sexxi-goose:upvars_mentioned, r=matthewjasperRalf Jung-1/+1
librustc_middle: Rename upvars query to upvars_mentioned As part of supporting RFC 2229, we will be capturing all the Places that were mentioned in the closure. This commit modifies the name of the upvars query to upvars_mentioned. r? @nikomatsakis @blitzerr @matthewjasper
2020-05-24librustc_middle: Rename upvars query to upvars_mentionedAman Arora-1/+1
As part of supporting RFC 2229, we will be capturing all the Places that were mentioned in the closure. This commit modifies the name of the upvars query to upvars_mentioned. Co-authored-by: Aman Arora <me@aman-arora.com> Co-authored-by: Chris Pardy <chrispardy36@gmail.com>
2020-05-24Auto merge of #72524 - RalfJung:rollup-s9f1pcc, r=RalfJungbors-19/+6
Rollup of 2 pull requests Successful merges: - #72388 (Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro`) - #72517 (small select cleanup) Failed merges: r? @ghost
2020-05-24Rollup merge of #72517 - lcnr:refactor-winnowing, r=jonas-schievinkRalf Jung-19/+6
small select cleanup
2020-05-24Auto merge of #72362 - matthewjasper:remove-rescope, r=nikomatsakisbors-7/+2
Remove ReScope `ReScope` is unnecessary now that AST borrowck is gone and we're erasing the results of region inference in function bodies. This removes about as much of the old regionck code as possible without having to enable NLL fully. cc #68261 r? @nikomatsakis
2020-05-24small select cleanupBastian Kauschke-19/+6
2020-05-24Rollup merge of #71618 - ecstatic-morse:issue-71394, r=nikomatsakisDylan DPC-42/+53
Preserve substitutions when making trait obligations for suggestions Resolves #71394. I *think* `map_bound_ref` is correct here. In any case, I think a lot of the diagnostic code is using `skip_binder` more aggressively than it should be, so I doubt that this is worse than the status quo. The assertion that `new_self_ty` has no escaping bound vars should be enough. r? @estebank cc @nikomatsakis Is the call to `skip_binder` on line 551 (and elsewhere in this file) appropriate? https://github.com/rust-lang/rust/blob/46ec74e60f238f694b46c976d6217e7cf8d4cf1a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs#L537-L565
2020-05-23iterate List by valueBastian Kauschke-11/+9
2020-05-23take predicates by value instead of by referenceBastian Kauschke-22/+22
2020-05-22Use `mk_trait_obligation_with_new_self_ty` for new suggestionDylan MacKenzie-7/+6
2020-05-22Bail out if `output_ty` has bound variablesDylan MacKenzie-5/+9
2020-05-22Document invariants of `mk_trait_obligation_with_new_self_ty`Dylan MacKenzie-0/+4
2020-05-22Ensure that `new_self_ty` has no escaping bound varsDylan MacKenzie-0/+2
Otherwise inserting it to the `Binder` used by `trait_ref` would cause problems. This is just to be extra carefult: we aren't going to start recommending that the user start using HKTs anytime soon.
2020-05-22Preserve substitutions when trying to prove trait obligationDylan MacKenzie-33/+35
`mk_obligation_for_def_id` is only correct if the trait and self type do not have any substitutions. Use a different method, `mk_trait_obligation_with_new_self_ty` that is more clear about what is happening.
2020-05-22Use `OnceCell` instead of `Once`Dylan MacKenzie-7/+6