Skip to content
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

Remove Binder::bind() and use Binder::dummy() #83825

Closed
wants to merge 1 commit into from

Conversation

camelid
Copy link
Member

@camelid camelid commented Apr 3, 2021

See here for motivation.

In one place, it manually uses the BoundVarsCollector for now because
we don't know what the bound variables are, and adding support for
tracking the bound variables will probably be a tricky change.

r? @jackh726

@camelid camelid added I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 3, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 3, 2021
@camelid
Copy link
Member Author

camelid commented Apr 3, 2021

At least one test (src/test/ui/const-generics/issues/issue-64494.rs#full) is failing with this change:

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /Users/user/rust/compiler/rustc_middle/src/ty/sty.rs:968:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-dev running on x86_64-apple-darwin

note: compiler flags: -Z threads=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z emit-future-incompat-report -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
thread 'rustc' panicked at 'substs of instance DefId(0:4 ~ issue_64494[317d]::Foo::VAL) not normalized for codegen: [^0]', compiler/rustc_middle/src/ty/instance.rs:285:9

I think you said that there was one case where we needed to keep the Binder::bind() call?

EDIT: It looks like that is the only test that is failing.

@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Member

jackh726 commented Apr 3, 2021

Yep that's the one test that I had troubles with. I've tried to dig into it a couple times, but didn't get very far.

@camelid
Copy link
Member Author

camelid commented Apr 3, 2021

So do you think there is a solution to that one without using Binder::bind() for it? If so, do you have any advice on what sorts of things to try?

@jackh726
Copy link
Member

jackh726 commented Apr 3, 2021

So do you think there is a solution to that one without using Binder::bind() for it? If so, do you have any advice on what sorts of things to try?

Well, we should first check if we expect bound vars there. Then, either need to figure out if we would know the binders elsewhere, or if we can pass through binders. For what it's worth, it wasn't obvious to me.

@jackh726
Copy link
Member

jackh726 commented Apr 5, 2021

Should still be able to do a perf run, I think. And I'm curious.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 5, 2021
@bors
Copy link
Contributor

bors commented Apr 5, 2021

⌛ Trying commit 61efe217f48b22ab8984eb9891955d87e029d65c with merge 24305f7b8bdf7853fd1537332a15bc69c0f7d9c4...

@bors
Copy link
Contributor

bors commented Apr 5, 2021

☀️ Try build successful - checks-actions
Build commit: 24305f7b8bdf7853fd1537332a15bc69c0f7d9c4 (24305f7b8bdf7853fd1537332a15bc69c0f7d9c4)

@rust-timer
Copy link
Collaborator

Queued 24305f7b8bdf7853fd1537332a15bc69c0f7d9c4 with parent 39eee17, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (24305f7b8bdf7853fd1537332a15bc69c0f7d9c4): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 5, 2021
@jackh726
Copy link
Member

jackh726 commented Apr 5, 2021

Slight perf win, but only a small portion of the regression from the binder refactor

@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 6, 2021
@camelid
Copy link
Member Author

camelid commented Apr 6, 2021

Here's a snippet of the debug logging of rustc running on the test. (I added
a debug! call to Binder::dummy().) This is the portion of the logs right
before the assertion failure.

