Commit Graph

10789 Commits

Author SHA1 Message Date
Oli Scherer
7546163335 Improve self-referential diagnostic somewhat 2022-02-03 15:59:34 +00:00
Oli Scherer
d526a8d594 Clean up opaque type obligations in query results 2022-02-03 13:44:29 +00:00
Oli Scherer
d9bb93f3a4 Fix some doctests where the main function returns an opaque type 2022-02-02 17:15:18 +00:00
Oli Scherer
be153f0976 Only prevent TAITs from defining each other, RPIT and async are fine, they only ever have one defining site, and it is ordered correctly around expected and actual type in type comparisons 2022-02-02 15:40:12 +00:00
Oli Scherer
7f608eb9ed Prevent two opaque types in their defining scopes from being defined via the other 2022-02-02 15:40:12 +00:00
Oli Scherer
7a1ccf9a03 Avoid an ICE in the presence of HKL 2022-02-02 15:40:12 +00:00
Oli Scherer
ee2158f1ee run rustfmt 2022-02-02 15:40:12 +00:00
Oli Scherer
59d0bff0e6 Reduce follow-up errors that are not helpful 2022-02-02 15:40:12 +00:00
Oli Scherer
6560d77a53 Bail out early if there already were errors 2022-02-02 15:40:12 +00:00
Oli Scherer
29c8732436 Make the error for opaque types that have no hidden types a bit informative 2022-02-02 15:40:12 +00:00
Oli Scherer
4d2e965106 Make a span more useful 2022-02-02 15:40:12 +00:00
Oli Scherer
5518d1931d Guess head span of async blocks 2022-02-02 15:40:12 +00:00
Oli Scherer
b6d57ecc0b Hide further opaque type errors if items that could constrain the opaque type have errors 2022-02-02 15:40:12 +00:00
Oli Scherer
e4794d9d1b Undo a change that is now unnecessary 2022-02-02 15:40:12 +00:00
Oli Scherer
c564898110 Remove a now-useless field 2022-02-02 15:40:12 +00:00
Oli Scherer
3d4b9b8b8b Remove some unused arguments and update a comment 2022-02-02 15:40:12 +00:00
Oli Scherer
dc36b38526 Make a comment more obvious 2022-02-02 15:40:12 +00:00
Oli Scherer
d3b534b6b5 manual formatting 2022-02-02 15:40:12 +00:00
Oli Scherer
d8c29b3e28 Simplify diff 2022-02-02 15:40:11 +00:00
Oli Scherer
dbda675419 Undo a diff 2022-02-02 15:40:11 +00:00
Oli Scherer
b45fabddfd Inline a function that is only used once 2022-02-02 15:40:11 +00:00
Oli Scherer
d35d1ef4f5 Remove unnecessary field 2022-02-02 15:40:11 +00:00
Oli Scherer
5b49b8e2d5 Remove unnecessary closure in favour of just passing the argument directly 2022-02-02 15:40:11 +00:00
Oli Scherer
fcba8d31c4 Remove the Instantiator now that we don't recurse within it anymore 2022-02-02 15:40:11 +00:00
Oli Scherer
e03edd287e Inline a function that is only ever used in one place 2022-02-02 15:40:11 +00:00
Oli Scherer
22477784a7 Fixup changes that aren't neccessary anymore 2022-02-02 15:40:11 +00:00
Oli Scherer
94d6a9acc9 This can't happen anymore. An opaque type can't end up with itself as its hidden type 2022-02-02 15:40:11 +00:00
Oli Scherer
3146c961fe We're equating hidden types eagerly now 2022-02-02 15:40:11 +00:00
Oli Scherer
7795f6233c Add explanation for early abort in TAIT hidden type computation 2022-02-02 15:40:11 +00:00
Oli Scherer
64c5b9a3d6 Add backcompat hack to support
```rust
fn foo() -> impl MyTrait {
    panic!();
    MyStruct
}

struct MyStruct;
trait MyTrait {}

impl MyTrait for MyStruct {}
```
2022-02-02 15:40:11 +00:00
Oli Scherer
edaf9625fb Clean up leftovers from eager hidden type merging 2022-02-02 15:40:11 +00:00
Oli Scherer
38f50d1ecb Eagerly merge hidden types. 2022-02-02 15:40:11 +00:00
Oli Scherer
a745797142 Stop generating inference vars for nested impl trait and let type equality handle it.
This means we stop supporting the case where a locally defined trait has only a single impl so we can always use that impl (see nested-tait-inference.rs).
2022-02-02 15:40:11 +00:00
Oli Scherer
7bce50c01a Register member constraints on the final merged hidden type
Previously we did this per hidden type candiate, which didn't always have all the information available.
2022-02-02 15:40:11 +00:00
Oli Scherer
0f6e06b7c0 Lazily resolve type-alias-impl-trait defining uses
by using an opaque type obligation to bubble up comparisons between opaque types and other types

Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02 15:40:11 +00:00
Oli Scherer
8d2b598459 More sanity checks 2022-02-02 15:40:10 +00:00
Oli Scherer
f7abc1b6f8 Expose current span to type equality checking in nll 2022-02-02 15:40:10 +00:00
Oli Scherer
4e1a5968f1 Found suspicious comparison of constants 2022-02-02 15:40:10 +00:00
Oli Scherer
bbbdcb327f Update some comments 2022-02-02 15:40:10 +00:00
Oli Scherer
a4c1cec4f8 Add some sanity assertions to make sure we use the opaque types correctly 2022-02-02 15:40:10 +00:00
Oli Scherer
d49b0746f6 Add roll back infrastructure for opaque type caches 2022-02-02 15:40:10 +00:00
bors
dca1e7aa5a Auto merge of #93154 - michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser
debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo.

Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name.

