Commit Graph

21066 Commits

Author SHA1 Message Date
Robin Schroer
f908f0be5a
Consider doc(alias) when providing typo suggestions
This means that

```rust
impl Foo {
    #[doc(alias = "quux")]
    fn bar(&self) {}
}

fn main() {
    (Foo {}).quux();
}
```

will suggest `bar`. This currently uses the "there is a method with a
similar name" help text, because the point where we choose and emit a
suggestion is different from where we gather the suggestions. Changes
have mainly been made to the latter.

The selection code will now fall back to aliased candidates, but
generally only if there is no candidate that matches based on the
existing Levenshtein methodology.

Fixes #83968.
2023-01-23 10:07:10 +09:00
bors
4c83bd03a9 Auto merge of #107038 - compiler-errors:dont-wfcheck-non-local-rpit, r=oli-obk
Don't wf-check non-local RPITs

We were using `ty::is_impl_trait_defn(..).is_none()` to check if we need to add WF obligations for an opaque type.

This is *supposed* to be checking if the type is a TAIT, since RPITs' wfness is implied by wf checking its parent item, but since `is_impl_trait_defn` returns `None` for non-local RPIT and async futures, we unnecessarily consider wf predicates for an RPIT if it is coming from a foreign crate.

Fixes #107036

r? `@oli-obk` but feel free to reassign
2023-01-19 16:49:06 +00:00
Michael Goulet
7e0b1f1115 Conditionally encode boolean 2023-01-19 16:09:10 +00:00
Michael Goulet
200f466d1a Encode whether foreign opaques are TAITs or not 2023-01-19 15:45:49 +00:00
bors
19423b5944 Auto merge of #106910 - aliemjay:alias-ty-in-regionck, r=oli-obk
even more unify Projection/Opaque handling in region outlives code

edit: This continues ate the same pace as #106829. New changes are described in https://github.com/rust-lang/rust/pull/106910#issuecomment-1383251254.

~This touches `OutlivesBound`, `Component`, `GenericKind` enums.~

