Closed
Description
cat hang.rs
pub type ISO<A: 'static, B: 'static> = (Box<dyn Fn(A) -> B>, Box<dyn Fn(B) -> A>);
pub fn iso<A: 'static, B: 'static, F1, F2>(a: F1, b: F2) -> ISO<A, B>
where
F1: 'static + Fn(A) -> B,
F2: 'static + Fn(B) -> A,
{
(Box::new(a), Box::new(b))
}
pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, Option<B>>) -> ISO<A, B> {
let (ab, ba) = (i.ab, i.ba);
let left = move |o_a| match o_a {
None => panic!("absured"),
Some(a) => a,
};
let right = move |o_b| match o_b {
None => panic!("absurd"),
Some(b) => b,
};
iso(left, right)
}
pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, B>) -> ISO<A, B> {
let (ab, ba) = (i.ab, i.ba);
let left = move |o_a| match o_a {
None => panic!("absured"),
Some(a) => a,
};
let right = move |o_b| match o_b {
None => panic!("absurd"),
Some(b) => b,
};
iso(left, right)
}
I expected to see this happen: The compiler compiles successfully or outputs an error message.
Instead, this happened: The code, as provided below, appears to encounter a hang
Command
rustc hang.rs
Meta
rustc --version --verbose
:
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2
The same problem is reproduced on the nightly version(1.75.0-nightly 1c05d50c8 2023-10-21
)
what's more, to get more information,I also tried '-Z time-passes' (using nighly version):
Output
time: 0.001; rss: 28MB -> 31MB ( +2MB) parse_crate
error[E0428]: the name `iso_un_option` is defined multiple times
--> hang.rs:21:1
|
9 | pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, Option<B>>) -> ISO<A, B> {
| --------------------------------------------------------------------------------------- previous definition of the value `iso_un_option` here
...
21 | pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, B>) -> ISO<A, B> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `iso_un_option` redefined here
|
= note: `iso_un_option` must be defined only once in the value namespace of this module
time: 0.008; rss: 34MB -> 50MB ( +16MB) expand_crate
time: 0.008; rss: 34MB -> 50MB ( +16MB) macro_expand_crate
time: 0.001; rss: 50MB -> 53MB ( +3MB) late_resolve_crate
time: 0.002; rss: 50MB -> 53MB ( +3MB) resolve_crate
error[E0601]: `main` function not found in crate `hang`
--> hang.rs:32:2
|
32 | }
| ^ consider adding a `main` function to `hang.rs`
time: 0.007; rss: 53MB -> 59MB ( +6MB) looking_for_entry_point
time: 0.007; rss: 53MB -> 60MB ( +7MB) misc_checking_1
time: 0.002; rss: 60MB -> 66MB ( +6MB) wf_checking
error[E0609]: no field `ab` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'static)>, Box<(dyn Fn(Option<B>) -> Option<A> + 'static)>)`
--> hang.rs:10:23
|
10 | let (ab, ba) = (i.ab, i.ba);
| ^^
error[E0609]: no field `ba` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'static)>, Box<(dyn Fn(Option<B>) -> Option<A> + 'static)>)`
--> hang.rs:10:29
|
10 | let (ab, ba) = (i.ab, i.ba);
|