-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 when using Self as uninitialized return type in trait method #57796
Comments
Wow... this bug is so old, I can reproduce it with nightly-2018-06-01... damn ^^ |
Took my first deep dive into the compiler trying to diagnose this. AFAICT, things first start going wrong when we resolve the The fix I've tried is: diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index cde6eb22bb..21e2466092 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1701,7 +1701,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
// `Self` in impl (we know the concrete type).
assert_eq!(opt_self_ty, None);
self.prohibit_generics(&path.segments);
- tcx.at(span).type_of(def_id)
+ self.normalize_ty(span, tcx.at(span).type_of(def_id))
}
Def::SelfTy(Some(_), None) => {
// `Self` in trait. However, I'm not 100% sure that's the appropriate point to do normalization. Several other branches of the match statement do normalization of types at that point, yet some don't. So it would be great if someone with a tad more experience in the compiler can take a quick look and verify that (a) that's the correct fix (b) that's the only point in FWIW, I've introduced a |
@aoikonomopoulos can you confirm that your fix also fixed #58212 ? |
@hellow554 yah, it ICEs with nightly, but compiles with the above patch. Should I prepare a PR? |
Sure, let's go 🎉 |
I think you can directly do |
@hellow554 Ok, will do. Thanks for the guidance. |
@aoikonomopoulos afaik you don't have to ask for taking testcases that are posted here, but IANAL! You can also take the testcase from #58212 (comment) or this minified version
|
Yah the minified version seems more appropriate too. |
Normalize the type Self resolves to in an impl This is required at the very least in order to evaluate associated constants for arrays. Fixes rust-lang#57796 Fixes rust-lang#58212. r? @oli-obk cc @hellow554
Normalize the type Self resolves to in an impl This is required at the very least in order to evaluate associated constants for arrays. Fixes rust-lang#57796 Fixes rust-lang#58212. r? @oli-obk cc @hellow554
Normalize the type Self resolves to in an impl This is required at the very least in order to evaluate associated constants for arrays. Fixes rust-lang#57796 Fixes rust-lang#58212. r? @oli-obk cc @hellow554
Normalize the type Self resolves to in an impl This is required at the very least in order to evaluate associated constants for arrays. Fixes rust-lang#57796 Fixes rust-lang#58212. r? @oli-obk cc @hellow554
Normalize the type Self resolves to in an impl This is required at the very least in order to evaluate associated constants for arrays. Fixes rust-lang#57796 Fixes rust-lang#58212. r? @oli-obk cc @hellow554
Playground
To make it compile you can simply replace
Self
for[u8; 30]
in theuninitialized
call (Playground)The text was updated successfully, but these errors were encountered: