Commit Graph

154 Commits

Author SHA1 Message Date
bors
83964c156d Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113005 (Don't call `query_normalize` when reporting similar impls)
 - #113064 (std: edit [T]::swap docs)
 - #113138 (Add release notes for 1.71.0)
 - #113217 (resolve typerelative ctors to adt)
 - #113254 (Use consistent formatting in Readme)
 - #113482 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-08 20:56:57 +00:00
Matthias Krüger
48a0d038fa
Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillot
Don't call `query_normalize` when reporting similar impls

Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well.

The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions:

```
error[E0277]: the trait bound `[X; 35]: Default` is not satisfied
 --> /home/gh-compiler-errors/test.rs:4:5
  |
4 |     <[X; 35] as Default>::default();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]`
  |
  = help: the following other types implement trait `Default`:
            &[T]
            &mut [T]
            [T; 32]
            [T; core::::array::{impl#30}::{constant#0}]
            [T; core::::array::{impl#31}::{constant#0}]
            [T; core::::array::{impl#32}::{constant#0}]
            [T; core::::array::{impl#33}::{constant#0}]
            [T; core::::array::{impl#34}::{constant#0}]
          and 27 others
```

So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-08 20:53:27 +02:00
Matthias Krüger
f3f1b0394d
Rollup merge of #113335 - compiler-errors:reveal-opaques-in-new-solver, r=lcnr
Reveal opaques in new solver

We were testing against the wrong reveal mode 😨

Also a couple of misc commits that I don't want to really put in separate prs

r? ``@lcnr``
2023-07-08 15:49:46 +02:00
bors
ce519c5945 Auto merge of #113474 - compiler-errors:rollup-07x1up7, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #113413 (Add needs-triage to all new issues)
 - #113426 (Don't ICE in `resolve_bound_vars` when associated return-type bounds are in bad positions)
 - #113427 (Remove `variances_of` on RPITIT GATs, remove its one use-case)
 - #113441 (miri: check that assignments do not self-overlap)
 - #113453 (Remove unused from_method from rustc_on_unimplemented)
 - #113456 (Avoid calling report_forbidden_specialization for RPITITs)
 - #113466 (Update cargo)
 - #113467 (Fix comment of `fn_can_unwind`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-08 10:46:29 +00:00
Santiago Pastorino
6d80879ab9
Add regression test for RPITITs 2023-07-07 15:58:25 -03:00
Michael Goulet
f55b046931 Normalize opaques during codegen in new solver 2023-07-07 16:02:25 +00:00
Oli Scherer
4c99872efe Require TAITs to be mentioned in the signatures of functions that register hidden types for them 2023-07-07 13:13:18 +00:00
Oli Scherer
9e98feb84c Add some extra information to opaque type cycle errors 2023-07-05 07:43:35 +00:00
bors
cd68ead9ec Auto merge of #113303 - compiler-errors:yeet-chalk, r=lcnr
Remove chalk support from the compiler

Removes chalk (`-Ztrait-solver=chalk`) from the compiler and prunes any dead code resulting from this, mainly:
* Remove the chalk compatibility layer in `compiler/rustc_traits/src/chalk`
* Remove the chalk flag `-Ztrait-solver=chalk` and its `TraitEngine` implementation
* Remove `TypeWellFormedFromEnv` (and its many `bug!()` match arms)
* Remove the chalk migration mode from compiletest
* Remove the `chalkify` UI tests (do we want to keep any of these, but migrate them to `-Ztrait-solver=next`??)

Fulfills rust-lang/types-team#93.

r? `@jackh726`
2023-07-04 09:09:09 +00:00
bors
0130c3a06e Auto merge of #113215 - compiler-errors:rpitit-predicates-tweaks, r=spastorino
Make RPITITs assume/require their parent method's predicates

Removes a FIXME from the `param_env` query where we were manually adding the parent function's predicates to the RPITIT's assumptions.

r? `@spastorino`
2023-07-04 04:24:24 +00:00
Michael Goulet
c6fcbaae0f Remove compare mode 2023-07-03 21:40:04 +00:00
Michael Goulet
810fbf086d Remove chalk from the compiler 2023-07-03 21:40:04 +00:00
Matthias Krüger
ca7e27a71c
Rollup merge of #113182 - compiler-errors:rpit-stricter-captures, r=oli-obk
Error when RPITITs' hidden types capture more lifetimes than their trait definitions

This implements a stricter set of captures rules for RPITITs. They now may only capture:
1. Lifetimes from the impl header (both the self type and any trait substs -- we may want to restrict just to the self type's lifetimes, but the PR makes that easy to do, too)
2. Lifetimes mentioned by the `impl Trait` in the trait method's definition.

Namely, they may not mention lifetimes from the method (early or late) that are not mentioned in the `impl Trait`.

cc #105258 which I think was trying to do this too, though I'm not super familiar with what exactly differs from that or why that one was broken.
cc #112194 (doesn't fix this issue per se, because it's still an open question, but I think this is objectively better than the status quo, and gets us closer to resolving that issue.)

Technically is a fix for the ICE in #108580, but it turns that issue into an error now. We can decide separately whether or not nested RPITITs should capture lifetimes from their parents.

r? ``@oli-obk``
2023-07-01 13:46:01 +02:00
Michael Goulet
b0ab37eb08 Additional wf test 2023-06-30 20:28:34 +00:00
Michael Goulet
a14285ca7e RPITITs inherit method predicates 2023-06-30 20:08:56 +00:00
Matthias Krüger
38e6bba9c1
Rollup merge of #113171 - spastorino:new-rpitit-25, r=compiler-errors
Properly implement variances_of for RPITIT GAT

This fixes some of the issues found by crater run in https://github.com/rust-lang/rust/pull/112988#issuecomment-1610019572

r? ``@compiler-errors``
2023-06-30 08:01:14 +02:00
Matthias Krüger
c8f50ee111
Rollup merge of #113165 - compiler-errors:rpitits-foreign-bounds, r=spastorino
Encode item bounds for `DefKind::ImplTraitPlaceholder`

This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃

Fixes #113155

r? ``@cjgillot``
2023-06-30 08:01:13 +02:00
Matthias Krüger
0b96b25bdf
Rollup merge of #113071 - compiler-errors:no-parent-non-lifetime-args-in-apit, r=eholk
Account for late-bound vars from parent arg-position impl trait

We should be reporting an error like we do for late-bound args coming from a parent APIT.

Fixes #113016
2023-06-30 08:01:13 +02:00
Michael Goulet
8ad5ea7b01 Adapt tests from #105258 2023-06-30 02:39:07 +00:00
Michael Goulet
473c88dfb6 Flip the order of binder instantiation for better diagnostics 2023-06-30 02:17:07 +00:00
Michael Goulet
d567e4f8b6 Error for RPITIT hidden tys that capture more than their trait defn 2023-06-30 02:17:07 +00:00
Santiago Pastorino
a10406318e
Properly implement variances_of for RPITIT GAT 2023-06-29 23:08:32 -03:00
Michael Goulet
0506250f8c Encode item bounds for DefKind::ImplTraitPlaceholder 2023-06-29 16:37:13 +00:00
Michael Goulet
2c33dfea76 Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
Michael Goulet
bfc6ca8207 More tests 2023-06-27 21:36:15 +00:00
Michael Goulet
724f3ff50d migrate lifetime too 2023-06-26 19:14:49 +00:00
Matthias Krüger
6c7575721f
Rollup merge of #113036 - TaKO8Ki:fix-112094, r=compiler-errors
Accept `ReStatic` for RPITIT

Fixes #112094

Regression in 8216b7f229

If there is a better suggestion, I will go with that.
2023-06-25 22:34:32 +02:00
Takayuki Maeda
83722c62b0 accept ReStatic for RPITIT
add an ui test for #112094
2023-06-26 01:11:44 +09:00
Oli Scherer
b323f587fc Handle weak type aliases by immediately resolving them to their aliased type 2023-06-22 15:51:19 +00:00
Oli Scherer
12243ec415 Point to argument/return type instead of the whole function header 2023-06-22 15:00:12 +00:00
Michael Goulet
7563909a28 Liberate bound vars properly when suggesting missing AFIT 2023-06-21 16:32:26 +00:00
Michael Goulet
be68e9e336
Rollup merge of #112596 - compiler-errors:missing-sig-with-rpitit, r=b-naber
Suggest correct signature on missing fn returning RPITIT/AFIT

Add `async` and unpeel the future's output type if the function is async

Fixes #108195
2023-06-19 17:53:34 -07:00
Michael Goulet
d43683f2e9 Treat TAIT equation as always ambiguous in coherence 2023-06-18 22:52:30 +00:00
Oli Scherer
f3b7dd6388 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
Michael Goulet
bc78d0cbf1 Error on unconstrained lifetime in RPITIT 2023-06-14 05:20:31 +00:00
Michael Goulet
dbee24d949 Suggest correct signature on missing fn returning RPITIT/AFIT 2023-06-13 20:41:15 +00:00
Michael Goulet
d80440263c Don't suggest boxing an empty if/else arm 2023-06-11 00:19:56 +00:00
Dylan DPC
ccf99bd769
Rollup merge of #111980 - compiler-errors:unmapped-substs, r=lcnr
Preserve substs in opaques recorded in typeck results

This means that we now prepopulate MIR with opaques with the right substs.

The first commit is a hack that I think we discussed, having to do with `DefiningAnchor::Bubble` basically being equivalent to `DefiningAnchor::Error` in the new solver, so having to use `DefiningAnchor::Bind` instead, lol.

r? `@lcnr`
2023-06-01 11:09:43 +05:30
Michael Goulet
df1c1afdaf Check that RPITs are compatible with the opaques inferred during HIR typeck too 2023-05-31 17:45:45 +00:00
Michael Goulet
00c92bd873 Check nested obligations during coercion unify 2023-05-27 17:37:16 +00:00
Matthias Krüger
39b633ece4
Rollup merge of #111947 - obeis:issue-111943, r=compiler-errors
Add test for RPIT defined with different hidden types with different substs

Close #111943
2023-05-26 08:24:08 +02:00
Obei Sideg
b37cdc67be Add test for RPIT defined with different hidden types with different substs 2023-05-26 00:14:12 +03:00
Michael Goulet
4692375389 Don't print newlines in APITs 2023-05-25 02:45:14 +00:00
Michael Goulet
3db2bcf4eb Remove return type sized check hack from hir typeck 2023-05-18 01:53:01 +00:00
Michael Goulet
795fdf7d61 Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
Michael Goulet
8921391a12 Use error term if missing associated item in new solver 2023-05-16 16:02:17 +00:00
y21
7fe83345ef improve error for impl<..> impl Trait for Type 2023-05-13 10:51:21 +02:00
Dylan DPC
05ca3e31df
Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naber
Note user-facing types of coercion failure

When coercing, for example, `Box<A>` into `Box<dyn B>`, make sure that any failure notes mention *those* specific types, rather than mentioning inner types, like "the cast from `A` to `dyn B`".

I expect end-users are often confused when we skip layers of types and only mention the "innermost" part of a coercion, especially when other notes point at HIR, e.g. #111406.
2023-05-13 11:05:33 +05:30
Oli Scherer
4e92f761fe Use the opaque_types_defined_by query to cheaply check for whether a hidden type may be registered for an opaque type 2023-05-12 10:26:50 +00:00
Michael Goulet
14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00