Skip to content

ICE with trait inheritance/generics #4208

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

Closed
brendanzab opened this issue Dec 17, 2012 · 9 comments
Closed

ICE with trait inheritance/generics #4208

brendanzab opened this issue Dec 17, 2012 · 9 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@brendanzab
Copy link
Member

numeric.rs

#[link(name = "numeric",
       vers = "0.1")];
#[crate_type = "lib"];

pub trait Trig<T> {
    pure fn sin(&self) -> T;
}

pub pure fn sin<T:Trig<R>, R>(theta: &T) -> R { theta.sin() }

pub trait Angle<T>: Trig<T> {}

main.rs

extern mod numeric;
use numeric::*;

fn foo<T, A:Angle<T>>(theta: A) -> T { sin(&theta) }

fn main() {}
$ rustc numeric.rs                           
warning: no debug symbols in executable (-arch x86_64)
$ RUST_LOG=rustc=1,::rt::backtrace rustc -L . main.rs
rust: task failed at 'Key not found in table: 28', /usr/local/src/rust/src/librustc/rustc.rc:1
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /usr/local/src/rust/src/librustc/rustc.rc:481
rust: domain main @0x7fa62380bc10 root task failed
rust: task failed at 'killed', /usr/local/src/rust/src/libcore/task/mod.rs:570
@ghost ghost assigned brson Dec 17, 2012
@brson
Copy link
Contributor

brson commented Dec 18, 2012

There are at least two problems here. The first is that the order in which type parameters are specified appears to be significant. This test fails:

pub trait Trig<T> {
    pure fn sin(&self) -> T;
}

pub trait Angle<T>: Trig<T> {}

pub pure fn sin<A:Angle<R>, R>(theta: &A) -> R { theta.sin() }

fn foo<R, A:Angle<R>>(theta: A) -> R { sin(&theta) }

impl int: Trig<int> {
    pure fn sin(&self) -> int { 10 }
}

impl int: Angle<int> {
}

fn main() {
    assert foo(0) == 10;
}

but if you switch the type parameter order on sin to <R, A:Angle<R> to match foo it works.

The second is some cross-crate issue with inheritance.

@brson
Copy link
Contributor

brson commented Dec 18, 2012

My above example is a different problem, since it makes sin have a bound of <T:Angle> instead of <T:Trig>. I'm coming up with a lot of variations that fail in different ways. I'll open another issue.

@ghost ghost assigned catamorphism Jan 24, 2013
@brendanzab
Copy link
Member Author

@catamorphism (nag nag)

@catamorphism
Copy link
Contributor

This ICEs with a different error now, but still ICEs.

@catamorphism
Copy link
Contributor

Unfortunately, I got derailed and this won't be done for 0.6. De-milestoning.

@catamorphism
Copy link
Contributor

This compiles now. I'll check in the test case.

@msullivan
Copy link
Contributor

So is this fixed?

@catamorphism
Copy link
Contributor

(bug triage) Huh, I wonder whether I checked in the test case. I'll look at that tomorrow.

@catamorphism
Copy link
Contributor

#9233 will close this.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 7, 2025
…ondet, r=<try>

Enable Non-determinism of float operations in Miri and change std tests

Links to [rust-lang#4208](rust-lang/miri#4208) and [rust-lang#3555](rust-lang/miri#3555) in Miri.

Non-determinism of floating point operations was disabled in rust-lang#137594 because it breaks the tests and doc-tests in core/coretests and std.

This PR:

- enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP
- changes tests that made incorrect assumptions about the operations not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`.
- changes the `assert_approx_eq!` macro to allow up to 1e-4 to make the tests pass

TODO:
- I didn't touch the doc tests because I do not know nearly enough to come near them :)
- probably change the `assert_approx_eq` to use the same technique as Miri (i.e., using ULP instead of EPSILON)

try-job: x86_64-gnu-aux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-trait-system Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants