Commit Graph

82 Commits

Author SHA1 Message Date
Michael Goulet
3e03b1b190 Use a proof tree visitor to refine the Obligation for error reporting 2024-05-02 21:56:14 -04:00
bors
f705de5962 Auto merge of #117164 - fmease:orphan-norm, r=lcnr
Lazily normalize inside trait ref during orphan check & consider ty params in rigid alias types to be uncovered

Fixes #99554, fixes rust-lang/types-team#104.
Fixes #114061.

Supersedes #100555.

Tracking issue for the future compatibility lint: #124559.

r? lcnr
2024-04-30 20:51:46 +00:00
León Orell Valerian Liehr
951e902562
Normalize trait ref before orphan check & consider ty params in alias types to be uncovered 2024-04-30 21:54:54 +02:00
Oli Scherer
aef0f4024a Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
Oli Scherer
c0a9c8c954 Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls 2024-04-09 10:23:58 +00:00
Guillaume Gomez
cb6a1c8d45
Rollup merge of #122894 - compiler-errors:downgrade, r=lcnr
Move check for error in impl header outside of reporting

Fixes #121006

r? lcnr

test location kinda sucks, can move it if needed
2024-04-05 16:38:49 +02:00
Michael Goulet
08c7ff2264 Restrict const ty's regions to static when putting them in canonical var list 2024-03-28 12:30:52 -04:00
Michael Goulet
5333f2a9d1 Move check for error in impl header outside of reporting 2024-03-22 17:46:40 -04:00
Boxy
8124b26122 update region debug formatting 2024-03-18 16:44:12 +00:00
Michael Goulet
01e6b43a07 Mark some next-solver-behavior tests explicitly with revisions 2024-03-10 23:23:46 -04:00
Michael Goulet
383051092f Ignore tests w/ current/next revisions from compare-mode=next-solver 2024-03-10 21:18:41 -04:00
Oli Scherer
8206cffc48 Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
Santiago Pastorino
23ae3dbb31
Make infer higher ranked equate use bidirectional subtyping in invariant context 2024-02-29 15:27:56 -03:00
lcnr
2c7ede8f52 update tests 2024-02-26 10:57:46 +01:00
Esteban Küber
caa216d245 Tweak wording of "implemented trait isn't imported" suggestion 2024-02-22 18:05:27 +00:00
lcnr
5fb67e2ad4 some type system cleanup 2024-02-20 20:42:10 +01:00
Nilstrieb
930566fe1a
Rollup merge of #121308 - kadiwa4:test_103369, r=TaKO8Ki
Add regression test for #103369

The issue was fixed in 1.70.0.
Closes #103369.
2024-02-20 07:35:48 +01:00
Nilstrieb
5b8b435d5d
Rollup merge of #120716 - spastorino:change-some-lint-msgs, r=lcnr
Change leak check and suspicious auto trait lint warning messages

The leak check lint message "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" is misleading as some cases may not be phased out and could end being accepted. This is under discussion still.

The suspicious auto trait lint the change in behavior already happened, so the new message is probably more accurate.

r? `@lcnr`

Closes #93367
2024-02-20 07:35:45 +01:00
bors
0395fa387a Auto merge of #121211 - lcnr:nll-relate-handle-infer, r=BoxyUwU
deduplicate infer var instantiation

Having 3 separate implementations of one of the most subtle parts of our type system is not a good strategy if we want to maintain a sound type system  while working on this I already found some subtle bugs in the existing code, so that's awesome 🎉 cc #121159

This was necessary as I am not confident in my nll changes in #119106, so I am first cleaning this up in a separate PR.

r? `@BoxyUwU`
2024-02-19 22:04:58 +00:00
Santiago Pastorino
086463b227
Remove suspicious auto trait lint 2024-02-19 17:41:48 -03:00
Kalle Wachsmuth
7fd7b47c1f
regression test for #103369 2024-02-19 18:16:11 +01:00
Santiago Pastorino
eee9d2a773
Change leak check lint message to behavior is likely to change in the future 2024-02-18 19:16:17 -03:00
lcnr
88a559fa9f move ty var instantiation into the generalize module 2024-02-17 01:42:36 +01:00
Michael Goulet
228441dbd6 Use fulfillment in next trait solver coherence 2024-02-16 23:53:09 +00:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Oli Scherer
5f6390f947 Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
Oli Scherer
4661c83530 Avoid accessing the HIR in the happy path of coherent_trait 2024-02-09 20:12:02 +00:00
bors
870a01a30e Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebank
Stop bailing out from compilation just because there were incoherent traits

fixes #120343

but also has a lot of "type annotations needed" fallout. Some are fixed in the second commit.
2024-02-08 05:01:09 +00:00
r0cky
c7519d42c2 Update tests 2024-02-07 10:42:01 +08:00
Oli Scherer
83738a9b1c Stop bailing out from compilation just because there were incoherent traits 2024-02-05 10:17:31 +00:00
Michael Goulet
8abf133c4b Make inductive cycles in coherence ambiguous always 2024-01-08 15:03:59 +00:00
Michael Goulet
807cd85dfa Add higher_ranked to relate submodule 2023-12-15 18:13:40 +00:00
Michael Goulet
5b0b7cd8f9 Move type relations into submodule in rustc_infer 2023-12-15 18:13:40 +00:00
lcnr
11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01:00
surechen
40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Michael Goulet
3448284f8d Continue folding if deep normalizer fails 2023-12-05 16:55:10 +00:00
Michael Goulet
334577f091 Add deeply_normalize_for_diagnostics, use it in coherence 2023-12-05 16:33:37 +00:00
lcnr
cf8a2bdd81 rebase 2023-12-04 10:48:00 +01:00
lcnr
407c117e88 cleanup and comments 2023-12-04 10:40:36 +01:00
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Michael Goulet
253f5023c3 Don't require intercrate mode for negative coherence 2023-11-20 18:49:48 +00:00
Michael Goulet
19a5e1dfc6 Don't drop region constraints that come from plugging infer regions with placeholders 2023-11-20 18:49:41 +00:00
Michael Goulet
6388c0ef04
Rollup merge of #118000 - compiler-errors:placeholder-ty-outlives, r=aliemjay
Make regionck care about placeholders in outlives components

Currently, we don't consider a placeholder type `!T` to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for `non_lifetime_binders`, and even more problematic for `with_negative_coherence`, since negative coherence uses placeholders as universals.

This PR adds `Component::Placeholder` which acts much like `Component::Param`. This currently causes a regression in some non-lifetime-binders tests because `for<T> T: 'static` doesn't imply itself when processing outlives obligations, so code like this will fail:

```
fn foo() where for<T> T: 'static {
  foo() //~ fails
}
```

Since the where clause doesn't imply itself. This requires making the `MatchAgainstHigherRankedOutlives` relation smarter when it comes to binders.

r? types
2023-11-19 19:14:35 -08:00
Michael Goulet
488dcb7af3 Ignore but do not assume region obligations from unifying headers in negative coherence 2023-11-19 19:20:02 +00:00
Michael Goulet
8f267e2b87 Make regionck care about placeholders in outlives components 2023-11-19 19:12:20 +00:00
bors
9ab0749ce3 Auto merge of #112875 - compiler-errors:negative-coherence-rework, r=lcnr
Rework negative coherence to properly consider impls that only partly overlap

This PR implements a modified negative coherence that handles impls that only have partial overlap.

It does this by:
1. taking both impl trait refs, instantiating them with infer vars
2. equating both trait refs
3. taking the equated trait ref (which represents the two impls' intersection), and resolving any vars
4. plugging all remaining infer vars with placeholder types

these placeholder-plugged trait refs can then be used normally with the new trait solver, since we no longer have to worry about the issue with infer vars in param-envs.

We use the **new trait solver** to reason correctly about unnormalized trait refs (due to deferred projection equality), since this avoid having to normalize anything under param-envs with infer vars in them.

This PR then additionally:
* removes the `FnPtr` knowable hack by implementing proper negative `FnPtr` trait bounds for rigid types.

---

An example:

Consider these two partially overlapping impls:

```
impl<T, U> PartialEq<&U> for &T where T: PartialEq<U> {}
impl<F> PartialEq<F> for F where F: FnPtr {}
```

Under the old algorithm, we would take one of these impls and replace it with infer vars, then try unifying it with the other impl under identity substitutions. This is not possible in either direction, since it either sets `T = U`, or tries to equate `F = &?0`.

Under the new algorithm, we try to unify `?0: PartialEq<?0>` with `&?1: PartialEq<&?2>`. This gives us `?0 = &?1 = &?2` and thus `?1 = ?2`. The intersection of these two trait refs therefore looks like: `&?1: PartialEq<&?1>`. After plugging this with placeholders, we get a trait ref that looks like `&!0: PartialEq<&!0>`, with the first impl having substs `?T = ?U = !0` and the second having substs `?F = &!0`[^1].

Then we can take the param-env from the first impl, and try to prove the negated where clause of the second.

We know that `&!0: !FnPtr` never holds, since it's a rigid type that is also not a fn ptr, we successfully detect that these impls may never overlap.

[^1]: For the purposes of this example, I just ignored lifetimes, since it doesn't really matter.
2023-10-26 10:57:21 +00:00
Oli Scherer
beaf46f7e5 Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
Michael Goulet
0626f2e7d0 nits 2023-10-23 23:35:27 +00:00
Michael Goulet
e1edefc137 coherence doesn't like region constraints 2023-10-23 23:35:27 +00:00
Michael Goulet
1d99ddbfe8 Consider regions 2023-10-23 23:35:27 +00:00