-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't use lift to detect local types #61871
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors try |
⌛ Trying commit 90fbfd7095ad0b022adb968bbc72ce51b55e2467 with merge 3e509e149d6644da28c5e2b642d164845e724047... |
@@ -1455,7 +1455,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { | |||
// Even if the type may have no inference variables, during | |||
// type-checking closure types are in local tables only. | |||
if !self.in_progress_tables.is_some() || !ty.has_closure_types() { | |||
if let Some((param_env, ty)) = self.tcx.lift_to_global(&(param_env, ty)) { | |||
if !(param_env, ty).has_local_value() { |
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.
cc @rust-lang/compiler I think it might be better if we stop referring to these as "local values" and instead use something more like .has_infer_vars()
?
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.
has_infer_types
already exist and is a different property.
ty.is_copy_modulo_regions(self.tcx.global_tcx(), param_env, span) | ||
}) | ||
if (param_env, ty).has_local_value() { | ||
None |
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.
Hmm, if self.infcx
is None
, this case should be impossible - it's plausible this code is unnecessarily defensive and lift_to_global
's result could've been unwrap
'd all along.
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.
I agree.
promoted: None, | ||
}; | ||
match self.selcx.tcx().at(obligation.cause.span) | ||
.const_eval(obligation.param_env.and(cid)) { |
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.
I can't wait for this to use erasure and canonicalization instead (@oli-obk and @nikomatsakis are working on that, I think?).
} | ||
if predicates.has_local_value() { | ||
// FIXME: shouldn't we, you know, actually report an error here? or an ICE? | ||
Err(ErrorReported) |
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.
@rust-lang/wg-traits This is scary, can we do a crater run with a delay_span_bug
in here?
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.
@eddyb What happened to this?
if let Some(lifted) = self.tcx().lift_to_global(&x) { | ||
lifted | ||
} else { | ||
if cfg!(debug_assertions) && x.has_local_value() { |
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.
Is it really that expensive? Anyway it should be impossible, given a correct Resolver
.
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.
I don't know how expensive these are. They're not free though, so I'd prefer to not have them for release builds.
And yes, it should be impossible, that's why it's an assertion =P
let c_sig = if let Some(c_sig) = self.tcx().lift_to_global(c_sig) { | ||
c_sig | ||
} else { | ||
if cfg!(debug_assertions) && c_sig.has_local_value() { |
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.
Hmm, can we do a crater run with all of these assertions turned on by default, to confirm they're very likely never triggered, and then remove them?
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.
They're effectively turned on now, and they have caught at least one bug #46184.
I do think we should have these assertions somewhere though, to ensure that no infer types leaks out from typeck. I could just use debug_assert
here instead of span_bug
to make them more slim.
@@ -808,26 +825,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | |||
|
|||
ty::Predicate::ConstEvaluatable(def_id, substs) => { | |||
let tcx = self.tcx(); | |||
match tcx.lift_to_global(&(obligation.param_env, substs)) { | |||
Some((param_env, substs)) => { |
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.
I'd prefer if one of two things happened here (and in other places match
-ing over lift_to_global
results):
- land a PR on master replacing the
match
es withif let
s (you can just r=me that if you want) - keep the
match
and either useOption::filter
or justmatch
on thebool
predicate
That is, I would prefer if indentation didn't change (and it only does because of the match
-> if
change).
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.
Why do you not want indention to change? I like less rightward drift, and I definitely don't like matching on bools.
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.
It's fine to change, I just want to be able to read the diff without mentally pretending nothing changed without checking, where indentation is involved.
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.
I changed the indentation to reduce the diffs 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.
@eddyb you can append ?w=1
to the diff url to have whitespace insensitive diffs https://github.com/rust-lang/rust/pull/61871/files?w=1
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.
Nice. I also reordered some branches which that can't deal with though =P
@@ -461,40 +461,34 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { | |||
} | |||
|
|||
ty::Predicate::ConstEvaluatable(def_id, substs) => { | |||
match self.selcx.tcx().lift_to_global(&obligation.param_env) { | |||
None => { | |||
if obligation.param_env.has_local_value() { |
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.
Same as the other match
-> if
change.
a35c705
to
fabe708
Compare
☔ The latest upstream changes (presumably #61945) made this pull request unmergeable. Please resolve the merge conflicts. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+ |
📌 Commit 8465daf has been approved by |
⌛ Testing commit 8465daf with merge ebe126b40db5acb422774453b0d9a2d821bb3755... |
@bors retry Yielding priority to the Azure migration. |
Don't use lift to detect local types This overlaps with rust-lang#61392. r? @eddyb
☀️ Test successful - checks-azure, checks-travis, status-appveyor |
This overlaps with #61392.
r? @eddyb