-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add flag for enabling global cache usage for proof trees and printing proof trees on error #113296
Conversation
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Outdated
Show resolved
Hide resolved
90d171d
to
96049a8
Compare
96049a8
to
040aa58
Compare
@@ -3499,3 +3513,16 @@ pub enum DefIdOrName { | |||
DefId(DefId), | |||
Name(&'static str), | |||
} | |||
|
|||
pub fn dump_proof_tree<'tcx>(o: &Obligation<'tcx, ty::Predicate<'tcx>>, infcx: &InferCtxt<'tcx>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that since this happens during error reporting, there may have been inference done in between when the goal was registered in the fulfillment context and now, but it's probably fine, since the proof tree will probably still explain why something failed pretty clearly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's actually kind of unfortunate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after review
"dump a proof tree for every goal evaluated by the new trait solver. If the flag is specified without any options after it | ||
then it defaults to `always`. If the flag is not specified at all it defaults to `on-request`."), | ||
dump_solver_proof_tree_use_cache: Option<bool> = (None, parse_opt_bool, [UNTRACKED], | ||
"determines whether proof tree generation uses the global cache"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"determines whether proof tree generation uses the global cache"), | |
"determines whether dumping proof trees should disable the global cache"), |
this flag should not affect general proof tree generation, only the proof trees which should get dumped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's.... not how the code works. the flag does cause us to use or not use the global cache during proof tree creation. It's not a step done when we dump the proof tree to edit all the "GLOBAL CACHE HIT" to actual proof trees. Implementing it that way sounds trickier than what was done in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the description:
This flag currently would affect misc uses of GenerateProofTree::Yes which will be added in the future for things like diagnostics logic and rustdoc's auto_trait file. We can fix this when we start using proof tree generation for those use cases if it's desirable.
When -Zdump-solver-proof-tree-use-cache=no/yes
is set it acts on every call to evaluate_goal
with GenerateProofTree::Yes
and also to all proof trees generated by -Zdump-solver-proof-tree=always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my thought was that setting this to true
does/will not prevent diagnostics and auto trait computation from disabling the cache, so this only affects trait solving when we construct a tree for "proof tree dumping"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally that's how it would work but right now it wouldn't if you implemented auto_trait/diagnostics by callign evalaute_goal
with GenerateProofTree::Yes(UseGlobalCache::No)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but that would completely ignore this compile flag
5bed20b
to
284b614
Compare
@bors r+ rollup |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#113192 (`assemble_candidates_after_normalizing_self_ty` docs) - rust-lang#113251 (Use scoped-tls for SMIR to map between TyCtxt and SMIR datastructures) - rust-lang#113282 (Update platform-support.md to improve ARM target descriptions) - rust-lang#113296 (add flag for enabling global cache usage for proof trees and printing proof trees on error) - rust-lang#113324 (implement `ConstEvaluatable` goals in new solver) r? `@ghost` `@rustbot` modify labels: rollup
This adds a few new things:
-Zdump-solver-proof-tree=always/never/on-error
always
/never
were previosuly specifiable by whether the flag exists or not, th new flag ison_error
which reruns obligations of fulfillment and selection errors with proof tree generation enabled and prints them out-Zdump-solver-proof-tree-uses-cache
always
so that it accurately represents what happend. This flag currently would affect misc uses ofGenerateProofTree::Yes
which will be added in the future for things like diagnostics logic and rustdoc's auto_trait file. We can fix this when we start using proof tree generation for those use cases if it's desirable.I also changed the output to go straight to stdout instead of going through
debug!
so that-Zdump-solver-proof-tree
can be adequately used onnightly
not just a locally built toolchain.The idea for
on-error
is that it should hopefully make it easier to quickly figure out "why doesnt this code compile"- you just pass in-Zdump-solver-proof-tree=on-error
and you'll only get proof trees you care about.r? @lcnr @compiler-errors