| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
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.
|
|
|
|
Add long error explanation for E0623
Part of #61137.
r? @Dylan-DPC
|
|
Transition future compat lints to {ERROR, DENY} - Take 2
Follow up to https://github.com/rust-lang/rust/pull/63247 implementing https://github.com/rust-lang/rust/pull/63247#issuecomment-536295992.
- `legacy_ctor_visibility` (ERROR) -- closes #39207
- `legacy_directory_ownership` (ERROR) -- closes #37872
- `safe_extern_static` (ERROR) -- closes #36247
- `parenthesized_params_in_types_and_modules` (ERROR) -- closes #42238
- `duplicate_macro_exports` (ERROR)
- `nested_impl_trait` (ERROR) -- closes #59014
- `ill_formed_attribute_input` (DENY) -- transitions #57571
- `patterns_in_fns_without_body` (DENY) -- transitions #35203
r? @varkor
cc @petrochenkov
|
|
consistent handling of missing sysroot spans
Due to https://github.com/rust-lang/rust/issues/53081, sysroot spans (pointing to code in libcore/libstd/...) fails to print on some x86 runners. This consolidates the ignore directives for that and references the relevant issue.
I also did that for the generated derive-error-span tests -- but there the script and the tests were not entirely in sync any more since https://github.com/rust-lang/rust/pull/64151. Cc @estebank @varkor
|
|
Update some build-pass ui tests to use check-pass where applicable
Helps with issue https://github.com/rust-lang/rust/issues/62277.
|
|
|
|
|
|
|
|
|
|
|
|
Type parameters are referenced in the error message after the previous
few commits (using span label). But when the main error message already
references the very same type parameter it becomes clumsy. Do not show
the additional label in this case as per code review comment by
@estebank.
Also this contains a small style fix.
|
|
Update the tests to reflect changes to how type mismatch errors are
reported (two previous commits).
|
|
Add long error explaination for E0666
In the spirit of the month of spooks, here's a long explanation for E0666 for #61137.
|
|
Don't ICE for completely unexpandable `impl Trait` types
Save the resolution of these types (to themselves) to the typeck tables so that they will eventually reach E0720.
closes #65561
|
|
|
|
|
|
Increase spacing for suggestions in diagnostics
Make the spacing between the code snippet and verbose structured
suggestions consistent with note and help messages.
r? @Centril
|
|
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
|
|
|
Make the spacing between the code snippet and verbose structured
suggestions consistent with note and help messages.
|
|
|
|
Improve error message for APIT with explicit generic arguments
This is disallowed with type or const generics. cc https://github.com/rust-lang/rust/issues/61410.
|
|
This is disallowed with type or const generics.
|
|
|
|
|
|
|
|
r=cramertj
Remove blanket silencing of "type annotation needed" errors
Remove blanket check for existence of other errors before emitting "type annotation needed" errors, and add some eager checks to avoid adding obligations when they refer to types that reference `[type error]` in order to reduce unneeded errors.
Fix #64084.
|
|
|
|
Remove blanket check for existence of other errors before emitting
"type annotation needed" errors, and add some eager checks to avoid
adding obligations when they refer to types that reference
`[type error]` in order to reduce unneded errors.
|
|
|
|
|
|
Give method not found a primary span label
|
|
|
|
|
|
r=varkor
Check impl trait substs when checking for recursive types
closes #64004
|
|
Account for arbitrary self types in E0599
Fix https://github.com/rust-lang/rust/issues/62373
|
|
|
|
This prevents mutual `async fn` recursion
|
|
|
|
|
|
|
|
Currently the default is "inherited" from context, so e.g. `&impl
Foo<Item = dyn Bar>` would default to `&'x impl Foo<Item = dyn Bar +
'x>`, but this triggers an ICE and is not very consistent.
This patch doesn't implement what I expect would be the correct
semantics, because those are likely too complex. Instead, it handles
what I'd expect to be the common case -- where the trait has no
lifetime parameters.
|
|
Object-lifetime-default elision is distinct from other forms of
elision; it always refers to some enclosing lifetime *present in the
surrounding type* (e.g., `&dyn Bar` expands to `&'a (dyn Bar + 'a)`.
If there is no enclosing lifetime, then it expands to `'static`.
Therefore, in an `impl Trait<Item = dyn Bar>` setting, we don't expand
to create a lifetime parameter for the `dyn Bar + 'X` bound. It will
just be resolved to `'static`.
Annoyingly, the responsibility for this resolution is spread across
multiple bits of code right now (`middle::resolve_lifetimes`,
`lowering`). The lowering code knows that the default is for an object
lifetime, but it doesn't know what the correct result would be.
Probably this should be fixed, but what we do now is a surgical fix:
we have it generate a different result for elided lifetimes in a
object context, and then we can ignore those results when figuring out
the lifetimes that are captured in the opaque type.
|
|
|
|
|
|
This commit prohibits return position `impl Trait` types that "inherit
lifetimes" from the parent scope. The intent is to forbid cases that are
challenging until they can be addressed properly.
|
|
Cleanup some surrounding code.
Support resolution of intra doc links in unnamed block scopes.
(Paths from rustdoc now use early resolution and no longer need results of late resolution like all the built ribs.)
Fix one test hitting file path limits on Windows.
|