│ │ │ ├┘rustc_middle::mir::interpret::queries::const_eval_resolve param_env=ParamEnv { caller_bounds: [], reveal: UserFacing }, ct=Unevaluated { def: WithOptConstParam { did: DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0}), const_param_did: Some(DefId(0:9 ~ issue_64494[317d]::Is::T)) }, substs: [^0], promoted: None }, span=Some(src/test/ui/const-generics/issues/issue-64494.rs:1:1: 1:1 (#0))
│ │ │ ├─22ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_FREE_REGIONS | HAS_RE_LATE_BOUND
│ │ │ ├─22ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_TY_PARAM | HAS_CT_PARAM | HAS_TY_INFER | HAS_CT_INFER | HAS_TY_PLACEHOLDER | HAS_CT_PLACEHOLDER | HAS_FREE_LOCAL_REGIONS | HAS_FREE_LOCAL_NAMES
│ │ │ ├─22ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_TY_INFER | HAS_RE_INFER | HAS_CT_INFER | NEEDS_INFER
│ │ │ ├┐rustc_middle::mir::interpret::queries::const_eval_resolve param_env=ParamEnv { caller_bounds: [], reveal: UserFacing }, ct=Unevaluated { def: WithOptConstParam { did: DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0}), const_param_did: Some(DefId(0:9 ~ issue_64494[317d]::Is::T)) }, substs: [^0], promoted: None }, span=Some(src/test/ui/const-generics/issues/issue-64494.rs:1:1: 1:1 (#0))
│ │ │ │└┐rustc_middle::mir::interpret::queries::const_eval_resolve param_env=ParamEnv { caller_bounds: [], reveal: All }, ct=Unevaluated { def: WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs: [^0], promoted: None }, span=None
│ │ │ │ ├┐rustc_middle::mir::interpret::queries::const_eval_resolve param_env=ParamEnv { caller_bounds: [], reveal: All }, ct=Unevaluated { def: WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs: [^0], promoted: None }, span=None
│ │ │ │ │└┐rustc_middle::ty::instance::resolve_opt_const_arg param_env=ParamEnv { caller_bounds: [], reveal: All }, def=WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs=[^0]
│ │ │ │ │ ├─0ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_FREE_REGIONS | HAS_RE_LATE_BOUND
│ │ │ │ │ ├─0ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_TY_PARAM | HAS_CT_PARAM | HAS_TY_INFER | HAS_CT_INFER | HAS_TY_PLACEHOLDER | HAS_CT_PLACEHOLDER | HAS_FREE_LOCAL_REGIONS | HAS_FREE_LOCAL_NAMES
│ │ │ │ │ ├─0ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_FREE_REGIONS | HAS_RE_LATE_BOUND
│ │ │ │ │ ├─0ms DEBUG rustc_query_system::query::plumbing ty::query::get_query<resolve_instance>(key=ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: (DefId(0:4 ~ issue_64494[317d]::Foo::VAL), [^0]) }, span=src/test/ui/const-generics/issues/issue-64494.rs:1:1: 1:1 (#0))
│ │ │ │ │ ├┐rustc_middle::ty::instance::resolve_opt_const_arg param_env=ParamEnv { caller_bounds: [], reveal: All }, def=WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs=[^0]
│ │ │ │ │ │└┐rustc_ty_utils::instance::resolve_instance key=ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: (DefId(0:4 ~ issue_64494[317d]::Foo::VAL), [^0]) }
│ │ │ │ │ │ ├─0ms DEBUG rustc_query_system::query::plumbing ty::query::get_query<opt_const_param_of>(key=DefId(0:4 ~ issue_64494[317d]::Foo::VAL), span=src/test/ui/const-generics/issues/issue-64494.rs:1:1: 1:1 (#0))
│ │ │ │ │ │ ├─0ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=^0 t.flags=(empty) self.flags=HAS_TY_PARAM | HAS_CT_PARAM | HAS_TY_INFER | HAS_CT_INFER | HAS_TY_PLACEHOLDER | HAS_CT_PLACEHOLDER | HAS_FREE_LOCAL_REGIONS | HAS_FREE_LOCAL_NAMES
│ │ │ │ │ │ ├┐rustc_ty_utils::instance::resolve_instance key=ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: (DefId(0:4 ~ issue_64494[317d]::Foo::VAL), [^0]) }
│ │ │ │ │ │ │└┐rustc_ty_utils::instance::inner_resolve_instance key=ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: (WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, [^0]) }
│ │ │ │ │ │ │ ├─0ms DEBUG rustc_query_system::query::plumbing ty::query::get_query<trait_of_item>(key=DefId(0:4 ~ issue_64494[317d]::Foo::VAL), span=src/test/ui/const-generics/issues/issue-64494.rs:1:1: 1:1 (#0))
│ │ │ │ │ │ │ ├─0ms DEBUG rustc_ty_utils::instance  => associated item, attempting to find impl in param_env ParamEnv {
│ │ │ │ │ │ │ │     caller_bounds: [],
│ │ │ │ │ │ │ │     reveal: All,
│ │ │ │ │ │ │ │ }
│ │ │ │ │ │ │ ├─0ms DEBUG rustc_ty_utils::instance resolve_associated_item(trait_item=DefId(0:4 ~ issue_64494[317d]::Foo::VAL), param_env=ParamEnv { caller_bounds: [], reveal: All }, trait_id=DefId(0:3 ~ issue_64494[317d]::Foo), rcvr_substs=[^0])
│ │ │ │ │ │ │ ├─0ms DEBUG rustc_middle::ty::sty Binder::dummy(<^0 as Foo>)
thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /Users/user/rust/compiler/rustc_middle/src/ty/sty.rs:969:9

@camelid
Copy link
Member Author

camelid commented Apr 6, 2021

The ICE disappears if I remove either of the conflicting impls, so I'm guessing this codepath is caused by coherence checking?

@jackh726
Copy link
Member

jackh726 commented Apr 6, 2021

Possibly. That sounds potentially reasonable. You could probably find that in the log?

@camelid
Copy link
Member Author

camelid commented Apr 6, 2021

Hmm, it seems like the code that is panicking is run after MIR basic block simplification:

│ │ │ ├─25ms DEBUG rustc_mir::transform::simplify simplifying bb0
│ │ │ ├─25ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: c=Const { ty: usize, val: Unevaluated(Unevaluated { def: WithOptConstParam { did
: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs: [T], promoted: None }) } c.flags=HAS_TY_PARAM | HAS_CT_PROJECTION 
| STILL_FURTHER_SPECIALIZABLE self.flags=HAS_FREE_REGIONS

The failed assertion occurs a bit later, I think as part of a chain of function calls? The logs seem to be noisy and it's hard to look through them. I think I'll try looking through the code a bit.

@camelid
Copy link
Member Author

camelid commented Apr 6, 2021

This line looks potentially interesting:

│ │ │ ├─25ms DEBUG rustc_middle::ty::subst shift_vars(val=^0, binders_passed=0, has_escaping_bound_vars=true)

(^0 is the escaping bound variable that causes the failed assertion later on.)

@camelid
Copy link
Member Author

camelid commented Apr 8, 2021

So, I think this is the crucial part of the logs:

│ │ │ ├─21ms DEBUG rustc_mir::transform::simplify simplifying bb0
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: c=Const { ty: usize, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs: [T], promoted: None }) } c.flags=HAS_TY_PARAM | HAS_CT_PROJECTION | STILL_FURTHER_SPECIALIZABLE self.flags=HAS_FREE_REGIONS
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: c=Const { ty: usize, val: Value(Scalar(0x0000000000000005)) } c.flags=(empty) self.flags=HAS_FREE_REGIONS
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=bool t.flags=(empty) self.flags=HAS_FREE_REGIONS
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: c=Const { ty: usize, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:4 ~ issue_64494[317d]::Foo::VAL), const_param_did: None }, substs: [T], promoted: None }) } c.flags=HAS_TY_PARAM | HAS_CT_PROJECTION | STILL_FURTHER_SPECIALIZABLE self.flags=HAS_FREE_REGIONS
│ │ │ ├─21ms DEBUG rustc_mir::const_eval::eval_queries eval_body_using_ecx: GlobalId { instance: Instance { def: Item(WithOptConstParam { did: DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0}), const_param_did: Some(DefId(0:9 ~ issue_64494[317d]::Is::T)) }), substs: [^0] }, promoted: None }, ParamEnv { caller_bounds: [], reveal: UserFacing }
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=bool t.flags=(empty) self.flags=HAS_TY_PARAM | HAS_RE_PARAM | HAS_CT_PARAM | NEEDS_SUBST
│ │ │ ├─21ms DEBUG rustc_middle::ty::normalize_erasing_regions normalize_erasing_regions::<&rustc_middle::ty::TyS>(value=bool, param_env=ParamEnv { caller_bounds: [], reveal: All })
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=bool t.flags=(empty) self.flags=HAS_FREE_REGIONS | HAS_RE_LATE_BOUND
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=bool t.flags=(empty) self.flags=HAS_TY_PROJECTION | HAS_TY_OPAQUE | HAS_CT_PROJECTION | HAS_PROJECTION
│ │ │ ├─21ms DEBUG rustc_middle::ty::fold HasTypeFlagsVisitor: t=bool t.flags=(empty) self.flags=HAS_TY_PARAM | HAS_CT_PARAM | HAS_TY_INFER | HAS_CT_INFER | HAS_TY_PLACEHOLDER | HAS_CT_PLACEHOLDER | HAS_FREE_LOCAL_REGIONS | HAS_FREE_LOCAL_NAMES
│ │ │ ├─21ms DEBUG rustc_middle::ty::print::pretty def_path_str: def_id=DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0}), ns=ValueNS
│ │ │ ├─21ms DEBUG rustc_middle::ty::print::pretty try_print_visible_def_path: def_id=DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0})
│ │ │ ├─21ms DEBUG rustc_middle::ty::print default_print_def_path: def_id=DefId(0:14 ~ issue_64494[317d]::{impl#1}::{constant#0}), substs=[]
│ │ │ ├─21ms DEBUG rustc_middle::ty::print default_print_def_path: key=DefKey { parent: Some(DefIndex(12)), disambiguated_data: DisambiguatedDefPathData { data: AnonConst, disambiguator: 0 } }

(There's a bunch of MIR dataflow stuff before the "simplifying bb0" line. That's
the same "simplifying bb0" line as in my last comment.)

I noticed that the HasTypeFlagsVisitor logs out at the beginning of this
section that substs: [T]. Then, a few lines later, it shows substs: [^0],
which I think is the troublesome bound variable that shows up later.
I think this means that ^0 is T.

I then modified the test so that each T has a unique name and re-ran rustc.
This allowed me to see that the T in the logs above is the T declared in the
first impl. Given that a lot of the logs are about const generics, I would
assume that the part of the code that triggers this code path is the
{T::Val == 5} const generic parameter.

I'm still very new to the trait solving and const generics code, so I don't know
what to try next to get this working. Should I try asking @lcnr or someone
else who's familiar with the const generics code to see if they have ideas about
why this is happening?

@camelid camelid removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 13, 2021
@jackh726
Copy link
Member

Yeah, maybe try asking someone more familiar with the const eval code and if we expect bound vars there (and if so, should we be keeping those around?)

@jackh726 jackh726 added the WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 label May 11, 2021
@jackh726 jackh726 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2021
@jackh726 jackh726 added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 1, 2021
@jackh726
Copy link
Member

@camelid if you want to split out all but the one difficult change for this, that would be nice. Then we could remove Binder::bind and just collect the bound vars in the one place that we need.

@camelid
Copy link
Member Author

camelid commented Jun 29, 2021

Sure, that sounds like a good plan!

@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the binder-bind branch 2 times, most recently from 20934da to 7d09df2 Compare June 29, 2021 02:44
@camelid camelid marked this pull request as ready for review June 29, 2021 02:44
@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 29, 2021
@rust-log-analyzer

This comment has been minimized.

See [1] for motivation.

In one place, it manually uses the `BoundVarsCollector` for now because
we don't know what the bound variables are, and adding support for
tracking the bound variables will probably be a tricky change.

[1]: rust-lang#76814 (comment)
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some comments. Some of these aren't quite actionable. I guess maybe just worth taking a closer look. Maybe adding FIXMEs to remove unneeded code?

@@ -115,7 +116,12 @@ fn resolve_associated_item<'tcx>(
);

let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs);
let vtbl = tcx.codegen_fulfill_obligation((param_env, ty::Binder::bind(trait_ref, tcx)))?;
// FIXME: we should instead track bound variables from their origin,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't want someone to start using BoundVarsCollector for something else. As much as it isn't the right place for it, I think it's better to just move that here until this is fixed. (With a very clear comment on why)

Comment on lines 225 to 229
let (impl_m_own_bounds, _) = infcx.replace_bound_vars_with_fresh_vars(
impl_m_span,
infer::HigherRankedType,
ty::Binder::bind(impl_m_own_bounds.predicates, tcx),
ty::Binder::dummy(impl_m_own_bounds.predicates),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird. If we don't ever have bound vars, why do we have to replace_bound_vars_with_fresh_vars

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think we can remove replace_bound_vars_with_fresh_vars here because impl_m_predicates is simply the Predicates of the impl, which obviously won't have escaping bound vars. And impl_to_placeholder_substs will only have substs for the impl itself, none of which are late-bound.

Comment on lines -1090 to +1096
let self_ty =
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::bind(self_ty, fcx.tcx));
let self_ty = fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::dummy(self_ty));

let receiver_ty = sig.inputs()[0];

let receiver_ty = fcx.normalize_associated_types_in(span, receiver_ty);
let receiver_ty =
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::bind(receiver_ty, fcx.tcx));
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::dummy(receiver_ty));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These again are a bit sus: There aren't late-bound vars, but we're calling liberate_late_bound_regions? (mental note to future me: this bit of code is touched in #85499, did we remove these calls?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay yeah, we liberate_late_bound_regions above, we shouldn't need to do that again here.

@@ -1767,7 +1767,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
}
diag.emit();

ty::Binder::bind(fn_sig, tcx)
ty::Binder::dummy(fn_sig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just move this up to right under fn_sig is created? Then when used, just skip_binder()

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay actually actionable comments

@@ -119,7 +119,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
// We won't add these if we encountered an illegal sized bound, so that we can use
// a custom error in that case.
if illegal_sized_bound.is_none() {
let method_ty = self.tcx.mk_fn_ptr(ty::Binder::bind(method_sig, self.tcx));
let method_ty = self.tcx.mk_fn_ptr(ty::Binder::dummy(method_sig));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this up?

tcx,
),
Binder::dummy(TraitPredicate {
trait_ref: TraitRef::from_method(tcx, trait_id, substs),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preexisting, but why not jsut use the trait_ref create directly above

@@ -404,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligations.extend(traits::predicates_for_generics(cause.clone(), self.param_env, bounds));

// Also add an obligation for the method type being well-formed.
let method_ty = tcx.mk_fn_ptr(ty::Binder::bind(fn_sig, tcx));
let method_ty = tcx.mk_fn_ptr(ty::Binder::dummy(fn_sig));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this up?

Comment on lines -1090 to +1096
let self_ty =
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::bind(self_ty, fcx.tcx));
let self_ty = fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::dummy(self_ty));

let receiver_ty = sig.inputs()[0];

let receiver_ty = fcx.normalize_associated_types_in(span, receiver_ty);
let receiver_ty =
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::bind(receiver_ty, fcx.tcx));
fcx.tcx.liberate_late_bound_regions(method.def_id, ty::Binder::dummy(receiver_ty));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay yeah, we liberate_late_bound_regions above, we shouldn't need to do that again here.

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2021
@jackh726
Copy link
Member

jackh726 commented Jul 2, 2021

Changes here were rolled into #86795. Thanks @camelid!

@jackh726 jackh726 closed this Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-compiletime Issue: Problems and improvements with respect to compile times. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants