about summary refs log tree commit diff
path: root/src/test/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2020-04-30Rollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasperDylan DPC-2/+2
extend NLL checker to understand `'empty` combined with universes This PR extends the NLL region checker to understand `'empty` combined with universes. In particular, it means that the NLL region checker no longer considers `exists<R2> { forall<R1> { R1: R2 } }` to be provable. This is work towards https://github.com/rust-lang/rust/issues/59490, but we're not all the way there. One thing in particular it does not address is error messages. The modifications to the NLL region inference code turned out to be simpler than expected. The main change is to require that if `R1: R2` then `universe(R1) <= universe(R2)`. This constraint follows from the region lattice (shown below), because we assume then that `R2` is "at least" `empty(Universe(R2))`, and hence if `R1: R2` (i.e., `R1 >= R2` on the lattice) then `R1` must be in some universe that can name `'empty(Universe(R2))`, which requires that `Universe(R1) <= Universe(R2)`. ``` static ----------+-----...------+ (greatest) | | | early-bound and | | free regions | | | | | scope regions | | | | | empty(root) placeholder(U1) | | / | | / placeholder(Un) empty(U1) -- / | / ... / | / empty(Un) -------- (smallest) ``` I also made what turned out to be a somewhat unrelated change to add a special region to represent `'empty(U0)`, which we use (somewhat hackily) to indicate well-formedness checks in some parts of the compiler. This fixes #68550. I did some investigation into fixing the error message situation. That's a bit trickier: the existing "nice region error" code around placeholders relies on having better error tracing than NLL currently provides, so that it knows (e.g.) that the constraint arose from applying a trait impl and things like that. I feel like I was hoping *not* to do such fine-grained tracing in NLL, and it seems like we...largely...got away with that. I'm not sure yet if we'll have to add more tracing information or if there is some sort of alternative. It's worth pointing out though that I've not kind of shifted my opinion on whose job it should be to enforce lifetimes: I tend to think we ought to be moving back towards *something like* the leak-check (just not the one we *had*). If we took that approach, it would actually resolve this aspect of the error message problem, because we would be resolving 'higher-ranked errors' in the trait solver itself, and hence we wouldn't have to thread as much causal information back to the region checker. I think it would also help us with removing the leak check while not breaking some of the existing crates out there. Regardless, I think it's worth landing this change, because it was relatively simple and it aligns the set of programs that NLL accepts with those that are accepted by the main region checker, and hence should at least *help* us in migration (though I guess we still also have to resolve the existing crates that rely on leak check for coherence). r? @matthewjasper
2020-04-20Ensure tail expression will have a `Ty` for E0746Esteban Küber-8/+17
When the return type is `!Sized` we look for all the returned expressions in the body to fetch their types and provide a reasonable suggestion. The tail expression of the body is normally evaluated after checking whether the return type is `Sized`. Changing the order of the evaluation produces undesirable knock down effects, so we detect the specific case that newcomers are likely to encounter ,returning a single bare trait object, and only in that case we evaluate the tail expression's type so that the suggestion will be accurate.
2020-04-20Suggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't returnEsteban Küber-9/+21
During development, a function could have a return type set that is a bare trait object by accident. We already suggest using either a boxed trait object or `impl Trait` if the return paths will allow it. We now do so too when there are *no* return paths or they all resolve to `!`. We still don't handle cases where the trait object is *not* the entirety of the return type gracefully.
2020-04-16reserve variable for empty root regionNiko Matsakis-2/+2
2020-04-11rustc: Add a warning count upon completionRoccoDev-3/+7
2020-04-10Rollup merge of #69745 - estebank:predicate-obligations-3, r=nikomatsakis,eddybMazdak Farrokhzad-3/+3
Use `PredicateObligation`s instead of `Predicate`s Keep more information about trait binding failures. Use more specific spans by pointing at bindings that introduce obligations. Subset of #69709. r? @eddyb
2020-04-08Small tweaks to required bound spanEsteban Küber-3/+3
2020-04-08Suggest move for closures and async blocks in more cases.Alex Aktsipetrov-14/+14
2020-04-05Use smaller span for suggestion restricting lifetimeEsteban Küber-1/+1
2020-04-02tests: remove ignore directives from tests that mention core/alloc/std spans.Eduard-Mihai Burtescu-8/+3
2020-03-30Rollup merge of #70546 - lqd:polonius_update, r=nikomatsakisDylan DPC-2/+5
Polonius: update to 0.12.1, fix more move errors false positives, update test expectations This PR: - updates `polonius-engine` to version 0.12.1 to fix some move errors false positives - fixes a fact generation mistake creating the other move errors false positives - updates the test expectations for the polonius compare-mode so that all (minus the 2 OOMs) ui tests pass again (matching the [analysis doc](https://hackmd.io/CjYB0fs4Q9CweyeTdKWyEg?view) starting at case 34) In my opinion, this is safe to rollup. r? @nikomatsakis
2020-03-30bless output of ui test impl-trait/multiple-lifetimes/error-handling.rsRemy Rakic-2/+5
Some impl Trait fixes lead to locating more accurately the cause of a universal region error with a user annotation
2020-03-29Tweak `suggest_constraining_type_param`Esteban Küber-10/+8
Some of the bound restriction structured suggestions were incorrect while others had subpar output.
2020-03-22Store idents for `DefPathData` into crate metadataAaron Hill-0/+10
Previously, we threw away the `Span` associated with a definition's identifier when we encoded crate metadata, causing us to lose location and hygiene information. We now store the identifier's `Span` in the crate metadata. When we decode items from the metadata, we combine the name and span back into an `Ident`. This improves the output of several tests, which previously had messages suppressed due to dummy spans. This is a prerequisite for #68686, since throwing away a `Span` means that we lose hygiene information.
2020-03-09Add FIXMEsYuki Okushi-6/+9
2020-03-09Add test for issue-67166Yuki Okushi-0/+22
2020-03-09Add test for issue-60473Yuki Okushi-0/+27
2020-03-09Add test for issue-57201Yuki Okushi-0/+22
2020-03-09Add test for issue-57200Yuki Okushi-0/+22
2020-03-06fix various typosMatthias Krüger-1/+1
2020-02-28keep predicate order and tweak outputEsteban Küber-21/+35
2020-02-28Tweak wordingEsteban Küber-7/+7
2020-02-28Mention the full path of the implementing traitEsteban Küber-7/+7
2020-02-28On single local candidate, use span labelEsteban Küber-14/+21
2020-02-19Tweak binding lifetime suggestion textEsteban Küber-2/+2
We already have a structured suggestion, but the wording made it seem like that wasn't the case. Fix #65286. r? @varkor
2020-02-14Fix and test nested impl TraitMatthew Jasper-0/+16
2020-02-14Update testsMatthew Jasper-19/+118
2020-02-14Handle equal regions in opaque type inferenceMatthew Jasper-0/+57
2020-02-14Update testsMatthew Jasper-46/+168
2020-02-14Call `is_freeze` less in unsafety-checkingMatthew Jasper-0/+32
This is to avoid cycles when calling `is_freeze` on an opaque type.
2020-02-14Explain a testMatthew Jasper-2/+9
2020-02-11Auto merge of #68929 - matprec:consistent-issue-references, r=Dylan-DPCbors-3/+3
Make issue references consistent Fixes https://github.com/rust-lang/rust/issues/62976 cc https://github.com/rust-lang/rust/pull/63008 r? @varkor because you reviewed the original pr
2020-02-09Auto merge of #67665 - Patryk27:master, r=zackmdavisbors-5/+10
Improve reporting errors and suggestions for trait bounds Fix #66802 - When printing errors for unsized function parameter, properly point at the parameter instead of function's body. - Improve `consider further restricting this bound` (and related) messages by separating human-oriented hints from the machine-oriented ones.
2020-02-09--bless --compare-mode=nllMatthias Prechtl-3/+3
2020-02-09Improve reporting errors and suggestions for trait boundsPatryk Wychowaniec-5/+10
2020-02-08review commentEsteban Küber-1/+1
2020-02-02Use more appropriate spans on object unsafe traits and provide structured ↵Esteban Küber-2/+8
suggestions when possible
2020-02-02Wording changes to object unsafe trait errorsEsteban Küber-2/+10
Stemming from the thread at https://twitter.com/indygreg/status/1223279056398929920
2020-02-02fix testEsteban Küber-4/+4
2020-02-02Rollup merge of #68760 - Tyg13:compile_fail_ui_test, r=CentrilMazdak Farrokhzad-5/+4
Issue error on `compile-fail` header in UI test Fixes #68732 r? @Centril
2020-02-02compiletest: error if `compile-fail` header in ui test.Tyler Lanphear-5/+4
2020-02-01Deduplicate generator interior typesJonas Schievink-2/+2
2020-01-24Apply `resolve_vars_if_possible` to returned types for more accurate suggestionsEsteban Küber-6/+6
2020-01-24Use more accurate return path spansEsteban Küber-25/+43
No longer suggest `Box::new(if foo { Type1 } else { Type2 })`, instead suggesting `if foo { Box::new(Type1) } else { Box::new(Type2) }`.
2020-01-23Account for `ty::Error` when suggesting `impl Trait` or `Box<dyn Trait>`Esteban Küber-2/+183
2020-01-16Account for object safety when suggesting `Box<dyn Trait>`Esteban Küber-2/+143
2020-01-16review commentsEsteban Küber-4/+11
2020-01-16review commentsEsteban Küber-0/+1
2020-01-16review commentsEsteban Küber-27/+13
2020-01-16Add E0746 explanation to the indexEsteban Küber-1/+1