Repository: rust
Issue: Internal Compiler Error working with Enum, Match
Labels: I-ICE,T-compiler,A-incr-comp,C-bug,S-needs-repro

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.

http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/

-->

### Code

```
enum Location {
    Unknown,
    Anonymous,
    Known(f64,f64)
}

impl Location {
    fn display(&self) {
        match *self {
            Location::Unknown => println!("Location unknown"),
            Location::Anonymous => println!("Location anonymous"),
            Location::Known(lat,lon) => println!("Latitude: {}, Longitude: {}", lat, lon)
        }
    }
}

fn main() {
    let address = Location::Unknown;
    address.display();
    let address = Location::Anonymous;
    address.display();
    let address = Location::Known(28.608295, -80.604177);
    address.display();
}



```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: aarch64-apple-darwin
release: 1.60.0
LLVM version: 14.0.0
```

### Error output

```
could not compile `challenge14`
Caused by:
  process didn't exit successfully: `/Users/michaeldavila/.cargo/bin/rustc --crate-name challenge14 --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=3a20c5034e3db8b2 -C extra-filename=-3a20c5034e3db8b2 --out-dir /Users/michaeldavila/Library/CloudStorage/OneDrive-UniversityofTexasatArlington/CLionProjects/challenge14/target/debug/deps -C incremental=/Users/michaeldavila/Library/CloudStorage/OneDrive-UniversityofTexasatArlington/CLionProjects/challenge14/target/debug/incremental -L dependency=/Users/michaeldavila/Library/CloudStorage/OneDrive-UniversityofTexasatArlington/CLionProjects/challenge14/target/debug/deps` (signal: 6, SIGABRT: process abort signal)
Process finished with exit code 101

```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_option::<core::option::Option<rustc_span::symbol::Symbol>, <core::option::Option<rustc_span::symbol::Symbol> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
   3: <rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   4: <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>
   5: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>::{closure#0}, core::option::Option<rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>>
   6: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>
   7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::ArenaCache<rustc_span::def_id::DefId, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>>
   8: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::codegen_fn_attrs, rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_middle::ty::instance::InstanceDef>::requires_caller_location
  10: <rustc_middle::ty::instance::Instance>::resolve_for_fn_ptr
  11: <rustc_monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_rvalue
  12: rustc_monomorphize::collector::collect_neighbours
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
  17: rustc_monomorphize::collector::collect_crate_mono_items
  18: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  19: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>
  20: rustc_data_structures::stack::ensure_sufficient_stack::<((&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit]), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>::{closure#3}>
  21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>>
  22: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::collect_and_partition_mono_items, rustc_query_impl::plumbing::QueryCtxt>
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  24: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  25: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
  26: <rustc_interface::queries::Queries>::ongoing_codegen
  27: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
```

</p>
</details>