Commit Graph

3125 Commits

Author SHA1 Message Date
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
Matthias Krüger
76d0b794cb
Rollup merge of #116452 - cjgillot:noassert-erased, r=oli-obk
Do not assert that hidden types don't have erased regions.

cc https://github.com/rust-lang/rust/issues/116306

`args` can have erased regions.
In the linked issue, this is reached by computing whether a large type is `Freeze` to compute its ABI.

I do not have a minimized test to include.
2023-10-05 19:24:35 +02:00
Camille GILLOT
14c846cb05 Do not assert that hidden types don't have erased regions. 2023-10-05 15:50:36 +00:00
bors
b781645332 Auto merge of #116184 - compiler-errors:afit-lint, r=tmandry
Add `async_fn_in_trait` lint

cc https://github.com/rust-lang/rust/pull/115822#issuecomment-1731168465

Mostly unsure what the messaging should be. Feedback required.

r? `@tmandry`
2023-10-05 01:14:25 +00:00
bors
afe67fa2ef Auto merge of #116370 - nnethercote:more-arena-stuff, r=cjgillot
Remove the `TypedArena::alloc_from_iter` specialization.

It was added in #78569. It's complicated and doesn't actually help
performance.

r? `@cjgillot`
2023-10-04 22:32:46 +00:00
Esteban Küber
8d92c996ca Fix test on WASM target by making ambiguity pruning more agressive 2023-10-04 18:58:06 +00:00
Esteban Küber
fd3804ab50 Split traits::error_reporting to keep files smaller 2023-10-04 02:19:09 +00:00
Esteban Küber
7313c10774 Show suggestion for <SelfTy as Trait>::assoc_fn in more cases and fmt code 2023-10-04 02:04:14 +00:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
Esteban Küber
2817ece19c Show more information when multiple impl apply 2023-10-04 02:04:13 +00:00
Matthias Krüger
8efbc2cbae
Rollup merge of #116261 - lcnr:wf-only-clause, r=davidtwco
a small wf and clause cleanup

- remove `Clause::from_projection_clause`, instead use `ToPredicate`
- change `predicate_obligations` to directly take a `Clause`
- remove some unnecessary `&`
- use clause in `min_specialization` checks where easily applicable
2023-10-03 16:24:15 +02:00
bors
e3c631b3de Auto merge of #116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #115863 (Add check_unused_messages in tidy)
 - #116210 (Ensure that `~const` trait bounds on associated functions are in const traits or impls)
 - #116358 (Rename both of the `Match` relations)
 - #116371 (Remove unused features from `rustc_llvm`.)
 - #116374 (Print normalized ty)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-03 11:49:06 +00:00
Matthias Krüger
12e4c780ee
Rollup merge of #116358 - compiler-errors:match, r=lcnr
Rename both of the `Match` relations

Both of these names kinda were ambiguous.

r? lcnr
2023-10-03 12:24:12 +02:00
bors
eb0f3ed59c Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR

This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205

Addresses https://github.com/rust-lang/rust/issues/112651

r? `@lcnr`
2023-10-03 10:02:52 +00:00
Nicholas Nethercote
a2051dd578 Optimize some alloc_from_iter call sites.
There's no need to collect an iterator into a `Vec`, or to call
`into_iter` at the call sites.
2023-10-03 18:12:37 +11:00
Michael Goulet
ec79720c1e Add async_fn_in_trait lint 2023-10-03 00:37:18 +00:00
Michael Goulet
07851679cd Point out the actual mismatch error 2023-10-02 23:14:29 +00:00
Michael Goulet
8be12f4ed7 For a single impl candidate, try to unify it with error trait ref 2023-10-02 23:14:29 +00:00
Michael Goulet
2ffaeb5110 Rename both of the Match relations 2023-10-02 21:06:09 +00:00
ouz-a
6f0c5ee2d4 change is_subtype to relate_types 2023-10-02 23:39:45 +03:00
lcnr
a4f6770d83 a small wf and clause cleanup 2023-09-29 11:34:50 +02:00
bors
60bb5192d1 Auto merge of #115843 - lcnr:bb-provisional-cache, r=compiler-errors
new solver: remove provisional cache

The provisional cache is a performance optimization if there are large, interleaving cycles. Such cycles generally do not exist. It is incredibly complex and unsound in all trait solvers which have one: the old solver, chalk, and the new solver ([link](https://github.com/rust-lang/rust/blob/master/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs)).

Given the assumption that it is not perf-critical and also incredibly complex, remove it from the new solver, only checking whether a goal is on the stack. While writing this, I uncovered two additional soundness bugs, see the inline comments for them.

r? `@compiler-errors`
2023-09-29 02:09:40 +00:00
Matthias Krüger
fd95627134 fix clippy::{redundant_guards, useless_format} 2023-09-27 23:49:15 +02:00
Michael Goulet
d6ce9ce115 Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
Camille GILLOT
26cb34cd18 Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
Camille GILLOT
ded1a8b026 Remove dead code. 2023-09-24 09:05:31 +00:00
Camille GILLOT
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Camille GILLOT
286502c9ed Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
Camille GILLOT
ff03204365 Fold lifetimes before substitution. 2023-09-23 13:15:15 +00:00
Michael Goulet
79d685325c Check types live across yields in generators too 2023-09-23 04:19:14 +00:00
Michael Goulet
c21867f9f6 Check that closure's by-value captures are sized 2023-09-23 04:19:14 +00:00
bors
b757318718 Auto merge of #115920 - Zoxc:depkind-u16, r=cjgillot
Move `DepKind` to `rustc_query_system` and define it as `u16`

This moves the `DepKind` type to `rustc_query_system` where it's defined with an inner `u16` field. This decouples it from `rustc_middle` and is a step towards letting other crates define dep kinds. It also allows some type parameters to be removed. The `DepKind` trait is replaced with a `Deps` trait. That's used when some operations or information about dep kinds which is unavailable in `rustc_query_system` are still needed.

r? `@cjgillot`
2023-09-22 00:46:13 +00:00
bors
99b63d068b Auto merge of #115897 - eduardosm:check-fn-sig, r=compiler-errors
rustc_hir_analysis: add a helper to check function the signature mismatches

This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.

This is the first time I do anything with rustc_hir_analysis/rustc_hir_typeck, so comments and suggestions about things I did wrong or that could be improved will be appreciated.
2023-09-21 22:59:13 +00:00
Michael Goulet
9072415252 Suggest desugaring to RPITIT when AFIT is required to be an auto trait 2023-09-21 19:18:14 +00:00
Michael Goulet
087a571e70 Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
John Kåre Alsaker
1806efe7f2 Move DepKind to rustc_query_system and define it as u16 2023-09-21 17:06:14 +02:00
lcnr
614760f612 review 2023-09-21 08:57:47 +02:00
lcnr
8167a25e4e w 2023-09-21 08:44:12 +02:00
lcnr
8e139eefaf slight refactor, add comment 2023-09-21 08:40:36 +02:00
lcnr
8024c69c29 HACK: avoid hang in structurally_normalize 2023-09-21 08:17:58 +02:00
lcnr
de53877f8b proof trees: use for intercrate_ambiguity_causes 2023-09-21 08:17:58 +02:00
Ziru Niu
3c69a107d0 remove impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> 2023-09-20 04:03:02 +08:00
Eduardo Sánchez Muñoz
c599761140 rustc_hir_analysis: add a helper to check function the signature mismatches
This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.
2023-09-19 18:15:23 +02:00
Michael Goulet
976d377f7f Explain HRTB + infer limitations of old solver 2023-09-19 05:14:14 +00:00
bors
cebb9cfd4f Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
2023-09-18 19:41:21 +00:00
lcnr
e8b8ddd17e remove provisional cache 2023-09-18 17:01:29 +02:00
Matthias Krüger
944c4134d2
Rollup merge of #115838 - lcnr:added-goals, r=compiler-errors
inspect: closer to proof trees for coherence

a continuation of #115751. Now explicitly store the added goals

r? ```@compiler-errors```
2023-09-18 13:02:18 +02:00
Nicholas Nethercote
af7d3e501b Remove unused Lift derives.
I found these by commenting out all `Lift` derives and then adding back
the ones that were necessary to successfully compile.
2023-09-18 09:37:10 +10:00
bors
327e6cf55c Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, r=compiler-errors
`#[diagnostic::on_unimplemented]` without filters

This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-17 10:00:15 +00:00
Michael Goulet
280f058560 Canonicalize effect vars in new solver 2023-09-15 05:11:16 +00:00