Repository navigation
broken MIR in Item (nightly) #99866
Description
Activity
- addedC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Jul 28, 2022 Of course, my bad for not providing this upfront. I've been able to repo it with this setup:
deps/features:
[features] default = ["metal"] dx12 = ["gfx-backend-dx12"] empty = ["gfx-backend-empty"] gl = ["gfx-backend-gl"] metal = ["gfx-backend-metal"] vulkan = ["gfx-backend-vulkan"] [dependencies] gfx-backend-dx12 = { version = "0.6.3", optional = true } gfx-backend-empty = { version = "0.6.0", optional = true } gfx-backend-gl = { version = "0.5.1", optional = true } gfx-backend-metal = { version = "0.6.2", optional = true } gfx-backend-vulkan = { version = "0.6.1", optional = true } gfx-hal = "0.6.0"lib.rs
#[cfg(feature = "metal")] use gfx_backend_metal as back; pub use gfx_hal as hal; #[cfg(feature = "vulkan")] use gfx_backend_vulkan as back; #[cfg(not(any(feature = "metal", feature = "vulkan")))] use gfx_backend_empty as back; pub type B = back::Backend; pub struct Exacterator<I: Iterator<Item = T>, T> { iter: I, size: usize, } impl<I: Iterator<Item = T>, T> Exacterator<I, T> { pub fn new(iter: I, size: usize) -> Self { Self { iter, size } } } impl<I: Iterator<Item = T>, T> Iterator for Exacterator<I, T> { type Item = I::Item; fn next(&mut self) -> Option<Self::Item> { self.iter.next() } fn size_hint(&self) -> (usize, Option<usize>) { (self.size, Some(self.size)) } } impl<I: Iterator<Item = T>, T> ExactSizeIterator for Exacterator<I, T> {} pub trait Exact<T>: Iterator<Item = T> + Sized { fn exact(self, size: usize) -> Exacterator<Self, T>; } impl<I: Iterator<Item = T>, T> Exact<T> for I { fn exact(self, size: usize) -> Exacterator<Self, T> { Exacterator::new(self, size) } } #[derive(Debug)] pub struct HalSetLayouts { vertex_layout: <B as hal::Backend>::DescriptorSetLayout, fragment_layout: <B as hal::Backend>::DescriptorSetLayout, fragment_sampler_layout: <B as hal::Backend>::DescriptorSetLayout, } impl HalSetLayouts { pub fn iter<DSL>(&self) -> impl ExactSizeIterator<Item = &DSL> + '_ where // rust 1.37 fails to typecheck `iter` without this. This is fixed in nightly. B: hal::Backend<DescriptorSetLayout = DSL>, DSL: std::fmt::Debug + Send + Sync + 'static, { std::iter::once(&self.vertex_layout) .chain(std::iter::once(&self.fragment_layout)) .chain(std::iter::once(&self.fragment_sampler_layout)) .exact(3) } }
Here is the MIR for the
iterfunction when I manually disabled validation (I just noticed, validation doesn't have to be disabled,-Zunpretty=mirworks anyways)fn <impl at lol.rs:17:1: 17:19>::iter(_1: HalSetLayouts) -> DSL { debug self => _1; // in scope 0 at lol.rs:18:22: 18:26 let mut _0: DSL; // return place in scope 0 at lol.rs:18:31: 18:34 bb0: { _0 = move (_1.0: DSL); // scope 0 at lol.rs:22:9: 22:27 return; // scope 0 at lol.rs:23:6: 23:6 } }
After looking into this a bit, I got the following:
The body is treating the generic type
DSTand the concrete associated type<Back as Backend>::DescriptorSetLayoutto be of the same type. The MIR validator probably thinks that this is very sketchy and bails out (I haven't looked at it closely).This is actually ok though, since in the where bounds
DSTis constrained to be equal to<Back as Backend>::DescriptorSetLayout.To me, this looks like a bug in the MIR validator.
This was probably regressed by #96856. cc @drmeepster
Yes, manually reverting the PR fixed the issue for me locally.
While it regressed in that PR, the PR only called validation that wasn't called before. The validation has been broken for longer.
@rustbot claim
3 remaining items
Oooppsss... Sorry, this test still ICE.
On the bright side, I was able to reduce the compiler arguments to
--crate-type lib --emit=link.- added 9 commits that reference this issue
on Sep 1, 2022 - added a commit that references this issue
on Sep 2, 2022 - added 2 commits that reference this issue
on Sep 2, 2022 - added a commit that references this issue
on Sep 2, 2022
Code
Meta
rustc --version --verbose:Error output
Backtrace
This came from a workaround for what seems to be an old compiler bug. removing the workaround gets ride of the ICE: