Stream: t-compiler/help

Topic: normalize constants


Bastian Kauschke (Mar 23 2020 at 11:03, on Zulip):

@eddyb @varkor I would like to work on https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708
as it seems like this is needed to fix https://github.com/rust-lang/rust/issues/63695

As I don't yet understand what exactly has to be done here I need some guidance.
In case you don't have enough time for this I would just work on something else for now.

eddyb (Mar 23 2020 at 12:15, on Zulip):

the first one is the important one, in src/librustc/ty/normalize_erasing_regions.rs

eddyb (Mar 23 2020 at 12:16, on Zulip):

basically you can add normalize_const_after_erasing_regions, or maybe even better generalize normalize_ty_after_erasing_regions to normalize_generic_rg_after_erasing_regions and make it take GenericArg<'tcx> instead of Ty<'tcx>

eddyb (Mar 23 2020 at 12:16, on Zulip):

then you can have a fold_const just like fold_ty

eddyb (Mar 23 2020 at 12:17, on Zulip):

which makes me wonder, how many fold_tys and visit_ty there are that are missing a fold_const/visit_const

Bastian Kauschke (Mar 23 2020 at 13:23, on Zulip):

I don't quite know what normalize_const_after_erasing_regions should do. :sweat_smile:

My guess is:

eddyb (Mar 23 2020 at 13:25, on Zulip):

@Bastian Kauschke you don't have to do anything yourself

eddyb (Mar 23 2020 at 13:25, on Zulip):

the query just exists to cache things

eddyb (Mar 23 2020 at 13:27, on Zulip):

@Bastian Kauschke all of this code should compile even if ty: Ty is replaced with ct: Const basically https://github.com/rust-lang/rust/blob/131772c5e0ba40cd656dedb5e1990d36e3ea31cf/src/librustc_traits/normalize_erasing_regions.rs#L13-L39

eddyb (Mar 23 2020 at 13:27, on Zulip):

most of the infrastructure is just generic code built on visitable/foldable types

eddyb (Mar 23 2020 at 13:31, on Zulip):

@Bastian Kauschke anyway if you take my second suggestion and generalize the Ty form to GenericArg, that will result in no code duplication

eddyb (Mar 23 2020 at 13:52, on Zulip):

@Bastian Kauschke so I looked at all fold_tys and it looks like the only one that's missing a fold_const counterpart is in normalize_erasing_regions, and I'll let you handle it

eddyb (Mar 23 2020 at 14:18, on Zulip):

opened #70317

Bastian Kauschke (Mar 23 2020 at 15:00, on Zulip):

@eddyb My current WIP causes a strange failure which I don't fully understand. https://github.com/rust-lang/rust/pull/70319

I will try and look into it in more detail later.

eddyb (Mar 23 2020 at 15:05, on Zulip):

@Bastian Kauschke the ICE? that looks like something I was explaining on some issue that we should ban for now because it's impossible to support

eddyb (Mar 23 2020 at 15:06, on Zulip):

ah no the builtins thing

eddyb (Mar 23 2020 at 15:07, on Zulip):

@Bastian Kauschke it's possible the builtins thing is because of the second half of https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708

eddyb (Mar 23 2020 at 15:10, on Zulip):

basically there is missing symmetry between visit_ty and visit_const

varkor (Mar 23 2020 at 16:09, on Zulip):

eddyb said:

which makes me wonder, how many fold_tys and visit_ty there are that are missing a fold_const/visit_const

I did audit the fold_ty and visit_tys at one point, either adding the *_const version, or at least adding FIXME(const_generics) comments
however, that's not to say that more have been added in the interim without accompanying const versions (or that I didn't miss a few)

eddyb (Mar 23 2020 at 16:34, on Zulip):

@varkor see #70317

Bastian Kauschke (Mar 23 2020 at 18:46, on Zulip):

https://github.com/rust-lang/rust/pull/70319 should now be ready for review again

Bastian Kauschke (Mar 23 2020 at 19:43, on Zulip):

I don't have anything to do now :shock: are some some topics/ issues which I can work on?

Bastian Kauschke (Mar 23 2020 at 21:27, on Zulip):

how can I add a span to a cycle error?

oli (Mar 23 2020 at 21:32, on Zulip):

use tcx.at(span).your_query when calling a query

Last update: Apr 03 2020 at 18:20UTC