rust/src/test
Aaron Hill 0e2ccaaa3e
Fix 'type annotations needed' error with opaque types
Related: #66426

This commit adds handling for opaque types during inference variable
fallback. Type variables generated from the instantiatino of opaque
types now fallback to the opque type itself.

Normally, the type variable for an instantiated opaque type is either
unified with the concrete type, or with the opaque type itself (e.g when
a function returns an opaque type by calling another function).

However, it's possible for the type variable to be left completely
unconstrained. This can occur in code like this:

```rust
pub type Foo = impl Copy;
fn produce() -> Option<Foo> {
    None
}
```

Here, we'll instantatiate the `Foo` in `Option<Foo>` to a fresh type
variable, but we will never unify it with anything due to the fact
that we return a `None`.

This results in the error message:

`type annotations needed: cannot resolve `_: std::marker::Copy``

pointing at `pub type Foo = impl Copy`.

This message is not only confusing, it's incorrect. When an opaque type
inference variable is completely unconstrained, we can always fall back
to using the opaque type itself. This effectively turns that particular
use of the opaque type into a non-defining use, even if it appears in a
defining scope.
2019-11-18 14:01:36 -05:00
..
assembly
auxiliary
codegen Do not require extra LLVM backends for x.py test to pass 2019-11-04 16:54:34 +03:00
codegen-units Update test output. 2019-10-25 14:52:39 +02:00
compile-fail Bless less verbose error messages 2019-11-13 10:44:14 -08:00
debuginfo fix debuginfo/issue22656 with LLDB 8 2019-09-18 10:42:55 -04:00
incremental Rollup merge of #66216 - wesleywiser:const_prop_codegen_improvements, r=oli-obk 2019-11-10 09:27:17 +09:00
mir-opt Auto merge of #66233 - cjgillot:constkind, r=oli-obk 2019-11-14 04:54:51 +00:00
pretty Fix a previously forgotten pretty-printing test after a change to the pretty-printing mechanism. 2019-10-28 18:43:59 +01:00
run-fail [const-prop] Handle MIR Rvalue::Aggregates 2019-10-18 06:29:57 -04:00
run-make Upgrade Emscripten targets to use upstream LLVM backend 2019-10-16 17:06:48 -07:00
run-make-fulldeps Add a callback that allows compiler consumers to override queries. 2019-11-11 19:29:34 +01:00
run-pass-valgrind
rustdoc Auto merge of #66211 - kinnison:kinnison/fix-66159, r=GuillaumeGomez 2019-11-13 23:22:03 +00:00
rustdoc-js
rustdoc-js-std
rustdoc-ui Rollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=QuietMisdreavus 2019-11-13 22:09:13 +09:00
rustfix
ui Fix 'type annotations needed' error with opaque types 2019-11-18 14:01:36 -05:00
ui-fulldeps Add warning annotations to ignore-stage1 ui-fulldeps tests 2019-11-10 21:00:59 +01:00
COMPILER_TESTS.md