Commit Graph

1967 Commits

Author SHA1 Message Date
Michael Goulet
0c09e2bf5a Substitute things correctly 2022-12-21 06:06:46 +00:00
Michael Goulet
c8ebff6aee Remove some unnecessary try_map_bound 2022-12-21 06:06:46 +00:00
Dylan DPC
3350ae9cef
Rollup merge of #105882 - compiler-errors:issue-105832, r=jackh726
Don't ICE in closure arg borrow suggestion

Fixes #105832
2022-12-19 14:41:36 +05:30
Dylan DPC
90035f130e
Rollup merge of #105839 - LegionMammal978:mut-upvar-not-send, r=lcnr
Suggest a `T: Send` bound for `&mut T` upvars in `Send` generators

Right now, we suggest a `T: Sync` bound for both `&T` and `&mut T` upvars. A user on URLO [found this confusing](https://users.rust-lang.org/t/error-complains-about-missing-sync-but-send-is-whats-missing/86021), so I wrote this quick fix to look at the mutability before making the suggestion.
2022-12-19 14:41:35 +05:30
Matthias Krüger
ebe3563764
Rollup merge of #105873 - matthiaskrgr:clippy_fmt, r=Nilstrieb
use &str / String literals instead of format!()
2022-12-18 23:03:07 +01:00
Matthias Krüger
221e71e7a1
Rollup merge of #105869 - matthiaskrgr:clone_on_copy, r=compiler-errors
don't clone Copy types
2022-12-18 23:03:07 +01:00
Matthias Krüger
e96166eb42
Rollup merge of #105867 - matthiaskrgr:rec_param, r=compiler-errors
remove redundant fn params that were only "used" in recursion
2022-12-18 23:03:06 +01:00
Michael Goulet
dd8897eb63 Don't ICE in closure arg borrow suggestion 2022-12-18 21:41:29 +00:00
Matthias Krüger
22379779b5
Rollup merge of #105875 - matthiaskrgr:needless_borrowed_reference, r=oli-obk
don't destuct references just to reborrow
2022-12-18 18:57:05 +01:00
Matthias Krüger
a108d55ce6 don't restuct references just to reborrow 2022-12-18 17:04:32 +01:00
Matthias Krüger
0aa4cde747 avoid .into() conversion to identical types 2022-12-18 16:20:32 +01:00
Matthias Krüger
3af7df91fc use &str / String literals instead of format!() 2022-12-18 16:17:46 +01:00
Matthias Krüger
6e52a0f421 remove redundant fn params that were only "used" in recursion 2022-12-18 14:27:07 +01:00
Matthias Krüger
fec9e9ecf1 don't clone Copy types 2022-12-18 14:25:55 +01:00
Matthew House
ee53452aec Suggest a T: Send bound for &mut T upvars in Send generators 2022-12-17 15:21:37 -05:00
bors
a803f313fd Auto merge of #105717 - compiler-errors:anonymize, r=jackh726
always use `anonymize_bound_vars`

Unless this is perf-sensitive, it's probably best to always use one anonymize function that does the right thing for all bound vars.

r? types
2022-12-16 06:45:08 +00:00
bors
39b2a41b39 Auto merge of #104334 - compiler-errors:ufcs-sugg-wrong-def-id, r=estebank
Use impl's def id when calculating type to specify in UFCS

Fixes #104327
Fixes #104328

Also addresses https://github.com/rust-lang/rust/pull/102670#discussion_r987381197
2022-12-16 03:57:10 +00:00
Matthias Krüger
abfad27fbc
Rollup merge of #105727 - estebank:use-impl-trait, r=oli-obk
Tweak output for bare `dyn Trait` in arguments

Fix #35825.
2022-12-15 22:02:59 +01:00
Matthias Krüger
24e584b991
Rollup merge of #105694 - ouz-a:issue_105689, r=estebank
Don't create dummy if val has escaping bounds var

Skips creating/pushing obligations if val has escaping bounds vars.

Fixes #105689
2022-12-15 22:02:59 +01:00
Esteban Küber
2492235c32 Consider lifetimes when comparing assoc types in method chain
Do not say "Type changed to X here" when the only difference is caused
by lifetimes.
2022-12-15 11:47:40 -08:00
Esteban Küber
30ae261c42 Use with_forced_trimmed_paths more 2022-12-15 11:13:44 -08:00
Esteban Küber
294944dfec Point at method chains on E0271 errors 2022-12-15 11:13:44 -08:00
bors
984eab57f7 Auto merge of #105746 - matthiaskrgr:rollup-sz3grbv, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #104592 (Ensure async trait impls are async (or otherwise return an opaque type))
 - #105623 (Fix `-Z print-type-sizes` for generators with discriminant field ordered first)
 - #105627 (Auto traits in `dyn Trait + Auto` are suggestable)
 - #105633 (Make `report_projection_error` more `Term` agnostic)
 - #105683 (Various cleanups to dest prop)
 - #105692 (Add regression test for #104678)
 - #105707 (rustdoc: remove unnecessary CSS `kbd { cursor: default }`)
 - #105715 (Do not mention long types in E0599 label)
 - #105722 (more clippy::complexity fixes)
 - #105724 (rustdoc: remove no-op CSS `.scrape-example .src-line-numbers { margin: 0 }`)
 - #105730 (rustdoc: remove no-op CSS `.item-info:before { color }`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-15 14:04:24 +00:00
Matthias Krüger
78cf8cc02e
Rollup merge of #105633 - compiler-errors:term-agnostic, r=oli-obk
Make `report_projection_error` more `Term` agnostic

Fixes #105632
2022-12-15 12:46:01 +01:00
bors
397b66e77b Auto merge of #105285 - compiler-errors:conflicting-param-env-2, r=estebank
Highlight conflicting param-env candidates, again

Un-reverts #98794 (i.e. reverts #99290).

The previous time I attempted to land this PR, it was because of an incremental issue (#99233). The repro instructions in the issue is no longer manifest the ICE -- I think it's because this ambiguity code was refactored (I think by `@lcnr)` to no longer store the ambiguities in the fulfillment error, but instead recompute them on the fly.

The main motivation for trying to re-land this is that it fixes #105131 by highlighting the root-cause of the issue, which is conflicting param-env candidates:

```
error[E0283]: type annotations needed: cannot satisfy `Self: Gen<'source>`
   |
note: multiple `impl`s or `where` clauses satisfying `Self: Gen<'source>` found
  --> $DIR/conflicting-bounds.rs:3:1
   |
LL | pub trait Gen<'source> {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL |         Self: for<'s> Gen<'s, Output = T>;
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0283`.
```

Fixes #105131.
Fixes (again) #98786
2022-12-15 11:11:49 +00:00
Esteban Küber
124f19485d Tweak output for bare dyn Trait in arguments
Fix #35825.
2022-12-14 18:51:55 -08:00
Michael Goulet
3eb5b62898 always use anonymize_bound_vars 2022-12-14 20:06:25 +00:00
Michael Goulet
34d194d41c Highlight conflicting param-env candidates, again 2022-12-14 18:44:26 +00:00
Michael Goulet
7bf36de6ab Make report_projection_error more term agnostic 2022-12-14 18:32:31 +00:00
Michael Goulet
1225a65389 drive-by: Fix path spans 2022-12-14 18:26:09 +00:00
Michael Goulet
ae60015e76 Use impl's def id when calculating type to specify UFCS 2022-12-14 18:26:09 +00:00
Oli Scherer
9f6ae8828e Fix a freshly detected wrong TraitRef 2022-12-14 15:36:39 +00:00
Oli Scherer
6af3638709 Prevent the creation of TraitRef without dedicated methods 2022-12-14 15:36:39 +00:00
Oli Scherer
a5cd3bde95 Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
Oli Scherer
1bf80249ae Remove many more cases of mk_substs_trait that can now use the iterator scheme` 2022-12-14 15:36:39 +00:00
Oli Scherer
7fd9beedc2 Rename to match similar methods 2022-12-14 15:36:39 +00:00
Oli Scherer
fef872a875 Guard AliasTy creation against passing the wrong number of substs 2022-12-14 15:36:39 +00:00
ouz-a
75cf31faa8 skip if val has ecaping bound vars 2022-12-14 14:05:44 +03:00
Matthias Krüger
939880ab72
Rollup merge of #105595 - TaKO8Ki:suggest-dereferencing-receiver-argument, r=compiler-errors
Suggest dereferencing receiver arguments properly

Fixes #105429
2022-12-14 10:31:07 +01:00
Matthias Krüger
e5fde968db
Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errors
Suggest `collect`ing into `Vec<_>`

Fix #105510.
2022-12-14 10:31:07 +01:00
bors
918d0ac38e Auto merge of #104986 - compiler-errors:opaques, r=oli-obk
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias`

Implements https://github.com/rust-lang/types-team/issues/79.

This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so:

```
enum AliasKind {
  Projection,
  Opaque,
}

struct AliasTy<'tcx> {
  def_id: DefId,
  substs: SubstsRef<'tcx>,
}
```

Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example:

```diff
  match ty.kind() {
-   ty::Opaque(..) =>
+   ty::Alias(ty::Opaque, ..) => {}
    _ => {}
  }
```

This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically.

r? `@ghost`
2022-12-14 01:19:24 +00:00
bors
21ee03e062 Auto merge of #105667 - matthiaskrgr:rollup-fexlc0b, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #105147 (Allow unsafe through inline const)
 - #105438 (Move some codegen-y methods from `rustc_hir_analysis::collect` -> `rustc_codegen_ssa`)
 - #105464 (Support #[track_caller] on async closures)
 - #105476 (Change pattern borrowing suggestions to be verbose and remove invalid suggestion)
 - #105500 (Make some diagnostics not depend on the source of what they reference being available)
 - #105628 (Small doc fixes)
 - #105659 (Don't require owned data in `MaybeStorageLive`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-13 22:05:28 +00:00
Takayuki Maeda
19fa5b381c suggest dereferencing receiver arguments properly
fix a stderr
2022-12-14 03:48:54 +09:00
Esteban Küber
3e25bcb020 Mention implementations that satisfy the trait 2022-12-13 10:39:44 -08:00
Esteban Küber
b3fba5e18a Remove unnecessary code and account for turbofish suggestion
Remove previously existing fallback that tried to give a good turbofish
suggestion, `need_type_info` is already good enough.

Special case `::<Vec<_>` suggestion for `Iterator::collect`.
2022-12-13 10:39:44 -08:00
Michael Goulet
fbe66a6ef3 Address nits
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-12-13 17:56:04 +00:00
Michael Goulet
96cb18e864 Combine identical alias arms 2022-12-13 17:48:55 +00:00
Michael Goulet
61adaf8187 Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
Michael Goulet
c13bd83528 squash OpaqueTy and ProjectionTy into AliasTy 2022-12-13 17:40:27 +00:00
Michael Goulet
5c6afb850c ProjectionTy.item_def_id -> ProjectionTy.def_id 2022-12-13 17:34:44 +00:00