r? `@oli-obk` (because of overlap with #95474)
2023-01-19 14:05:07 +00:00
Ali MJ Al-Nasrawy
a7a842027c even more unify Projection/Opaque in outlives code 2023-01-19 15:31:53 +03:00
Guillaume Gomez
dee88e0fa2
Rollup merge of #107037 - tmiasko:rank, r=oli-obk
Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-19 11:19:36 +01:00
Guillaume Gomez
246daa49ee
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
document + UI test `E0208` and make its output more user-friendly

Cleans up `E0208`'s output a lot. It could actually be useful for someone learning about variance now. I also added a UI test for it in `tests/ui/error-codes/` and wrote some docs for it.

r? `@GuillaumeGomez` another error code, can't be bothered to find the issue :P. Obviously there's some compiler stuff, so you'll have to hand it off.

Part of https://github.com/rust-lang/rust/issues/61137.
2023-01-19 11:19:35 +01:00
Guillaume Gomez
1a878df2b8
Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank
make `CastError::NeedsDeref` create a `MachineApplicable` suggestion

Fixes #106903

Simple impl for the linked issue. I also made some other small changes:
- `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`.
- `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.
2023-01-19 11:19:34 +01:00
Guillaume Gomez
30ddeefcf0
Rollup merge of #105977 - Swatinem:async-mir-context, r=oli-obk
Transform async `ResumeTy` in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

---

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1330 CC `@bjorn3`

r? `@compiler-errors`
2023-01-19 11:19:34 +01:00
Arpad Borsos
96931a787a
Transform async ResumeTy in generator transform
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-19 09:03:05 +01:00
bors
65d2f2a5f9 Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov
Various cleanups around pre-TyCtxt queries and functions

part of #105462

based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](0e2b39fd1f) is new in this PR)

r? `@petrochenkov`

I think this should be most of the uncontroversial part of #105462.
2023-01-19 05:23:40 +00:00
bors
6ba6d22bdf Auto merge of #107052 - compiler-errors:rollup-vxr22g5, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #105796 (rustdoc: simplify JS search routine by not messing with lev distance)
 - #106753 (Make sure that RPITITs are not considered suggestable)
 - #106917 (Encode const mir for closures if they're const)
 - #107004 (Implement some candidates for the new solver (redux))
 - #107023 (Stop using `BREAK` & `CONTINUE` in compiler)
 - #107030 (Correct typo)
 - #107042 (rustdoc: fix corner cases with "?" JS keyboard command)
 - #107045 (rustdoc: remove redundant CSS rule `#settings .setting-line`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-19 02:09:45 +00:00
Michael Goulet
5d562be33d
Rollup merge of #107030 - albertlarsan68:patch-3, r=lcnr
Correct typo

https://github.com/rust-lang/rust/pull/106718#discussion_r1073508490
2023-01-18 18:00:30 -05:00
Michael Goulet
2eef516b30
Rollup merge of #107023 - scottmcm:stop-shouting, r=Nilstrieb
Stop using `BREAK` & `CONTINUE` in compiler

Switching them to `Break(())` and `Continue(())` instead.

Entirely search-and-replace, though there's one spot where rustfmt insisted on a reformatting too.

libs-api would like to remove these constants (https://github.com/rust-lang/rust/pull/102697#issuecomment-1385705202), so stop using them in compiler to make the removal PR later smaller.
2023-01-18 18:00:30 -05:00
Michael Goulet
cf5068bd62
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
Implement some candidates for the new solver (redux)

Based on #106718, so the diff is hard to read without it. See [here](98700cf481...compiler-errors:rust:new-solver-new-candidates-2) for an easier view until that one lands.

Of note:
* 44af916020fb43c12070125c45b6dee4ec303bbc fixes a bug where we need to make the query response *inside* of a probe, or else we make no inference progress (I think)
* 50daad5acd2f163d03e7ffab942534f09bc36e2e implements `consider_assumption` for traits and predicates. I'm not sure if using `sup` here is necessary or if `eq` is fine.
* We decided that all of the `instantiate_constituent_tys_for_*` functions are verbose but ok, since they need to be exhaustive and the logic between each of them is not similar enough, right?

r? ``@lcnr``
2023-01-18 18:00:29 -05:00
Michael Goulet
a637e2a950
Rollup merge of #106917 - compiler-errors:const-closure-foreign, r=tmiasko
Encode const mir for closures if they're const

Fixes #106913
2023-01-18 18:00:29 -05:00
Michael Goulet
685c77305c
Rollup merge of #106753 - compiler-errors:rpitit-not-suggestable, r=spastorino
Make sure that RPITITs are not considered suggestable

Makes no sense to suggest `where impl Future<Output = ()>: Send`, for example.
2023-01-18 18:00:28 -05:00
bors
8b11574ca0 Auto merge of #107041 - Nilstrieb:back-to-being-clueless-whether-it-really-is-a-literal, r=compiler-errors
Revert "Improve heuristics whether `format_args` string is a source literal"

This reverts commit e6c02aad93 (from #106195).

Keeps the code improvements from the PR and the test (as a known-bug).

Works around #106408 while a proper fix is discussed more thoroughly in #106505, as proposed by `@tmandry.`

Reopens #106191

r? compiler-errors
2023-01-18 22:58:30 +00:00
Nilstrieb
a8086cf9df Revert "Improve heuristics whether format_args string is a source literal"
This reverts commit e6c02aad93.

Keeps the code improvements from the PR and the test (as a known-bug).
2023-01-18 20:33:17 +01:00
Scott McMurray
7d57685682 Also remove #![feature(control_flow_enum)] where possible 2023-01-18 10:22:21 -08:00
bors
6d46b1ec87 Auto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk
Do not filter substs in `remap_generic_params_to_declaration_params`.

The relevant filtering should have been performed by borrowck.

Fixes https://github.com/rust-lang/rust/issues/105826

r? types
2023-01-18 16:37:33 +00:00
Tomasz Miąsko
b8c5821ad8 Fix Dominators::rank_partial_cmp to match documentation
The only use site is also updated accordingly and there is no change in
end-to-end behaviour.
2023-01-18 17:11:43 +01:00
Michael Goulet
f672436f04 Handle structural traits more gracefully 2023-01-18 14:59:15 +00:00
Michael Goulet
34127c5080 no subtyping in the new trait solver 2023-01-18 14:59:15 +00:00
Michael Goulet
685c32fd85 Sized, Copy/Clone 2023-01-18 14:59:15 +00:00
Michael Goulet
45aa5c0f90 Auto and alias traits 2023-01-18 14:59:15 +00:00
Michael Goulet
3d87a8e848 Assemble object bound candidates 2023-01-18 14:28:14 +00:00
Michael Goulet
f99b273d57 implement consider_assumption 2023-01-18 14:28:14 +00:00
Michael Goulet
b84b1da2db Canonicalize trait solver response inside probe 2023-01-18 14:28:14 +00:00
Albert Larsan
5a685a10ec
Correct typo 2023-01-18 14:08:41 +01:00
Dylan DPC
6f5c3c9cdb
Rollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors
finish trait solver skeleton work

### 648d661b4e0fcf55f7082894f577377eb451db4b

The previous implementation didn't remove provisional entries which depended on the current goal if we're forced to rerun in case the provisional result of that entry is different from the new result. For reference, see https://rust-lang.github.io/chalk/book/recursive/search_graph.html.

We should also treat inductive cycles as overflow, not ordinary ambiguity.

### 219a5de2517cebfe20a2c3417bd302f7c12db70c 6a1912be539dd5a3b3c10be669787c4bf0c1868a

These two commits move canonicalization to the start of the queries which simplifies a bunch of stuff. I originally intended to keep stuff canonicalized for a while because I expected us to add a additional caches the trait solver, either for candidate assembly or for projections. We ended up not adding (and expect to not need) any of them so this just ends up being easier to understand.

### d78d5ad0979e965afde6500bccfa119b47063506

adds a special `eq` for the solver which doesn't care about obligations or spans

### 18704e6a78b7703e1bbb3856f015cb76c0a07a06

implements https://rust-lang.zulipchat.com/#narrow/stream/364551-t-types.2Ftrait-system-refactor/topic/projection.20cache

r? `@compiler-errors`
2023-01-18 15:55:38 +05:30
Ezra Shaw
708861e5b7
remove error code from #[rustc_variance] and document its remains 2023-01-18 21:10:27 +13:00
Scott McMurray
925dc37313 Stop using BREAK & CONTINUE in compiler
Switching them to `Break(())` and `Continue(())` instead.

libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17 23:17:51 -08:00
lcnr
369f9aa099 add comment 2023-01-18 08:11:15 +01:00
lcnr
415aa663a2 add note about indirect cycles 2023-01-18 08:11:15 +01:00
lcnr
31ac29d989 update project to emulate a projection cache 2023-01-18 08:11:15 +01:00
lcnr
9a757d6ee4 add eq to InferCtxtExt 2023-01-18 08:11:15 +01:00
lcnr
660c28391c remove assembly context and impl a bit more 2023-01-18 08:11:15 +01:00
lcnr
bf7dbff921 instantiate canonical vars eagerly 2023-01-18 08:11:13 +01:00
lcnr
b738b06160 update cache 2023-01-18 08:09:01 +01:00
Matthias Krüger
9e46c24a90
Rollup merge of #106873 - BoxyUwU:ty_const_formatting, r=compiler-errors
dont randomly use `_` to print out const generic arguments

const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten  very annoying . Latest example would be #106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`.

For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.
2023-01-18 06:59:20 +01:00
Matthias Krüger
d26e07b91a
Rollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank
Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

Fix for issue #105507

The problem:
When generic associated types (GATs) are from higher-ranked trait bounds (HRTB), they are implied 'static requirement (see
[Implied 'static requirement from higher-ranked trait bounds](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#implied-static-requirement-from-higher-ranked-trait-bounds) for more details). If the user did not explicitly specify the `'static` lifetime when using the GAT, the current error message will only point out the type `does not live long enough` where the type is used, but not where the GAT is specified and how to fix the problem.

The solution:
Add notes at the span where the problematic GATs are specified and suggestions of how to fix the problem by adding `'static` lifetime at the right spans.
2023-01-18 06:59:20 +01:00
Boxy
1171fe5c45 i am free 2023-01-18 04:45:43 +00:00
Boxy
a2a50f96f3 actually print out non local anon consts 2023-01-18 04:07:39 +00:00
Boxy
4ca5368a12 defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
Ezra Shaw
b73cdf1b29
special case removing & suggestion 2023-01-18 13:14:56 +13:00
bors
edefa4189f Auto merge of #106998 - matthiaskrgr:rollup-hmfisji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #104505 (Remove double spaces after dots in comments)
 - #106784 (prevent E0512 from emitting [type error] by checking the references_error)
 - #106834 (new trait solver: only consider goal changed if response is not identity)
 - #106889 (Mention the lack of `windows_mut` in `windows`)
 - #106963 (Use `scope_expr_id` from `ProbeCtxt`)
 - #106970 (Switch to `EarlyBinder` for `item_bounds` query)
 - #106980 (Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-17 20:53:05 +00:00
yanchen4791
aadd58ef7a Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB 2023-01-17 11:52:45 -08:00
Matthias Krüger
48bd3ab81d
Rollup merge of #106980 - Nilstrieb:_use_mk_manual_debug_impl_instead, r=lcnr
Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`
2023-01-17 20:21:28 +01:00