| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Fixes #88696
|
|
Handle opaques in the new solver (take 2?)
Implement a new strategy for handling opaques in the new solver.
First, queries now carry both their defining anchor and the opaques that were defined in the inference context at the time of canonicalization. These are both used to pre-populate the inference context used by the canonical query.
Second, use the normalizes-to goal to handle opaque types in the new solver. This means that opaques are handled like projection aliases, but with their own rules:
* Can only define opaques if they're "defining uses" (i.e. have unique params in all their substs).
* Can only define opaques that are from the anchor.
* Opaque type definitions are modulo regions. So that means `Opaque<'?0r> = HiddenTy1` and `Opaque<?'1r> = HiddenTy2` equate `HiddenTy1` and `HiddenTy2` instead of defining them as different opaque type keys.
|
|
Don't leak the function that is called on drop
It probably wasn't causing problems anyway, but still, a `// this leaks, please don't pass anything that owns memory` is not sustainable.
I could implement a version which does not require `Option`, but it would require `unsafe`, at which point it's probably not worth it.
|
|
|
|
|
|
|
|
|
|
EvalCtxt::normalize_opaque_type
Co-authored-by: lcnr <rust@lcnr.de>
|
|
r=petrochenkov
Use `Option::is_some_and` and `Result::is_ok_and` in the compiler
`.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable.
This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
|
|
Preprocess and cache dominator tree
Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).
This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.
Rebase of https://github.com/rust-lang/rust/pull/107157
cc `@tmiasko`
|
|
|
|
r=compiler-errors
Rename `traits_in_crate` query to `traits`
> NOTE: Not named just `traits` due to a naming conflict.
This can, in fact, be easily avoided.
|
|
|
|
Pretty-print inherent projections correctly
Previously, we were trying to pretty-print inherent projections with `Printer::print_def_path` which is incorrect since
it expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for
inherent projections (self type subst followed by own substs).
Now we print inherent projections manually.
Fixes #111390.
Fixes #111397.
Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases,
inherent projections are normalized away before they get the chance to appear in diagnostics.
If I were to create regression tests for linked issues, they would need to be `mir-opt` tests to exercise
`-Zdump-mir=all` (right?) which doesn't feel quite adequate to me.
`@rustbot` label F-inherent_associated_types
|
|
|
|
Check opaques for mismatch during writeback
Revive #111705.
I realized that we don't need to put any substs in the writeback results since all of the hidden types have already been remapped. See the comment in `compiler/rustc_middle/src/ty/typeck_results.rs`, which should make that clear for other explorers of the codebase.
Additionally, we need to do some diagnostic stashing because the diagnostics we produce during HIR typeck is very poor and we should prefer the diagnostic that comes from MIR, if we have one.
r? `@oli-obk`
|
|
|
|
|
|
Rollup of 6 pull requests
Successful merges:
- #111501 (MIR drive-by cleanups)
- #111609 (Mark internal functions and traits unsafe to reflect preconditions)
- #111612 (Give better error when collecting into `&[T]`)
- #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming)
- #111843 (move lcnr to only review types stuff)
- #111844 (Migrate GUI colors test to original CSS color format)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
MIR drive-by cleanups
Some random drive-by cleanups I did while working with MIR/THIR.
|
|
fix recursion depth handling after confirmation
fixes #111729
I think having to use `Obligation::with_depth` correctly everywhere is very hard because e.g. the nested obligations from `eq` currently do not have the correct obligation depth.
The new solver [completely removes `recursion_depth` from obligations](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/traits/solve/struct.Goal.html) and instead tracks the depth in the solver itself which is far easier to get right. Moving the old solver towards this shouldn't be that hard but is probably somewhat annoying.
r? `@matthewjasper`
|
|
Add extra debug assertions for equality for Adt/Variant/FieldDef
Would've made it easier to both catch and test https://github.com/rust-lang/rust/pull/111494. Maybe not worth it, since it does mean that the compiler is doing extra work when debug-assertions are enabled, but also that's what debug assertions are for :^)
This is a revival of #111523 because I think I pushed an empty branch and bors got a bit too excited it closed the PR.
|
|
|
|
|
|
Use `OpaqueTypeKey` in query response
Makes it a bit clearer that at least one of the types being returned from a canonical query is an opaque.
|
|
Add timings for MIR passes to profiling report
This will help identify which pass is responsible for a regression.
|
|
|
|
Fix dependency tracking for debugger visualizers
This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves.
TODO:
- [x] perf.rlo
- [x] Needs a bit more documentation in some places
- [x] Needs regression test for the incr. comp. case
Fixes https://github.com/rust-lang/rust/issues/111226
Fixes https://github.com/rust-lang/rust/issues/111227
Fixes https://github.com/rust-lang/rust/issues/111295
r? `@wesleywiser`
cc `@gibbyfree`
|
|
|
|
Only depend on CFG_VERSION in rustc_interface
This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
|
|
Merge query property modules into one
This merges all the query modules that defines types into a single module per query with a normal naming convention for type aliases.
r? ``@cjgillot``
|
|
Retire is_foreign_item query.
This can be written in terms of `DefKind`. This does not deserve the cost of a query.
|
|
Delay a bug when overwriting fed value.
Fixes https://github.com/rust-lang/rust/issues/110887
|
|
|
|
Avoid `&format("...")` calls in error message code.
Some error message cleanups. Best reviewed one commit at a time.
r? `@davidtwco`
|
|
this avoids having to rebuild the whole compiler on each commit when
`omit-git-hash = false`.
|
|
|
|
|
|
Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs
This just keeps the query modules together.
r? `@cjgillot`
|
|
|
|
|
|
|
|
|
|
Rollup of 6 pull requests
Successful merges:
- #110145 (Share slice of bytes)
- #111043 (Stabilize feature `cstr_is_empty`)
- #111648 (Remove `LangItems::require`)
- #111649 (Add derive for `core::marker::ConstParamTy`)
- #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`)
- #111661 (Erase regions of type in `offset_of!`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Remove `LangItems::require`
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
|
|
debug format `Const`'s less verbosely
Not user visible change only visible to people debugging const generics.
Currently debug output for `ty::Const` is super verbose (even for `-Zverbose` lol), things like printing infer vars as `Infer(Var(?0c))` instead of just `?0c`, bound vars and placeholders not using `^0_1` or `!0_1` syntax respectively. With these changes its imo better but not perfect:
`Const { ty: usize, kind: ^0_1 }`
is still a lot for not much information. not entirely sure what to do about that so not dealing with it yet.
Need to do formatting for `ConstKind::Expr` at some point too since rn it sucks (doesn't even print anything with `Display`) not gonna do that in this PR either.
r? `@compiler-errors`
|
|
|
|
|
|
|