This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name.

NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
2022-02-02 12:37:28 +00:00
Matthias Krüger
344bb59530
Rollup merge of #93560 - steffahn:a_typo, r=petrochenkov
Fix two incorrect "it's" (typos in comments)

Found one of these while reading the documentation online. The other came up because it's in the same file.
2022-02-02 07:11:09 +01:00
Matthias Krüger
c483b9f1bf
Rollup merge of #93559 - danielframpton:link-args-typo, r=oli-obk
Add missing | between print options

The help text for the newly stabilized print option is missing a | between stack-protector-strategies and link-args.
2022-02-02 07:11:08 +01:00
Matthias Krüger
8ede21b09c
Rollup merge of #92788 - estebank:colon-colon, r=cjgillot
Detect `::` -> `:` typo in type argument

When writing `Vec<A:B>`, suggest `Vec<A::B>`.
2022-02-02 07:11:05 +01:00
bors
d5f9c40e6a Auto merge of #93466 - cjgillot:query-dead, r=nagisa
Make dead code check a query.

Dead code check is run for each invocation of the compiler, even if no modifications were involved.
This PR makes dead code check a query keyed on the module. This allows to skip the check when a module has not changed.
To perform this, a query `live_symbols_and_ignored_derived_traits` is introduced to encapsulate the global analysis of finding live symbols. The second query `check_mod_deathness` outputs diagnostics for each module based on this first query's results.
2022-02-02 02:29:32 +00:00
Esteban Kuber
b26ad8d10f Detect :: -> : typo in type argument
When writing `Vec<A:B>`, suggest `Vec<A::B>`.
2022-02-02 01:19:24 +00:00
bors
1ea4851715 Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obk
Continue work on associated const equality

This actually implements some more complex logic for assigning associated consts to values.
Inside of projection candidates, it now defers to a separate function for either consts or
types. To reduce amount of code, projections are now generic over T, where T is either a Type or
a Const. I can add some comments back later, but this was the fastest way to implement it.

It also now finds the correct type of consts in type_of.

---

The current main TODO is finding the const of the def id for the LeafDef.

Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection.
I was hoping to get some help in getting the `&'tcx ty::Const<'tcx>`, in addition to a bunch of other `todo!()`s which I think may not be hit.

r? `@oli-obk`

Updates #92827
2022-02-01 23:18:01 +00:00
Frank Steffahn
63b12aea27 Fix two incorrect "it's" 2022-02-01 22:32:02 +01:00
Daniel Frampton
e22729b464 Add missing | between print options 2022-02-01 12:40:01 -08:00