Stream: t-compiler

Topic: mir borrow checker: current scope's type arguments?


Esteban Küber (Jan 04 2019 at 21:51, on Zulip):

Is there a canonical way to get the current scope's type arguments from the MirBorrowckCtxt
Context: https://github.com/rust-lang/rust/pull/57294
I'd like to get the type argument if the current Ty corresponds to them in order to suggest an appropriate binding restriction.

Esteban Küber (Jan 04 2019 at 21:51, on Zulip):

@nikomatsakis My guess is that you'd be the best person to ask :^)

davidtwco (Jan 04 2019 at 22:05, on Zulip):

Not sure if I've done it before, but I'd try calling generics_of with self.mir_def_id?

davidtwco (Jan 04 2019 at 22:06, on Zulip):

I think that has information about the type parameters.

davidtwco (Jan 04 2019 at 22:08, on Zulip):

If you've got a Ty then you could get the relevant generic from that (assuming it is a ty::TyKind::Param) with the type_param function?

davidtwco (Jan 04 2019 at 22:10, on Zulip):

Not sure if you'd need to start looking at the predicates on the function so you correctly suggest a T: ... + Copy or just T: Copy depending if the user already specified some constraints.

davidtwco (Jan 04 2019 at 22:10, on Zulip):

Just some ideas in case you hadn't looked at those functions already.

Esteban Küber (Jan 04 2019 at 22:13, on Zulip):

That sounds reasonable and promising. I'll take a look at that this weekend.

Esteban Küber (Jan 06 2019 at 23:24, on Zulip):

@davidtwco that worked, thank you! :thumbs_up:

Last update: Nov 22 2019 at 05:30UTC