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

Revert the LazyConst PR #59178

Merged
merged 1 commit into from
Mar 17, 2019
Merged

Revert the LazyConst PR #59178

merged 1 commit into from
Mar 17, 2019

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 14, 2019

The introduction of LazyConst did not actually achieve the code simplicity improvements that were the main reason it was introduced. Especially in the presence of const generics, the differences between the "levels of evaluatedness" of a constant become less clear. As it can be seen by the changes in this PR, further simplifications were possible by folding LazyConst back into ConstValue. We have been able to keep all the advantages gained during the LazyConst refactoring (like const_eval not returning an interned value, thus making all the match code simpler and more performant).

fixes #59209

r? @eddyb @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 14, 2019
@@ -42,6 +43,10 @@ pub enum ConstValue<'tcx> {
/// An allocation together with a pointer into the allocation.
/// Invariant: the pointer's `AllocId` resolves to the allocation.
ByRef(Pointer, &'tcx Allocation),

/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
/// variants if the code is monomorphic enough for that.
Copy link
Member

Choose a reason for hiding this comment

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

IMO this should be at the top with Param / Infer - but also, I wouldn't mind having Scalar, Slice and ByRef in a sub-enum, because they are the "concrete values".

Maybe keep only Scalar, Slice and ByRef here and move everything else to a ty::ConstKind enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such a change will cause major fallout and be very bitrotty. I can do that in a separate PR after const generics has been merged as to not block the const generics work.

Copy link
Member

Choose a reason for hiding this comment

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

I guess, I was just hoping to avoid having "known value" methods on the general type.

However, IIRC miri uses its own enum for values so this should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opened as #59210

@@ -2276,6 +2230,10 @@ impl<'tcx> Const<'tcx> {
}
}
}
ConstValue::Unevaluated(..) => {
flags |= TypeFlags::HAS_NORMALIZABLE_PROJECTION;
flags |= TypeFlags::HAS_PROJECTION;
Copy link
Member

Choose a reason for hiding this comment

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

You need to include flags from the substs, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Basically treat Unevaluated like ty::{Adt,Projection,UnnormalizedProjection} - unless they differ on something, in which case it needs to be looked at in more detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

those are included via the add_const method that calls this method. All of that logic is slightly weirdly distributed. Not sure what's going on there. We should refactor these somewhat, but that's a preexisting issue.

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'm confused as to why this Const::type_flags method even exists, I'll look into it a bit.

Copy link
Member

Choose a reason for hiding this comment

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

Ah looks like this is a mistake from the const generics work, mimicking RegionKind (which idk why it has a type_flags method but it's not great).

This should be inlined/moved into add_const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opened #59209 to track it

Copy link
Member

Choose a reason for hiding this comment

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

Oh I wanted you to do it here since it should be pretty easy (only one call site) and so I can actually review it. I can't tell very well if this is correct because it's awkwardly split into two.

@eddyb
Copy link
Member

eddyb commented Mar 14, 2019

r=me with nits fixed

@bors p=77

@@ -411,8 +411,9 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
};
if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) {
let substs = tcx.lift_to_global(&substs).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do substs need to be lifted here? If substs needed inference but the const still evaluated successfully, doesn't that mean we can just use InternalSubsts::empty() here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or am I misunderstanding what's happening here?

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 confusing - InternalSubsts::empty() would be wrong, but I'm wondering why there is any substitution at all, maybe this is from the time when this could return e.g. function pointers referring to generic parameters?

IMO const_eval should either return an (interned) &'tcx ty::Const, or the Scalar | Slice | ByRef enum by value, not what it does now.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, nevermind, const_eval returns the type as well, which could depend on parameters and whatnot (especially lifetime ones!).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, cool, makes sense. The reason I ask is that this blows up on array lengths that use generic parameters when they have a real param_env.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Mar 15, 2019

📌 Commit 336d42a8448417e7aa7cc6bd1eb925f2b9a296a8 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 15, 2019
@RalfJung
Copy link
Member

Could you add some explanation about why this is getting reverted?

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

Could you add some explanation about why this is getting reverted?

I added an explanation to the main post

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Mar 15, 2019

📌 Commit ae00a0f69f5caa8921cacec6a9953c3b12b85775 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 15, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

@bors r-

I'm getting odd failures, I must be setting the flags wrong or otherwise mishandling const generics

DEBUG 2019-03-15T15:53:54Z: rustc_typeck::check::writeback: write_ty_to_tables(HirId { owner: DefIndex(0:6), local_id: 6 }, fn() -> i32 {i32_identity<X : i32>})
thread 'rustc' panicked at 'assertion failed: !ty.needs_infer() && !ty.has_placeholders()', src/librustc_typeck/check/writeback.rs:119:9

EDIT: nevermind... I just messed up some copy pasting

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 15, 2019
@bors
Copy link
Contributor

bors commented Mar 15, 2019

☔ The latest upstream changes (presumably #58140) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 15, 2019
@bors
Copy link
Contributor

bors commented Mar 15, 2019

⌛ Testing commit bb1d27b9653147f35e09f95dbc7847271201ec8d with merge a0334b6dbba8370396b7a01490dd28d13e59b502...

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:007c3fe0:start=1552677138731564164,finish=1552677141169742334,duration=2438178170
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[00:06:23]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:06:36]    Compiling synstructure v0.10.1
[00:06:57]    Compiling rustc_macros v0.1.0 (/checkout/src/librustc_macros)
[00:07:51]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:08:23] error[E0277]: the trait bound `mir::interpret::value::ConstValue<'_>: ty::context::Lift<'_>` is not satisfied
[00:08:23]     --> src/librustc/ty/print/pretty.rs:1399:25
[00:08:23] 1394 | / macro_rules! forward_display_to_print {
[00:08:23] 1394 | / macro_rules! forward_display_to_print {
[00:08:23] 1395 | |     ($($ty:ty),+) => {
[00:08:23] 1396 | |         $(impl fmt::Display for $ty {
[00:08:23] 1397 | |             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
[00:08:23] 1398 | |                 ty::tls::with(|tcx| {
[00:08:23] 1399 | |                     tcx.lift(self)
[00:08:23]      | |                         ^^^^ the trait `ty::context::Lift<'_>` is not implemented for `mir::interpret::value::ConstValue<'_>`
[00:08:23] 1406 | |     };
[00:08:23] 1407 | | }
[00:08:23]      | |_- in this expansion of `forward_display_to_print!`
[00:08:23] 1408 | 
[00:08:23] 1408 | 
[00:08:23] 1409 | / macro_rules! define_print_and_forward_display {
[00:08:23] 1410 | |     (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
[00:08:23] 1411 | |         $(impl<'gcx: 'tcx, 'tcx, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for $ty {
[00:08:23] 1412 | |             type Output = P;
[00:08:23] ...    |
[00:08:23] 1424 | |         forward_display_to_print!($($ty),+);
[00:08:23] 1425 | |     };
[00:08:23] 1426 | | }
[00:08:23]      | |_- in this expansion of `define_print_and_forward_display!`
[00:08:23] ...
[00:08:23] ...
[00:08:23] 1457 | / define_print_and_forward_display! {
[00:08:23] 1458 | |     (self, cx):
[00:08:23] 1459 | |
[00:08:23] 1460 | |     &'tcx ty::List<Ty<'tcx>> {
[00:08:23] 1607 | |     }
[00:08:23] 1608 | | }
[00:08:23]      | |_- in this macro invocation
[00:08:23] 
[00:08:23] 
[00:08:23] error[E0277]: the trait bound `ty::sty::Const<'_>: ty::context::Lift<'_>` is not satisfied
[00:08:23]     --> src/librustc/ty/print/pretty.rs:1399:25
[00:08:23] 1394 | / macro_rules! forward_display_to_print {
[00:08:23] 1394 | / macro_rules! forward_display_to_print {
[00:08:23] 1395 | |     ($($ty:ty),+) => {
[00:08:23] 1396 | |         $(impl fmt::Display for $ty {
[00:08:23] 1397 | |             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
[00:08:23] 1398 | |                 ty::tls::with(|tcx| {
[00:08:23] 1399 | |                     tcx.lift(self)
[00:08:23]      | |                         ^^^^ the trait `ty::context::Lift<'_>` is not implemented for `ty::sty::Const<'_>`
[00:08:23] 1406 | |     };
[00:08:23] 1407 | | }
[00:08:23]      | |_- in this expansion of `forward_display_to_print!`
[00:08:23] 1408 | 
[00:08:23] 1408 | 
[00:08:23] 1409 | / macro_rules! define_print_and_forward_display {
[00:08:23] 1410 | |     (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
[00:08:23] 1411 | |         $(impl<'gcx: 'tcx, 'tcx, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for $ty {
[00:08:23] 1412 | |             type Output = P;
[00:08:23] ...    |
[00:08:23] 1424 | |         forward_display_to_print!($($ty),+);
[00:08:23] 1425 | |     };
[00:08:23] 1426 | | }
[00:08:23]      | |_- in this expansion of `define_print_and_forward_display!`
[00:08:23] ...
[00:08:23] ...
[00:08:23] 1457 | / define_print_and_forward_display! {
[00:08:23] 1458 | |     (self, cx):
[00:08:23] 1459 | |
[00:08:23] 1460 | |     &'tcx ty::List<Ty<'tcx>> {
[00:08:23] 1607 | |     }
[00:08:23] 1608 | | }
[00:08:23]      | |_- in this macro invocation
[00:08:23]      |
[00:08:23]      |
[00:08:23]      = help: the following implementations were found:
[00:08:23]                <&'a ty::sty::Const<'a> as ty::context::Lift<'tcx>>
[00:08:27] error: aborting due to 2 previous errors
[00:08:27] 
[00:08:27] For more information about this error, try `rustc --explain E0277`.
[00:08:27] error: Could not compile `rustc`.
---
travis_time:end:252507ec:start=1552677660801931999,finish=1552677660806864477,duration=4932478
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0237e372
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:30cc9006
travis_time:start:30cc9006
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:02a25daa
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2019

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 15, 2019
@bors
Copy link
Contributor

bors commented Mar 15, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-debug of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:04:29]     Checking rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:04:52]    Compiling synstructure v0.10.1
[00:04:58]     Checking syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:05:07]    Compiling rustc_macros v0.1.0 (/checkout/src/librustc_macros)
[00:05:29] error[E0277]: the trait bound `mir::interpret::value::ConstValue<'_>: ty::context::Lift<'_>` is not satisfied
[00:05:29]     --> src/librustc/ty/print/pretty.rs:1399:25
[00:05:29] 1394 | / macro_rules! forward_display_to_print {
[00:05:29] 1394 | / macro_rules! forward_display_to_print {
[00:05:29] 1395 | |     ($($ty:ty),+) => {
[00:05:29] 1396 | |         $(impl fmt::Display for $ty {
[00:05:29] 1397 | |             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
[00:05:29] 1398 | |                 ty::tls::with(|tcx| {
[00:05:29] 1399 | |                     tcx.lift(self)
[00:05:29]      | |                         ^^^^ the trait `ty::context::Lift<'_>` is not implemented for `mir::interpret::value::ConstValue<'_>`
[00:05:29] 1406 | |     };
[00:05:29] 1407 | | }
[00:05:29]      | |_- in this expansion of `forward_display_to_print!`
[00:05:29] 1408 | 
[00:05:29] 1408 | 
[00:05:29] 1409 | / macro_rules! define_print_and_forward_display {
[00:05:29] 1410 | |     (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
[00:05:29] 1411 | |         $(impl<'gcx: 'tcx, 'tcx, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for $ty {
[00:05:29] 1412 | |             type Output = P;
[00:05:29] ...    |
[00:05:29] 1424 | |         forward_display_to_print!($($ty),+);
[00:05:29] 1425 | |     };
[00:05:29] 1426 | | }
[00:05:29]      | |_- in this expansion of `define_print_and_forward_display!`
[00:05:29] ...
[00:05:29] ...
[00:05:29] 1457 | / define_print_and_forward_display! {
[00:05:29] 1458 | |     (self, cx):
[00:05:29] 1459 | |
[00:05:29] 1460 | |     &'tcx ty::List<Ty<'tcx>> {
[00:05:29] 1607 | |     }
[00:05:29] 1608 | | }
[00:05:29]      | |_- in this macro invocation
[00:05:29] 
[00:05:29] 
[00:05:29] error[E0277]: the trait bound `ty::sty::Const<'_>: ty::context::Lift<'_>` is not satisfied
[00:05:29]     --> src/librustc/ty/print/pretty.rs:1399:25
[00:05:29] 1394 | / macro_rules! forward_display_to_print {
[00:05:29] 1394 | / macro_rules! forward_display_to_print {
[00:05:29] 1395 | |     ($($ty:ty),+) => {
[00:05:29] 1396 | |         $(impl fmt::Display for $ty {
[00:05:29] 1397 | |             fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
[00:05:29] 1398 | |                 ty::tls::with(|tcx| {
[00:05:29] 1399 | |                     tcx.lift(self)
[00:05:29]      | |                         ^^^^ the trait `ty::context::Lift<'_>` is not implemented for `ty::sty::Const<'_>`
[00:05:29] 1406 | |     };
[00:05:29] 1407 | | }
[00:05:29]      | |_- in this expansion of `forward_display_to_print!`
[00:05:29] 1408 | 
[00:05:29] 1408 | 
[00:05:29] 1409 | / macro_rules! define_print_and_forward_display {
[00:05:29] 1410 | |     (($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
[00:05:29] 1411 | |         $(impl<'gcx: 'tcx, 'tcx, P: PrettyPrinter<'gcx, 'tcx>> Print<'gcx, 'tcx, P> for $ty {
[00:05:29] 1412 | |             type Output = P;
[00:05:29] ...    |
[00:05:29] 1424 | |         forward_display_to_print!($($ty),+);
[00:05:29] 1425 | |     };
[00:05:29] 1426 | | }
[00:05:29]      | |_- in this expansion of `define_print_and_forward_display!`
[00:05:29] ...
[00:05:29] ...
[00:05:29] 1457 | / define_print_and_forward_display! {
[00:05:29] 1458 | |     (self, cx):
[00:05:29] 1459 | |
[00:05:29] 1460 | |     &'tcx ty::List<Ty<'tcx>> {
[00:05:29] 1607 | |     }
[00:05:29] 1608 | | }
[00:05:29]      | |_- in this macro invocation
[00:05:29]      |
[00:05:29]      |
[00:05:29]      = help: the following implementations were found:
[00:05:29]                <&'a ty::sty::Const<'a> as ty::context::Lift<'tcx>>
[00:05:33] error: aborting due to 2 previous errors
[00:05:33] 
[00:05:33] For more information about this error, try `rustc --explain E0277`.
[00:05:33] error: Could not compile `rustc`.
---
travis_time:end:06a575a2:start=1552677830732770050,finish=1552677830738623554,duration=5853504
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2027ee70
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:103ab790
travis_time:start:103ab790
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0065031c
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors bors 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 Mar 15, 2019
@kennytm kennytm 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 Mar 16, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 17, 2019

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Mar 17, 2019

📌 Commit 5cd2806 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 17, 2019
@bors
Copy link
Contributor

bors commented Mar 17, 2019

⌛ Testing commit 5cd2806 with merge 070cebd...

bors added a commit that referenced this pull request Mar 17, 2019
Revert the `LazyConst` PR

The introduction of `LazyConst` did not actually achieve the code simplicity improvements that were the main reason it was introduced. Especially in the presence of const generics, the differences between the "levels of evaluatedness" of a constant become less clear. As it can be seen by the changes in this PR, further simplifications were possible by folding `LazyConst` back into `ConstValue`. We have been able to keep all the advantages gained during the `LazyConst` refactoring (like `const_eval` not returning an interned value, thus making all the `match` code simpler and more performant).

fixes #59209

r? @eddyb @varkor
@bors
Copy link
Contributor

bors commented Mar 17, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: eddyb
Pushing 070cebd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 17, 2019
@bors bors merged commit 5cd2806 into rust-lang:master Mar 17, 2019
} else {
c.super_visit_with(self)
}
flags.intersects(self.flags) || c.super_visit_with(self)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need the || ... recursion part, since the flags should be complete.


&'tcx ty::LazyConst<'tcx> {
match self {
// FIXME(const_generics) this should print at least the type.
Copy link
Member

Choose a reason for hiding this comment

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

You deleted this important comment - it should be wherever the Unevaluated case ends up. cc @varkor

instantiated_predicates,
location.to_locations(),
);
}
Copy link
Member

Choose a reason for hiding this comment

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

cc @nikomatsakis this code seems waay too specific (unless it applies to TerminatorKind::Call callees?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type_flags method on ty::Const is a footgun
7 participants