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

ICE: "no errors encountered even though delay_span_bug issued" in recursive impl #110623

Closed
WardBrian opened this issue Apr 20, 2023 · 4 comments · Fixed by #116891
Closed

ICE: "no errors encountered even though delay_span_bug issued" in recursive impl #110623

WardBrian opened this issue Apr 20, 2023 · 4 comments · Fixed by #116891
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@WardBrian
Copy link

WardBrian commented Apr 20, 2023

Some code I wrote for the 2022 advent of code fails to compile under the newly released 1.69. It compiled previously under 1.67 and 1.68.

Code

use std::{collections::BTreeMap, num::ParseIntError, str::FromStr};

enum FileSystem {
    File(usize),
    Directory(BTreeMap<String, FileSystem>),
}

impl FromStr for FileSystem {
    type Err = ParseIntError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if s.starts_with("dir") {
            Ok(Self::new_dir())
        } else {
            Ok(Self::File(s.split_whitespace().next().unwrap().parse()?))
        }
    }
}

impl FileSystem {
    fn new_dir() -> FileSystem {
        FileSystem::Directory(BTreeMap::new())
    }

    fn insert(&mut self, name: String, other: FileSystem) -> Option<FileSystem> {
        match self {
            FileSystem::File(_) => panic!("can only insert into directory!"),
            FileSystem::Directory(tree) => tree.insert(name, other),
        }
    }

    // Recursively build a tree from commands. This uses (abuses?)
    // the fact that `cd /` only appears at the start and that
    // subsequent `cd`s can only move ONE level to use the recursion
    // stack as the filesystem stack
    fn build<'a>(
        &mut self,
        mut commands: impl Iterator<Item = &'a str> + 'a,
    ) -> Option<impl Iterator<Item = &'a str> + 'a> {
        let cmd = commands.next()?;
        let mut elements = cmd.lines();
        match elements.next().map(str::trim) {
            Some("cd /") | None => self.build(commands),
            Some("cd ..") => {
                // return to higher scope
                Some(commands)
            }
            Some("ls") => {
                for item in elements {
                    let name = item.split_whitespace().last().unwrap();
                    let prior = self.insert(name.to_string(), item.parse().unwrap());
                    debug_assert!(prior.is_none());
                }
                // continue on
                self.build(commands)
            }
            Some(other_cd) => {
                let name = other_cd
                    .trim()
                    .strip_prefix("cd ")
                    .expect("expected a cd command");
                let mut directory = FileSystem::new_dir();
                let further_commands = directory.build(commands);
                self.insert(name.to_string(), directory);
                self.build(further_commands?) // THIS LINE FAILS TO COMPILE
            }
        }
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7

I also tried with nightly:

rustc 1.71.0-nightly (39c6804b9 2023-04-19)
binary: rustc
commit-hash: 39c6804b92aa202369e402525cee329556bc1db0
commit-date: 2023-04-19
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: opaque type with non-universal region substs
  --> 7/src/main.rs:65:17
   |
65 |                 self.build(further_commands?)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}::{closure#2}
              3: rustc_middle::ty::util::fold_list::<rustc_middle::ty::fold::RegionFolder, rustc_middle::ty::subst::GenericArg, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with<rustc_middle::ty::fold::RegionFolder>::{closure#0}>
              4: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types
              5: rustc_borrowck::nll::compute_regions
              6: rustc_borrowck::do_mir_borrowck
              7: rustc_borrowck::mir_borrowck
              8: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
              9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
             11: rustc_hir_analysis::collect::type_of::type_of
             12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
             13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
             14: rustc_hir_analysis::check::check::check_mod_item_types
             15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             17: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
             18: rustc_hir_analysis::check_crate
             19: rustc_interface::passes::analysis
             20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             22: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             23: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             24: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             25: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             26: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
             27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
             28: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys/unix/thread.rs:108:17
             29: start_thread
                        at ./nptl/./nptl/pthread_create.c:442:8
             30: clone3
                        at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
           

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.69.0 (84c898d65 2023-04-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `seven` (bin "seven") generated 2 warnings
error: could not compile `seven`; 2 warnings emitted
Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: opaque type with non-universal region substs
  --> 7/src/main.rs:65:17
   |
65 |                 self.build(further_commands?)
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types::{closure#0}::{closure#2}
              3: rustc_middle::ty::util::fold_list::<rustc_middle::ty::fold::RegionFolder, rustc_middle::ty::subst::GenericArg, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with<rustc_middle::ty::fold::RegionFolder>::{closure#0}>
              4: <rustc_borrowck::region_infer::RegionInferenceContext>::infer_opaque_types
              5: rustc_borrowck::nll::compute_regions
              6: rustc_borrowck::do_mir_borrowck
              7: rustc_borrowck::mir_borrowck
              8: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
              9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
             10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
             11: rustc_hir_analysis::collect::type_of::type_of
             12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
             13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
             14: rustc_hir_analysis::check::check::check_mod_item_types
             15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             17: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
             18: rustc_hir_analysis::check_crate
             19: rustc_interface::passes::analysis
             20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             22: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             23: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             24: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             25: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             26: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
             27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/alloc/src/boxed.rs:1987:9
             28: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys/unix/thread.rs:108:17
             29: start_thread
                        at ./nptl/./nptl/pthread_create.c:442:8
             30: clone3
                        at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
           

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.69.0 (84c898d65 2023-04-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `seven` (bin "seven") generated 2 warnings
error: could not compile `seven`; 2 warnings emitted

@WardBrian WardBrian added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 20, 2023
@compiler-errors compiler-errors added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Apr 20, 2023
@matthiaskrgr
Copy link
Member

reduced

struct FileSystem;

impl FileSystem {
    fn build<'a>(
        &mut self,
        commands: impl Iterator<Item = &'a str> + 'a,
    ) -> Option<impl Iterator<Item = &'a str> + 'a> {
        let further_commands = self.build(commands);
        self.build(further_commands?)
    }
}

fn main() {}

@matthiaskrgr
Copy link
Member

searched toolchains nightly-2022-03-30 through nightly-2023-04-20
Regression in nightly-2022-03-31

fetching (via local git) commits from 9c06e1b to c5cf08d
opening existing repository at "rust.git"
Found origin remote under name origin
refreshing repository at "rust.git"
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 8 bors merge commits in the specified range
commit[0] 2022-03-29: Auto merge of #95448 - Dylan-DPC:rollup-wpj5yto, r=Dylan-DPC
commit[1] 2022-03-30: Auto merge of #95455 - RalfJung:miri, r=RalfJung
commit[2] 2022-03-30: Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakis
commit[3] 2022-03-30: Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
commit[4] 2022-03-30: Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubilee
commit[5] 2022-03-30: Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-se
commit[6] 2022-03-30: Auto merge of #95458 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
commit[7] 2022-03-30: Auto merge of #95425 - nnethercote:yet-more-parse_tt-improvements, r=petrochenkov
ERROR: no CI builds available between 9c06e1b and c5cf08d within last 167 days

ouff, a bit more than a year 😆

#94081 by @oli-obk looks a bit suspicious imo 🙃

@zirconium-n
Copy link
Contributor

reduced

trait S {}

fn foo<'a>(x: impl S + 'a) -> impl S + 'a {
    foo(foo(x))
}

@zirconium-n
Copy link
Contributor

I will try fix this.

@rustbot claim

@zirconium-n zirconium-n removed their assignment Sep 18, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 19, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 21, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 23, 2023
…2, r=<try>

rework opaque type region inference

fixes rust-lang#113971 Pass -> Error

fixes rust-lang#111906 ICE -> Pass
fixes rust-lang#110623 ==
fixes rust-lang#109059 ==

fixes rust-lang#112841 Pass -> Error

fixes rust-lang#110726 ICE->Error

fixes rust-lang#111935 Pass -> Error
fixes rust-lang#113916 ==

r? `@ghost`
@bors bors closed this as completed in 551abd6 Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants