Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up🔬 introduce a canonical query for `evaluate_obligation` #48537
Comments
nikomatsakis
added
A-traits
T-compiler
WG-compiler-traits
labels
Feb 25, 2018
nikomatsakis
assigned
nikomatsakis and
aravind-pg
and unassigned
nikomatsakis
Feb 25, 2018
This comment has been minimized.
This comment has been minimized.
|
@aravind-pg expressed interest in taking this on! |
aravind-pg
referenced this issue
Mar 13, 2018
Merged
Create a canonical trait query for `evaluate_obligation` #48995
bors
added a commit
that referenced
this issue
Mar 20, 2018
bors
added a commit
that referenced
this issue
Mar 20, 2018
jkordish
added
the
C-enhancement
label
Apr 24, 2018
bors
added a commit
that referenced
this issue
Apr 27, 2018
bors
closed this
in
#48995
Apr 27, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nikomatsakis commentedFeb 25, 2018
The
evaluate_obligationmethod ofSelectionContexthas the job of determining whether a given predicate may hold:rust/src/librustc/traits/select.rs
Lines 622 to 625 in 322d7f7
Building on the work in #48411, this seems like a clean place to introduce a canonical trait query. The argument to this query would be canonicalized predicate, combined with an environment:
The query would be something like this:
I expect this would follow the pattern introduced in #48411, where the query is not invoked directly by end-users. Rather, they invoke a wrapper method defined on the
Attype, likenormalizehere. This method would canonicalize and invoke the underlying query.Note that I defined the query to return a
EvaluationResult, where the current method returns abool-- this would allow the same query to be shared forevaluate_obligation_conservatively. I suggest that we rename theinfcx.at().foo()methods, actually, to be something like this:infcx.at(...).predicate_may_hold(predicate)(what is todayevaluate_obligation)infcx.at(...).predicate_must_hold(predicate)(what is todayevaluate_obligation_conservatively)Both of these would return a boolean.
Anyway, I will try to write up more comprehensive guidelines in the rustc-guide describing the pattern for trait queries, and link to them from here.
If you are interesting in this task, please feel free to ping me on gitter for more info!