Commit Graph

1391 Commits

Author SHA1 Message Date
Matthias Krüger
8a5843f07f
Rollup merge of #108202 - compiler-errors:non_lifetime_binders-type-match-ice, r=davidtwco
Make sure `test_type_match` doesn't ICE with late-bound types

Fixes #108190 (in a kind of hacky way, anyways doesn't really matter)
2023-02-21 23:01:59 +01:00
Matthias Krüger
314fe4d170
Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
Better debug logs for borrowck constraint graph

It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
2023-02-21 23:01:58 +01:00
Oli Scherer
88a7b6803b Make hidden type registration opt-in, so that each site can be reviewed on its own and we have the right defaults for trait solvers 2023-02-21 14:50:51 +00:00
Dylan DPC
270f45e172
Rollup merge of #108289 - compiler-errors:name-placeholder, r=petrochenkov
Name placeholder in some region errors

Also don't print `ReVar` or `ReLateBound` as debug... these error messages are super uncommon anyways, but in the case they do trigger, let's be slightly more helpful.
2023-02-21 14:20:01 +05:30
Michael Goulet
2895731e5e Name placeholder in some region errors 2023-02-21 00:00:49 +00:00
b-naber
c9843d6144 remove cfg attributes 2023-02-20 22:00:30 +00:00
lcnr
f97a8f017d small opaque_type_origin cleanup 2023-02-20 18:00:57 +01:00
b-naber
960ebaf899 collect existentials and placeholders 2023-02-19 22:12:09 +00:00
b-naber
2f79f73821 collect region contexts during mir renumbering 2023-02-19 22:11:27 +00:00
Michael Goulet
c13d5f1aeb Make sure test_type_match doesn't ICE with late-bound types 2023-02-18 20:16:51 +00:00
Michael Goulet
ec40b1a393 Collapse placeholders to root universe in canonicalizer if not preserving universes 2023-02-18 19:49:40 +00:00
Matthias Krüger
d3d5163921
Rollup merge of #108186 - compiler-errors:closures-with-late-bound-types-r-bad, r=cjgillot
Deny non-lifetime bound vars in `for<..> ||` closure binders

Moves the check for illegal bound var types from astconv to resolve_bound_vars. If a binder is defined to have a type or const late-bound var that's not allowed, we'll resolve any usages to ty error or const error values, so we shouldn't ever see late-bound types or consts in places they aren't expected.

Fixes #108184
Fixes #108181
Fixes #108192
2023-02-18 13:26:47 +01:00
Michael Goulet
cec7835d7a Move late-bound arg type checks to resolve_bound_vars 2023-02-18 03:28:54 +00:00
bors
9aa5c24b7d Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstrieb
Remove `arena_cache` modifier from `associated_item` query & copy `ty::AssocItem` instead of passing by ref

r? `@ghost`
2023-02-17 17:42:51 +00:00
Boxy
e919d7e348 Add Clause::ConstArgHasType variant 2023-02-17 09:30:33 +00:00
bors
9556b56dbd Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwU
Switch to `EarlyBinder` for `type_of` query

Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`.

r? `@lcnr`
2023-02-17 04:45:15 +00:00
Kyle Matsuda
8e92849cbb changes from review 2023-02-16 17:05:59 -07:00
Kyle Matsuda
c183110cc2 remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
Kyle Matsuda
d822b97a27 change usages of type_of to bound_type_of 2023-02-16 17:01:52 -07:00
Matthias Krüger
ecdb7bcee8
Rollup merge of #108136 - eggyal:unmet_trait_alias_bound_on_generic_impl, r=compiler-errors
Do not ICE on unmet trait alias impl bounds

Fixes #108132

I've also added some documentation to the `impl_def_id` field of `DerivedObligationCause` to try and minimise the risk of such errors in future.

r? `@compiler-errors`
2023-02-17 00:19:37 +01:00
Matthias Krüger
9b2ee4192e
Rollup merge of #108104 - matthiaskrgr:into, r=compiler-errors
don't into self

don't into()-convert types to themselves
2023-02-17 00:19:36 +01:00
Matthias Krüger
089e8c03bc
Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillot
Implement partial support for non-lifetime binders

This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed.

Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged.

Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`)

cc rust-lang/types-team#81

r? `@ghost`
2023-02-17 00:19:34 +01:00
Alan Egerton
55d449fe0a
Clarify DerivedObligationCause may hold alias id 2023-02-16 22:12:15 +00:00
bors
9a7cc6c32f Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #106347 (More accurate spans for arg removal suggestion)
 - #108057 (Prevent some attributes from being merged with others on reexports)
 - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`)
 - #108092 (note issue for feature(packed_bundled_libs))
 - #108099 (use chars instead of strings where applicable)
 - #108115 (Do not ICE on unmet trait alias bounds)
 - #108125 (Add new people to the compiletest review rotation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-16 19:21:02 +00:00
Matthias Krüger
a1a6588162 don't into self
don't into()-convert types to themselves
2023-02-16 18:30:25 +01:00
bors
c5d1b3ea96 Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errors
Optimize `mk_region`

PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions.

r? `@compiler-errors`
2023-02-16 16:11:54 +00:00
Maybe Waffle
8751fa1a9a if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
Michael Goulet
eff2cb7760 Rename some region-specific stuff 2023-02-16 03:39:59 +00:00
Matthias Krüger
897f56ed28
Rollup merge of #108049 - clubby789:dont-suggest-unstable, r=compiler-errors
Don't suggest `#[doc(hidden)]` trait methods with matching return type

Fixes #107983, addressing the bad suggestion.
The test can probably be made more specific to this  case, but I'm unsure how.

`@rustbot` label +A-diagnostics
2023-02-15 21:30:58 +01:00
Matthias Krüger
8f65e25aec
Rollup merge of #108010 - compiler-errors:can_eq-returns-bool, r=lcnr
Make `InferCtxt::can_eq` and `InferCtxt::can_sub` return booleans

Nobody matches on the result, nor does the result return anything useful...
2023-02-15 21:30:56 +01:00
Matthias Krüger
1fdf0e1334
Rollup merge of #107034 - IntQuant:issue-100717-infer-5, r=oli-obk
Migrating rustc_infer to session diagnostics (part 4)

`@rustbot` label +A-translation
r? rust-lang/diagnostics
cc https://github.com/rust-lang/rust/issues/100717
2023-02-15 21:30:55 +01:00
Maybe Waffle
a32d392741 Copy ty::AssocItem all other the place 2023-02-15 20:22:41 +00:00
bors
2d14db321b Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
Avoid accessing HIR when it can be avoided

Experiment to see if it helps some incremental cases.

Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged.

r? `@ghost`
2023-02-15 16:14:10 +00:00
clubby789
f4de121951 Don't suggest #[doc(hidden)] methods 2023-02-15 12:31:38 +00:00
bors
999ac5f777 Auto merge of #108070 - Dylan-DPC:rollup-v6xw7vk, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #105300 (rework min_choice algorithm of member constraints)
 - #107163 (Remove some superfluous type parameters from layout.rs.)
 - #107173 (Suggest the correct array length on mismatch)
 - #107411 (Handle discriminant in DataflowConstProp)
 - #107968 (Enable `#[thread_local]` on armv6k-nintendo-3ds)
 - #108032 (Un📦ing the Resolver)
 - #108060 (Revert to using `RtlGenRandom` as a fallback)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-15 08:48:44 +00:00
Dylan DPC
a110cf5d16
Rollup merge of #107173 - clubby789:suggest-array-length, r=compiler-errors
Suggest the correct array length on mismatch

Fixes #107156

I wasn't able to find a way to get the `Span` for the actual array size unfortunately, so this suggestion can't be applied automatically.

``@rustbot`` label +A-diagnostics
2023-02-15 12:24:54 +05:30
bors
068161ea48 Auto merge of #107940 - BoxyUwU:const_ty_assertion_use_semantic_equality, r=compiler-errors
use semantic equality for const param type equality assertion

Fixes #107898

See added test for what caused this ICE

---

The current in assertion in `relate.rs` is rather inadequate when keeping in mind future expansions to const generics:
- it will ICE when there are infer vars in a projection in a const param ty
- it will spurriously return false when either ty has infer vars because of using `==` instead of `infcx.at(..).eq`
- i am also unsure if it would be possible with `adt_const_params` to craft a situation where the const param type is not wf causing `normalize_erasing_regions` to `bug!` when we would have emitted a diagnostic.

This impl feels pretty Not Great to me  although i am not sure what a better idea would be.

- We have to have the logic behind a query because neither `relate.rs` or `combine.rs` have access to trait solving machinery (without evaluating nested obligations this assert will become _far_ less useful under lazy norm, which consts are already doing)
- `relate.rs` does not have access to canonicalization machinery which is necessary in order to have types potentially containing infer vars in query arguments.

We could possible add a method to `TypeRelation` to do this assertion rather than a query but to avoid implementing the same logic over and over we'd probably end up with the logic in a free function somewhere in `rustc_trait_selection` _anyway_ so I don't think that would be much better.

We could also just remove this assertion, it should not actually be necessary for it to be present. It has caught some bugs in the past though so if possible I would like to keep it.

r? `@compiler-errors`
2023-02-15 05:17:58 +00:00
Nicholas Nethercote
cef9004f5a Add specialized variants of mk_region.
Much like there are specialized variants of `mk_ty`. This will enable
some optimization in the next commit.

Also rename the existing `re_error*` functions as `mk_re_error*`, for
consistency.
2023-02-15 09:02:44 +11:00
Nicholas Nethercote
7439028374 Remove reuse_or_mk_region.
It's not used on any hot paths, and so has little perf benefit, and it
interferes with the optimizations in the following commits.
2023-02-15 09:02:44 +11:00
IQuant
58939b9520 Specify correct spans in suggest_await_on_expect_found 2023-02-14 23:16:29 +03:00
Camille GILLOT
03dff82d59 Add of_trait to DefKind::Impl. 2023-02-14 19:55:44 +00:00
IQuant
5c7afde6f2 Port PlaceholderRelationLfNotSatisfied diagnostic 2023-02-14 18:56:22 +03:00
IQuant
fdbec623c4 Port ConsiderAddingAwait 2023-02-14 18:55:54 +03:00
IQuant
9f06c3d87f Port SuggestRemoveSemiOrReturnBinding 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
6fa4c7d89c Make sure tests pass 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
b8feb63345 Port WhereClauseSuggestions 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
8d590dc303 Resolve rebase 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
35dbec338a Port another diagnostic 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
cb8ea01096 Port RefLongerThanData 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
58e901b6fd Port "BorrowedTooLong" diagnostic 2023-02-14 18:31:45 +03:00