-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE in region_inference/mod.rs
#21750
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
Comments
Reduced test case: pub trait Arg<A> { }
pub trait Traversal {
type Item;
fn foreach<F: Arg<Self::Item>>(F);
}
impl<'a> Traversal for i32 {
type Item = &'a i32;
fn foreach<F: Arg<&'a i32>>(f: F) { }
}
fn main() {} Still ICEs with The ICE goes away if the |
Slightly different test case: pub trait Traversal {
type Item;
fn foreach<F>(self, F) where F: FnMut(Self::Item);
}
impl<'a, T> Traversal for &'a [T] {
type Item = &'a T;
fn foreach<F>(self, mut f: F) where F: FnMut(&'a T) {
//
}
} EDIT: Nevermind, it's the same but uses a closure instead of the more general |
A workaround would be simply: impl<'a> Traversal for i32 {
...
fn foreach<F>(f: F) { }
} |
@edwardw This doesn't help much if you need to call methods that are on the |
cc me |
This is blocking collect-rs from compiling. |
This is interesting. The culprit is compare_method.rs#L251-L264: it registers obligations from implementation's methods into an hybrid parameter environment which has trait's methods in it. In the example given in this issue, when the associate type is projected out, the implementation's method acquires an extra lifetime variable. The trait's method doesn't have it so the lifetime resolution fails in an ICE later on. I'm not sure how to fix that though. |
This compiles so at first glance it looks like a viable workaround: impl<'a> Traversal for i32 {
type Item = &'a i32;
fn foreach<F: Arg<<Self as Traversal>::Item>>(f: F) { }
} But if one tries to really use pub trait Arg<A> {
fn arg(&self);
}
pub trait Traversal {
type Item;
fn foreach<F: Arg<Self::Item>>(F);
}
impl<'a> Traversal for i32 {
type Item = &'a i32;
fn foreach<F: Arg<<Self as Traversal>::Item>>(f: F) {
f.arg();
}
} |
Otherwise, the substitution is carried out from outside perspective, which would be against the very purpose of `ParameterEnvironment`. Closes rust-lang#21750 Closes rust-lang#22077
…ion-with-regions, r=pnkfelix Two changes: 1. Make traits with assoc types invariant w/r/t their inputs. 2. Fully normalize parameter environments, including any region variables (which were being overlooked). The former supports the latter, but also just seems like a reasonably good idea. Fixes rust-lang#21750 cc @edwardw r? @pnkfelix
Getting this with some hashing code. fn hash_item(&self) -> String {
println!("Start hash");
let bytes = self.bytes();
println!("BYTES: {:?}", bytes);
let lyra2res = sum(bytes.clone());
println!(
"lyra2 finished: {}",
bs58::encode(lyra2res.clone()).into_string()
);
let mut sk: u64 = 0;
for byte in bytes.iter() {
sk += *byte as u64;
}
let password = lyra2res;
let salt = sk.to_string();
let config = Config {
variant: Variant::Argon2id,
version: Version::Version13,
mem_cost: 65536,
time_cost: 5,
lanes: 4,
thread_mode: ThreadMode::Parallel,
secret: &[],
ad: &[],
hash_length: 32,
};
println!("Starting argon");
let hash: String = bs58::encode(
argon2::hash_encoded(&password, salt.as_bytes(), &config)
.unwrap_or("".to_string())
.as_bytes(),
)
.into_string();
return hash;
} will output something along the lines of: thread 'certificate::tests::check_cert_diff' panicked at 'index out of bounds: the len is 0 but the index is 31', /rustc/f509b26a7730d721ef87423a72b3fdf8724b4afa/src/libcore/slice/mod.rs:2842:10 |
Attempting to compile https://github.com/reem/rust-traverse with
cargo 0.0.1-pre-nightly (453ae9f 2015-01-29 00:56:56 +0000)
andrustc 1.0.0-nightly (c5961ad06 2015-01-28 21:49:38 +0000)
yields the following ICE:The text was updated successfully, but these errors were encountered: