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

Allow inference regions when relating consts #73225

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/librustc_middle/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,7 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
let tcx = relation.tcx();

let eagerly_eval = |x: &'tcx ty::Const<'tcx>| {
// FIXME(eddyb) this doesn't account for lifetime inference variables
// being erased by `eval`, *nor* for the polymorphic aspect of `eval`.
// That is, we could always use `eval` and it will just return the
// old value back if it doesn't succeed.
if !x.val.needs_infer() {
return x.eval(tcx, relation.param_env()).val;
}
x.val
};
let eagerly_eval = |x: &'tcx ty::Const<'tcx>| x.eval(tcx, relation.param_env()).val;
Copy link
Member

@eddyb eddyb Jun 18, 2020

Choose a reason for hiding this comment

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

I think this makes sense. I left that FIXME comment (and the one below) while working on an unrelated PR #71049 (and glancing at code next to what I was touching). I should've probably filed issues.

At least I don't think this FIXME was a soundness problem, the overzealous check could only lead to types failing to equate (which could mean ICEs, clearly it happened here so it's possible).

This is reminiscent of #70773, where missing normalizations started showing up after we stopped ignoring generics in scope, in #70452.

I wonder if changing this one piece of code in relate makes the extra normalizations added to fix #70773 unnecessary.


// FIXME(eddyb) doesn't look like everything below checks that `a.ty == b.ty`.
// We could probably always assert it early, as `const` generic parameters
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/async-await/issue-73050.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// check-pass
// edition:2018

#[allow(unused)]
async fn foo<'a>() {
let _data = &mut [0u8; { 1 + 4 }];
bar().await
}
Comment on lines +5 to +8
Copy link
Member

Choose a reason for hiding this comment

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

Weird that this would need async, presumably fn foo<'a: 'a> (forcing lifetime parameters aka "early-bound" as opposed to only the signature being lifetime-polymorphic aka "late-bound) would also work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't get it to ICE: playground

The ICE happened when unifying the generator witness with the generator type (IIRC?), so maybe there's something special about that operation.


async fn bar() {}

fn main() {}