-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
ICE(stable): thread 'rustc' panicked at 'called Option::unwrap()
on a None
value', compiler/rustc_middle/src/ty/instance.rs:434:85
#80706
Comments
Slightly smaller: use futures::future::BoxFuture;
fn main() {
f();
}
#[tokio::main]
async fn f() {
run("dependency").await;
}
struct InMemoryStorage;
struct User<'dep> {
dep: &'dep str,
}
impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> {
fn execute(&self) -> BoxFuture<Result<(), String>> {
todo!()
}
}
trait Storage {
type Error;
}
impl Storage for InMemoryStorage {
type Error = String;
}
trait StorageRequestReturnType {
type Output;
}
trait StorageRequest<S: Storage>: StorageRequestReturnType {
fn execute(
&self,
) -> BoxFuture<Result<<Self as StorageRequestReturnType>::Output, <S as Storage>::Error>>;
}
struct SaveUser<'a> {
name: &'a str,
}
impl<'a> StorageRequestReturnType for SaveUser<'a> {
type Output = ();
}
impl<'dep> User<'dep> {
async fn save<S>(self)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
SaveUser { name: "Joe" }
.execute()
.await;
}
}
async fn run<S>(dep: &str)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
User { dep }.save().await;
} There are a few strange things about this:
Backtrace
|
Relevant code: rust/compiler/rustc_middle/src/ty/instance.rs Line 434 in 9919ad6
rust/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs Lines 221 to 233 in 9919ad6
|
Removing Edit: Should it be labeled with some priority as it is an ICE on Stable? |
Option::unwrap()
on a None
value', compiler/rustc_middle/src/ty/instance.rs:434:85Option::unwrap()
on a None
value', compiler/rustc_middle/src/ty/instance.rs:434:85
@fominok can you remove 'dep and post the new code? I don't have time right now.
Normally issues aren't prioritized unless they're regressions or unsound, but I can make an exception since you asked nicely :) |
@jyn514 it's up to you, but many thanks anyway! I just tried to remove 'dep for a simplified example you posted and it compiles, but it doesn't compile for a snippet I posted first, so here is a version that sill larger than yours, but without lifetime parameter for a User struct:
|
Turns out this is a regression: the code works on 1.47 and ICEs on 1.48. searched nightlies: from nightly-2020-08-24 to nightly-2020-11-14 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --preserve --start=2020-08-24 --end=2020-11-14 -- build @rustbot label regression-from-stable-to-stable also, since no-one's posted a reduction without the use of async/await: @rustbot label A-async-await |
rustbot did not like that, huh @rustbot label A-async-await |
Here's a no-dependency version that gives the alternate ICE from #80706 (comment). type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output=T>>>;
fn main() {
f();
}
async fn f() {
run("dependency").await;
}
struct InMemoryStorage;
struct User<'dep> {
dep: &'dep str,
}
impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> {
fn execute(&self) -> BoxFuture<Result<(), String>> {
todo!()
}
}
trait Storage {
type Error;
}
impl Storage for InMemoryStorage {
type Error = String;
}
trait StorageRequestReturnType {
type Output;
}
trait StorageRequest<S: Storage>: StorageRequestReturnType {
fn execute(
&self,
) -> BoxFuture<Result<<Self as StorageRequestReturnType>::Output, <S as Storage>::Error>>;
}
struct SaveUser<'a> {
name: &'a str,
}
impl<'a> StorageRequestReturnType for SaveUser<'a> {
type Output = ();
}
impl<'dep> User<'dep> {
async fn save<S>(self)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
SaveUser { name: "Joe" }
.execute()
.await;
}
}
async fn run<S>(dep: &str)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
User { dep }.save().await;
} |
@jyn514 To my understanding, this is expected. A function needs to be used in order to be monomorphized; otherwise what whould it be monomorphized to? So, if the bug happens during monomorphization, it should only happen for functions that are actually used (and thus instantiated). |
Assigning |
In the minimized version above (#80706 (comment)), codegenning debuginfo fails because it doesn't know the layout of the unnormalized type @lcnr, do you know why #78410 might have caused this type to remain unnormalized? |
|
It could, but it should already have been done (unless I'm confused). So either |
Fixed by #85499, but not sure how. Going to mark as needs-test, since this case is different from others. |
This ICE has since regressed. #88640 added a test but marked it as check-pass. This did not reproduce the failure which only occurs when codegen runs.
Backtrace
|
all examples seem to run now, marking as |
@rustbot claim |
visiting for P-high review. from what I can tell from the dialogue here, https://github.com/rust-lang/rust/blob/master/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs is the test we want, and is now correctly marked as build-pass thanks to PR #95031 closing as fixed |
Code
EDIT: MCVE is here.
Meta
Also reproducible on beta and nightly;
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: