Commit Graph

1892 Commits

Author SHA1 Message Date
Nicholas Nethercote
09af8a667c Rename Session::span_diagnostic as Session::dcx. 2023-12-18 16:06:21 +11:00
Jubilee
c5a3d98cc6
Rollup merge of #119004 - matthiaskrgr:conv, r=compiler-errors
NFC don't convert types to identical types
2023-12-15 21:33:00 -08:00
Matthias Krüger
8479945c08 NFC don't convert types to identical types 2023-12-15 23:56:24 +01:00
Jubilee
1d54949765
Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillot
Collect lang items from AST, get rid of `GenericBound::LangItemTrait`

r? `@cjgillot`
cc #115178

Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change:
1. A lot of `rustc_ast_lowering` for things like expr `..`
2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently.
3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem`

Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15 14:08:15 -08:00
Michael Goulet
0184c7616e Move nll_relate to relate::nll submodule 2023-12-15 18:13:40 +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
Michael Goulet
fc010de26b banish hir::GenericBound::LangItemTrait 2023-12-15 16:17:27 +00:00
Michael Goulet
70b9dad3dc Annotate some bugs 2023-12-15 14:45:06 +00:00
Michael Goulet
146e345d8b Opportunistically resolve region var in canonicalizer 2023-12-15 05:02:37 +00:00
lcnr
11d16c4082 update use of feature flags 2023-12-14 15:22:37 +01:00
bors
d23e1a6894 Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnr
cache param env canonicalization

Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results.

Prelimiary results show ~3-4% savings in diesel and serde benchmarks.

Best to review commits individually. Some commits have a short description.

Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation:
- When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context.
- This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's.

r? `@ghost`
2023-12-14 04:04:10 +00:00
Ali MJ Al-Nasrawy
e452c94912 remove canonicalize_query_preserving_universes
unused!
2023-12-14 03:03:03 +00:00
Ali MJ Al-Nasrawy
3b55869615 make infcx optional in canonicalizer
This doesn't change behavior.
It should prevent unintentional resolution of inference variables
during canonicalization, which previously caused a soundness bug.
See PR description for more.
2023-12-14 03:03:03 +00:00
Esteban Küber
9d846fcc11 Tweak short_ty_string to reduce number of files
When shortening types and writing them to disk, make `short_ty_string`
capable of reusing the same file, instead of writing a file per
shortened type.
2023-12-13 23:07:10 +00:00
Ali MJ Al-Nasrawy
fafe66d438 don't resolve regions in query input
fixes a soundness regression described in the PR description.
2023-12-13 14:57:52 +00:00
Ali MJ Al-Nasrawy
85338197d4 don't store OriginalQueryValues::universe_map
ParamEnv is canonicalized in *queries input* rather than query response.
In such case we don't "preserve universes" of canonical variable.
This means that `universe_map` always has the default value, which is
wasteful to store in the cache.
2023-12-13 14:57:52 +00:00
Ali MJ Al-Nasrawy
f38d1e971d global param_env canonicalization cache 2023-12-13 14:57:52 +00:00
bors
56d25ba5ea Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkov
Move some methods from `tcx.hir()` to `tcx`

https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834

Renamed:
- find -> opt_hir_node
- get -> hir_node
- find_by_def_id -> opt_hir_node_by_def_id
- get_by_def_id -> hir_node_by_def_id
2023-12-13 10:31:56 +00:00
Jubilee
4583a0134f
Rollup merge of #118889 - matthiaskrgr:compl_2023_2, r=WaffleLapkin
more clippy::complexity fixes

      redundant_guards
      redundant_slicing
      filter_next
      needless_borrowed_reference
      useless_format
2023-12-12 18:48:54 -08:00
Matthias Krüger
3795cc8eb0 more clippy::complexity fixes
redundant_guards
      redundant_slicing
      filter_next
      needless_borrowed_reference
      useless_format
2023-12-12 20:41:51 +01:00
zetanumbers
24f009c5e5 Move some methods from tcx.hir() to tcx
Renamings:
- find -> opt_hir_node
- get -> hir_node
- find_by_def_id -> opt_hir_node_by_def_id
- get_by_def_id -> hir_node_by_def_id

Fix rebase changes using removed methods

Use `tcx.hir_node_by_def_id()` whenever possible in compiler

Fix clippy errors

Fix compiler

Apply suggestions from code review

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>

Add FIXME for `tcx.hir()` returned type about its removal

Simplify with with `tcx.hir_node_by_def_id`
2023-12-12 06:40:29 -08:00
lcnr
6ffe36b37d refactor writeback: emit normalization errors with new solver 2023-12-12 12:20:54 +00:00
bors
5f5d248602 Auto merge of #118742 - lcnr:infer-var-cleanup, r=compiler-errors
refactor infer var storage

cleanup the code, discovered while working on #118725
2023-12-12 03:23:37 +00:00
bors
6f40082313 Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, r=compiler-errors
Restore `const PartialEq`

And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now.

r? `@compiler-errors`
2023-12-11 10:34:51 +00:00
bors
84f6130fe3 Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkov
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.

r? `@petrochenkov`
2023-12-10 11:55:48 +00:00
Deadbeef
d1f4bc5a19 Revert "Don't print host effect param in pretty path_generic_args"
This reverts commit f1bf874fb1.
2023-12-10 10:17:28 +00: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
f1bf874fb1 Don't print host effect param in pretty path_generic_args 2023-12-09 17:42:33 +00:00
Matthias Krüger
943fa33daf
Rollup merge of #118730 - jyn514:cmp_refs, r=estebank,compiler-errors
recurse into refs when comparing tys for diagnostics

before:
![image](https://github.com/rust-lang/rust/assets/23638587/bf6abd62-c7f3-4c09-a47e-31b6e129de19)

after:
![image](https://github.com/rust-lang/rust/assets/23638587/b704d728-ddba-4204-aebe-c07dcbbcb55c)

this diff from the test suite is also quite nice imo:
```diff
`@@` -4,8 +4,8 `@@` error[E0308]: mismatched types
 LL |     debug_assert_eq!(iter.next(), Some(value));
    |                                   ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>`
    |
-   = note: expected enum `Option<<I as Iterator>::Item>`
-              found enum `Option<&<I as Iterator>::Item>`
+   = note: expected enum `Option<_>`
+              found enum `Option<&_>`
```
2023-12-08 23:15:13 +01:00
Michael Goulet
cb41509601 Uplift canonicalizer into new trait solver crate 2023-12-08 17:44:01 +00:00
lcnr
75cfeb1854 cleanup type variable storage 2023-12-08 14:28:57 +01:00
jyn
eb53721a34 recurse into refs when comparing tys for diagnostics 2023-12-07 23:00:46 -05:00
lcnr
ac50f4b571 update fixme 2023-12-08 02:16:29 +01:00
lcnr
ffb4c08a81 implement and use NormalizesTo 2023-12-08 01:31:18 +01:00
lcnr
3978f545ba add unused NormalizesTo predicate 2023-12-07 17:52:51 +01:00
lcnr
40aa9f4fd9 avoid instantiating infer vars with infer 2023-12-07 16:13:09 +01:00
Michael Goulet
b97ff8eb16 Add print_trait_sugared 2023-12-05 17:15:46 +00:00
lcnr
407c117e88 cleanup and comments 2023-12-04 10:40:36 +01:00
lcnr
f69d67221e generalize: handle occurs check failure in aliases 2023-12-04 10:39:00 +01:00
lcnr
2d0ec174e4 do not fetch variance info during generalization 2023-12-04 10:38:43 +01:00
Nicholas Nethercote
a179a53565 Use Session::diagnostic in more places. 2023-12-02 09:01:35 +11:00
Nicholas Nethercote
c9008c6c8b Rename Handler::delay_good_path_bug as Handler::good_path_delayed_bug.
In line with the previous commits.
2023-12-02 09:01:34 +11:00
Nicholas Nethercote
2c337a072c Rename HandlerInner::delayed_span_bugs as HandlerInner::span_delayed_bugs.
For reasons similar to the previous commit.
2023-12-02 09:01:34 +11:00
Nicholas Nethercote
5d1d384443 Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug.
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug`
follows the pattern used everywhere else: `span_err`, `span_warning`,
etc.
2023-12-02 09:01:19 +11:00
Matthias Krüger
68d31b1906
Rollup merge of #118269 - compiler-errors:poly, r=wesleywiser
Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`

I did this recently with `FnSigs` and `PolyFnSigs` but didn't think to do it with `TraitRefs` and `PolyTraitRefs`.
2023-11-29 04:23:22 +01:00
bors
6eb9524047 Auto merge of #117200 - rmehri01:repeated_help, r=WaffleLapkin
Don't add redundant help for object safety violations

Fixes #117186

r? WaffleLapkin
2023-11-27 19:37:35 +00:00
Ryan Mehri
ee96a7a288
move comment about local trait 2023-11-26 10:09:25 -08:00
Ryan Mehri
af6b84aaab
don't add redundant help for object safety violations 2023-11-26 09:53:58 -08:00
Guillaume Gomez
c67613bef9
Rollup merge of #118302 - mu001999:dead_code/clean, r=cjgillot
Clean dead codes

Clean dead codes detected by #118257
2023-11-26 15:44:54 +01:00