Stream: t-compiler/help

Topic: #72675: Eq using ptr equality for Consts


lcnr (May 29 2020 at 21:11, on Zulip):

I am currently looking into using ptr equality when comparing ty::Const.

As this would break interning afaict, I added a new struct InternedConst for which I derived all of Hash, Eq and HashStable which is use as a value` in https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sharded/type.ShardedHashMap.html#method.intern

lcnr (May 29 2020 at 21:11, on Zulip):

This leads to the following errors however:

forcing query with already existing `DepNode`
- query-key: Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(<[T; N] as array::LengthAtMost32>)), Binder(TraitPredicate(<T as marker::Sized>))], reveal: UserFacing, def_id: None }, value: array::iter::IntoIter<T, N> } }
- dep-node: implied_outlives_bounds(4f246e06f2621b4f-6e0eacf16f43cb9)
lcnr (May 29 2020 at 21:13, on Zulip):

I probably have a fundamental misunderstanding here and need some pointers to make progress.

oli (May 30 2020 at 09:16, on Zulip):

ty::Const is inherently broken for basically anything but integer constants and &str and &[u8]

oli (May 30 2020 at 09:18, on Zulip):

I'm not sure how you're intending to use InternedConst and what criteria something needs to fulfil to be a legal InternedConst

oli (May 30 2020 at 09:18, on Zulip):

can you elaborate on how you're planning to use it?

lcnr (May 30 2020 at 09:22, on Zulip):

ty::Const is inherently broken for basically anything but integer constants and &str and &[u8]

can you elaborate here?

oli (May 30 2020 at 09:23, on Zulip):

There are a few things happening here: two constants of type &i32 do not necessarily compare equal (and I mean the PartialEq impl on ty::Const)

oli (May 30 2020 at 09:23, on Zulip):

An Unevaluated ty::Const is not equal to any other unevaluated const

oli (May 30 2020 at 09:23, on Zulip):

or even an evaluated const

oli (May 30 2020 at 09:23, on Zulip):

even if evaluation were possible and yielded the same result

oli (May 30 2020 at 09:24, on Zulip):

A static's ty::Const is never equal to any other ty::Const

oli (May 30 2020 at 09:24, on Zulip):

I probably forgot some others

Notification Bot (May 30 2020 at 09:27, on Zulip):

This topic was moved by oli to #t-compiler/const-eval > #72675: Eq using ptr equality for Consts

Last update: Sep 27 2020 at 14:15UTC