about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2019-01-05Rollup merge of #57229 - mikeyhew:fix-56806, r=varkorkennytm-0/+19
Fix #56806 by using `delay_span_bug` in object safety layout sanity checks It's possible that `is_object_safe` is called on a trait method that with an invalid receiver type. This caused an ICE in #56806, because `receiver_is_dispatchable` returns `true` for `self: Box<dyn Trait>`, which causes one of the layout sanity checks in object_safety.rs to fail. Replacing `bug!` with `delay_span_bug` solves this. The fact that `receiver_is_dispatchable` returns `true` here could be considered a bug. It passes the check that the method implements, though: `Box<dyn Trait>` implements `DispatchFromDyn<Box<dyn Trait>>` because `dyn Trait` implements `Unsize<dyn Trait>`. It would be good to hear what @eddyb and @nikomatsakis think. Note that I only added a test for the case encountered in #56806. I could not come up with a case that triggered an ICE from the other check, `bug!("receiver when Self = dyn Trait should be ScalarPair, found Scalar")`. There is no way, to my knowledge, that you can make `receiver_is_dispatchable` return true but still have a `Scalar` ABI when `Self = dyn Trait`. One other case I encountered while debugging #56806 was that if you have a type parameter `T` that implements `Deref<Target=Self>` and `DispatchFromDyn<T>`, and use it as a method receiver, it will cause an ICE during `is_object_safe` because `T` has no layout ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d9b7497b3be0ca8382fa7d9497263214)): ```rust trait Trait<T: Deref<Target=Self> + DispatchFromDyn<T>> { fn foo(self: T) -> dyn Trait<T>; } ``` I don't intend to remove the ICE there because it is a pathological case, especially since there is no way to implement `DispatchFromDyn<T>` for `T` — the checks in typeck/coherence/builtin.rs do not allow that. fixes #56806 r? @varkor
2019-01-05Rollup merge of #57219 - matthewjasper:mir-cleanup, r=nikomatsakiskennytm-15/+9
Remove some unused code Closes #57096
2019-01-05Auto merge of #57145 - RalfJung:panic-if-uninhabited, r=alexcrichtonbors-7/+34
panic when calling MaybeUninhabited::into_inner on uninhabited type I do this by adding an internal-only intrinsic `panic_if_uninhabited`. I have no idea what I am doing here, just mindlessly copying code around, so please review carefully!
2019-01-05Auto merge of #57099 - davidtwco:issue-57098, r=nikomatsakisbors-0/+6
NLL: Add closure cannot be moved note. Fixes #57098. This PR extends existing logic for checking whether a closure that is `FnOnce` and therefore moves variables that it captures from the environment has already been invoked when being invoked again. Now, this logic will also check whether the closure is being moved after previously being moved or invoked and add an appropriate note. r? @pnkfelix
2019-01-05Show suggestion to use .char().nth() and link to The Book on unimplemented ↵folex-0/+4
Index trait
2019-01-05Auto merge of #56837 - arielb1:nonprincipal-trait-objects, r=nikomatsakisbors-73/+343
Add support for trait-objects without a principal The hard-error version of #56481 - should be merged after we do something about the `traitobject` crate. Fixes #33140. Fixes #57057. r? @nikomatsakis
2019-01-05Auto merge of #56145 - weiznich:re_rebalance_coherence, r=nikomatsakisbors-235/+1565
Implement the Re-rebalance coherence RFC This is the first time I touch anything in the compiler so just tell me if I got something wrong. Big thanks to @sgrif for the pointers where to look for those things. cc #55437
2019-01-04use `delay_span_bug` instead of `bug!` when doing layout sanity checkMichael Hewson-0/+19
It's possible that `is_object_safe` is called on a trait that is ill-formed, and we shouldn't ICE unless there are no errors being raised. Using `delay_span_bug` solves this. fixes #56806
2019-01-04Improve diagnostic labels and add note.David Wood-17/+35
This commit improves diagnostic labels to mention which field a borrow overlaps with and adds a note explaining that the fields overlap.
2019-01-04Make conflicting borrow description more robust.David Wood-0/+96
This commit improves the logic for place descriptions in conflicting borrow errors so that borrows of union fields have better messages even when the unions are embedded in other unions or structs.
2019-01-04add test for #57162Ariel Ben-Yehuda-0/+7
Fixes #57162.
2019-01-04Auto merge of #56897 - euclio:parse-fatal, r=estebankbors-14/+220
make `panictry!` private to libsyntax This commit completely removes usage of the `panictry!` macro from outside libsyntax. The macro causes parse errors to be fatal, so using it in libsyntax_ext caused parse failures *within* a syntax extension to be fatal, which is probably not intended. Furthermore, this commit adds spans to diagnostics emitted by empty extensions if they were missing, à la #56491.
2019-01-04force binary filename for compiled doctestsQuietMisdreavus-0/+7
2019-01-04Auto merge of #56074 - matthewjasper:forbid-recursive-impl-trait, r=nikomatsakisbors-8/+222
Forbid recursive impl trait There is no type T, such that `T = [T; 2]`, but impl Trait could sometimes be to circumvented this. This patch makes it a hard error for an opaque type to resolve to such a "type". Before this can be merged it needs - [x] A better error message - it's good enough for now. - [x] A crater run (?) to see if this any real-world code closes #47659
2019-01-04alphabetize marker traits when printedAriel Ben-Yehuda-10/+10
This makes sure they are printed in a compiler-version-independent order, avoiding ui test instability.
2019-01-04Auto merge of #55986 - cjgillot:issue-45510, r=nikomatsakisbors-0/+88
Allow to dispatch fn traits depending on number of parameters Hello, By following @eddyb's advise on issue #45510, I managed to have the snippets of code in #45510 and #18952 passing without breaking older diagnostics. EDIT: the codegen tests breakage I experienced is due to the poor quality of my laptop. If any kind reviewer has any advice, you are very welcome.
2019-01-04Update tests changed by rebaseGeorg Semmler-4/+39
2019-01-03Improve error generation, fixup recursion limitsAaron Hill-77/+7
2019-01-03Fix stack overflow when finding blanket implsAaron Hill-0/+34
Currently, SelectionContext tries to prevent stack overflow by keeping track of the current recursion depth. However, this depth tracking is only used when performing normal section (which includes confirmation). No such tracking is performed for evaluate_obligation_recursively, which can allow a stack overflow to occur. To fix this, this commit tracks the current predicate evaluation depth. This is done separately from the existing obligation depth tracking: an obligation overflow can occur across multiple calls to 'select' (e.g. when fulfilling a trait), while a predicate evaluation overflow can only happen as a result of a deep recursive call stack. Fixes #56701
2019-01-04stabilize convert::identityMazdak Farrokhzad-2/+0
2019-01-04implement a hack to make traitobject 0.1.0 compileAriel Ben-Yehuda-75/+297
2019-01-04add testsAriel Ben-Yehuda-0/+41
2019-01-03Forbid impl Trait from referring to unnamable recursive typesMatthew Jasper-8/+222
There is no type T, such that `T = [T; 2]`, we should not allow this to be circumvented by impl Trait.
2019-01-03More test deduplicationGeorg Semmler-446/+38
2019-01-03Add missing filesGeorg Semmler-127/+1008
2019-01-03Fix typoGeorg Semmler-1/+1
2019-01-03Unify testsGeorg Semmler-2723/+400
Implement compile tests as variants of existing tests
2019-01-03Update some new tests to changed error messagesGeorg Semmler-5/+5
2019-01-03Fix failing compile testsGeorg Semmler-1/+2
2019-01-03Add some testsGeorg Semmler-0/+3144
This copies and adjusts the existing coherence tests to ensure that they continue to work using the new implementation.
2019-01-03Fix repeated word typosWiktor Kuchta-2/+2
Found with `git grep -P '\b([a-z]+)\s+\1\b'`
2019-01-03use structured suggestion for method callsAndy Russell-33/+33
Furthermore, don't suggest calling the method if it is part of a place expression, as this is invalid syntax.
2019-01-03Fix bug in associated constant type annotations.David Wood-0/+43
This commit reverses the variance used when relating types from the type annotation of an associated constant - this matches the behaviour of the lexical borrow checker and fixes a bug whereby matching a `&'a str` against a `&'static str` would produce an error.
2019-01-03Auto merge of #55517 - nikomatsakis:universes, r=scalexmbors-593/+529
Universes This PR transitions the compiler to use **universes** instead of the **leak-check**. It is marked as [WIP] for a few reasons: - The diagnostics at present are terrible =) - This changes the behavior of coherence, regressing some things that used to compile The goals of this PR at present are: - To start getting some eyes on the code - To do a crater run - To see the full travis results (due to https://github.com/rust-lang/rust/issues/52452, I am not able to run the full test suite locally anymore at present) The first few commits in the PR are changing how `evaluate` treats regions. We now track whether region comparisons occurred, reverting the "staticized" query approach that @arielb1 put in. The problem with "staticized" queries is that it relied on the leak-check to get higher-ranked things correct, and we are removing the leak-check in this PR series, so that caused problems. You can see at the end a collection of test updates. Mostly we behave the same but with atrocious diagnostics, but there are a number of cases where we used to error and now no longer do, as well as single case where we used to **not** error but we now do (the coherence-subtyping change). (Note: it would be possible to do a version of leak-check that propagates universe information and recover the old behavior. I am reluctant to do so because I'd like to leave us room to get more precise -- e.g., I want to eventually handle things like `exists<'a> { for<'b> { if ('a: 'b) { 'a: 'b } } }` which presently the leak-check cannot cope with etc. Also because it seems more consistent to me: most folks I've talked to expect the new behavior and are surprised to learn that binding sites were so significant before when it comes to coherence. One question is, though, to what extent are people relying on this in the wild?)
2019-01-03Fix unused_assignments false positiveShotaro Yamada-0/+9
Make `continue` jump to the loop condition's `LiveNode` instead of one of the loop body.
2019-01-02update to reflect changes recommended by @shepmaster his reviewOzaren-16/+9
2019-01-02rename `type_moves_by_default` to `type_is_copy_modulo_regions`Niko Matsakis-1/+1
2019-01-02try to detect affected code and direct people to #56105Niko Matsakis-0/+2
2019-01-02address tmandry nitsNiko Matsakis-63/+14
2019-01-02improve handling for subtypeNiko Matsakis-298/+98
Still not great, but good enough to land this PR.
2019-01-02say "the lifetime" instead of "some lifetime" when it feels rightNiko Matsakis-8/+8
In particular, when we want to indicate that there is a connection between the self type and the other types.
2019-01-02apply the same logic to ConcreteFailure errorsNiko Matsakis-38/+19
2019-01-02apply the new placeholder errors even with just one placeholderNiko Matsakis-45/+40
2019-01-02introduce placeholder-placeholder errors for trait matchingNiko Matsakis-91/+35
2019-01-02WIP other test changesNiko Matsakis-7/+6
2019-01-02tests: cases where we now do the right thing but did not beforeNiko Matsakis-137/+137
Fixes #33684
2019-01-02tests: worse diagnostics, but basically same errorsNiko Matsakis-437/+463
2019-01-02tests: move coherence-subtyping from run-pass to compile-failNiko Matsakis-1/+33
This is the pattern we no longer accept.
2019-01-02add tests exercising `exists<'a> { forall<'b> { .. } }` patternNiko Matsakis-0/+163
Amazingly, this scenario was not tested for trait matching.
2019-01-02select.rs: unsizing coercion should use a subtypeNiko Matsakis-7/+9
When we coerce `dyn Foo` to `dyn Bar`, that is OK as long as `Foo` is usable in all contexts where `Bar` is usable (hence using the source must be a subtype of the target). This is needed for the universe-based code to handle `old-lub-glb-object`; that test used to work sort of by accident before with the old code.