3

Add a separate error for `dyn Trait` in `const fn` by WaffleLapkin · Pull Reques...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/89021
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

@estebank estebank on Sep 17

For the cases of fields like this one it would be nice to have a span_note pointing at the type and field's type to show how it is a trait object.

Copy link

Contributor

Author

@WaffleLapkin WaffleLapkin on Sep 17

It would be really nice! Can we implement this though? It seems like we only check locals and not expressions:

for (idx, local) in body.local_decls.iter_enumerated() { // Handle the return place below. if idx == RETURN_PLACE || local.internal { continue; } self.span = local.source_info.span; self.check_local_or_return_ty(local.ty, idx); } // impl trait is gone in MIR, so check the return type of a const fn by its signature // instead of the type of the return place. self.span = body.local_decls[RETURN_PLACE].source_info.span; let return_ty = tcx.fn_sig(def_id).output(); self.check_local_or_return_ty(return_ty.skip_binder(), RETURN_PLACE);

Copy link

Contributor

@estebank estebank on Sep 17

I'm not sure if we can't get that info from local.local_info or local.source_info (I'm not that familiar with const eval and have to relearn it every time I look at it).

Copy link

Contributor

Author

@WaffleLapkin WaffleLapkin on Sep 18

Hm, after reading docs I can't see how we can get the expression, but maybe I'm missing something

Copy link

Contributor

@estebank estebank 29 days ago

edited

Can you check what the contents of local.local_info are? I assume it is going to be a VarBindingForm. If it is, what are the contents of opt_match_place?

Alternatively, if the data isn't there, it could potentially be added.

Copy link

Contributor

Author

@WaffleLapkin WaffleLapkin 27 days ago

So in the case of our interest (field access) local.local_info is simply None :(

Copy link

Contributor

@estebank estebank 27 days ago

In that case, we'll have to make more dramatic changes so that we can track that data :-/

It's probably not high priority, but if you desire to take that on, I'd be more than happy to see it through!

Copy link

Contributor

Author

@WaffleLapkin WaffleLapkin 27 days ago

I don't think I'm interested enough in that. Thanks for offering help though!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK