about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2023-05-25diagnostics: don't crash if an injected crate shows up in suggestionsMichael Howell-1/+4
2023-05-25diagnostics: exclude indirect private deps from trait impl suggestMichael Howell-1/+22
Fixes #88696
2023-05-25Auto merge of #111473 - compiler-errors:opaques, r=lcnrbors-14/+123
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.
2023-05-25Rollup merge of #111875 - WaffleLapkin:defer_on_drop, r=NilstriebMatthias Krüger-1/+1
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.
2023-05-25Streamline `modify_size_estimate`.Nicholas Nethercote-4/+1
2023-05-25Check that opaque is a defining use, prefer pre-defined opaquesMichael Goulet-0/+36
2023-05-25Prepopulate opaques in canonical inputMichael Goulet-4/+72
2023-05-25Move DefiningAnchorMichael Goulet-0/+11
2023-05-25Pull out logic from #111131, plus some new logic in ↵Michael Goulet-10/+4
EvalCtxt::normalize_opaque_type Co-authored-by: lcnr <rust@lcnr.de>
2023-05-24Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, ↵Manish Goregaokar-12/+11
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
2023-05-24Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiaskobors-2/+3
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`
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-12/+11
2023-05-24Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, ↵Matthias Krüger-10/+12
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.
2023-05-23Rename `traits_in_crate` query to `traits`Maybe Waffle-10/+12
2023-05-23Rollup merge of #111486 - fmease:pp-inh-proj, r=petrochenkovMatthias Krüger-1/+21
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
2023-05-23Don't leak the function that is called on dropMaybe Waffle-1/+1
2023-05-23Rollup merge of #111853 - compiler-errors:opaque-check, r=oli-obkDylan DPC-7/+23
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`
2023-05-22Check opaques for mismatch during writebackMichael Goulet-7/+23
2023-05-22properly pretty-print inherent projectionsLeón Orell Valerian Liehr-1/+21
2023-05-22Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPCbors-0/+23
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
2023-05-23Rollup merge of #111501 - WaffleLapkin:drivebycleanupuwu, r=oli-obkDylan DPC-0/+23
MIR drive-by cleanups Some random drive-by cleanups I did while working with MIR/THIR.
2023-05-22Auto merge of #111754 - lcnr:recursion-depth, r=matthewjasperbors-3/+20
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`
2023-05-22Auto merge of #111775 - compiler-errors:triple-check, r=Nilstriebbors-5/+44
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.
2023-05-21Tweak the post-order for multi-successor blocksScott McMurray-14/+14
2023-05-21Replace `QueryStruct` with arrays local to `rustc_query_impl`John Kåre Alsaker-13/+3
2023-05-20Rollup merge of #111450 - compiler-errors:opaque-ty-key, r=oli-obkGuillaume Gomez-2/+2
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.
2023-05-20Rollup merge of #111619 - cjgillot:profile-pass, r=WaffleLapkinDylan DPC-1/+1
Add timings for MIR passes to profiling report This will help identify which pass is responsible for a regression.
2023-05-19Add extra debug assertions for equality for Adt/Variant/FieldDefMichael Goulet-5/+44
2023-05-19Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillotbors-2/+64
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`
2023-05-19update recursion depth in `confirm_candidate`lcnr-3/+20
2023-05-18Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31bors-1/+1
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.
2023-05-18Rollup merge of #111703 - Zoxc:queries-mod, r=cjgillotDylan DPC-93/+64
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``
2023-05-18Rollup merge of #111686 - cjgillot:no-foreign-item, r=compiler-errorsDylan DPC-6/+7
Retire is_foreign_item query. This can be written in terms of `DefKind`. This does not deserve the cost of a query.
2023-05-18Rollup merge of #110986 - cjgillot:delay-feed-bug, r=WaffleLapkinDylan DPC-5/+13
Delay a bug when overwriting fed value. Fixes https://github.com/rust-lang/rust/issues/110887
2023-05-18Merge query property modules into oneJohn Kåre Alsaker-93/+64
2023-05-18Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkinDylan DPC-3/+7
Avoid `&format("...")` calls in error message code. Some error message cleanups. Best reviewed one commit at a time. r? `@davidtwco`
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-1/+1
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-05-17Delay a bug when overwriting fed value.Camille GILLOT-5/+13
2023-05-17Retire is_foreign_item query.Camille GILLOT-6/+7
2023-05-17Rollup merge of #111625 - Zoxc:rustc_middle-query-move, r=cjgillotDylan DPC-22/+20
Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs This just keeps the query modules together. r? `@cjgillot`
2023-05-17Drive-by cleanup: `debug::term_type` => `TerminatorKind::name`Maybe Waffle-0/+23
2023-05-17Merge DominatorTree and Dominators.Camille GILLOT-7/+1
2023-05-17Cache dominators.Camille GILLOT-4/+6
2023-05-17Preprocess dominator tree to answer queries in O(1)Tomasz Miąsko-1/+6
2023-05-17Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPCbors-7/+11
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
2023-05-17Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkinDylan DPC-7/+11
Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-17Auto merge of #111630 - BoxyUwU:ty_const_debug_formatting, r=compiler-errorsbors-41/+71
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`
2023-05-17Finish move of query.rsJohn Kåre Alsaker-22/+20
2023-05-17Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rsJohn Kåre Alsaker-0/+0
2023-05-16Move DebuggerVisualizerFile types from rustc_span to rustc_middleMichael Woerister-3/+44