From 5f160a025c79d86a5bd0c5ab514f722902249891 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Wed, 10 Feb 2021 20:48:19 -0500 Subject: [PATCH 1/9] Add 81974 Most likely low-priority; feel free to ignore Issue: rust-lang/rust#81974 --- ices/81974.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ices/81974.rs diff --git a/ices/81974.rs b/ices/81974.rs new file mode 100644 index 00000000..5e3c6532 --- /dev/null +++ b/ices/81974.rs @@ -0,0 +1,51 @@ +#![feature(unboxed_closures)] +#![feature(fn_traits)] + +use std::collections::HashMap; +use std::hash::Hash; + +struct CachedFun{ + cache: HashMap, + fun: fn(&mut CachedFun, A) -> B +} + +impl CachedFun { + fn new(fun: fn(&mut Self, A) -> B) -> Self { + CachedFun { + cache: HashMap::new(), + fun + } + } +} + +impl FnOnce for CachedFun where + A: Eq + Hash + Clone, + B: Clone, +{ + type Output = B; + extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { + self.call_mut(a) + } +} + + +impl FnMut for CachedFun where + A: Eq + Hash + Clone, + B: Clone, +{ + extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { + self.cache.get(&a) + .map(|a| a.clone()) + .unwrap_or_else(|| { + let b = (self.fun)(self, a.clone()); + self.cache.insert(a, b.clone()); + b + }) + } +} + +fn main() -> () { + let pesce = |y: &mut CachedFun, x| x + 1; + let cachedcoso = CachedFun::new(pesce); + cachedcoso.call_once(1); +} From 6fc5bae3a14036919655f833a676aff5bbf3228f Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Wed, 10 Feb 2021 20:51:09 -0500 Subject: [PATCH 2/9] Add 81924 Issue: rust-lang/rust#81924 --- ices/81924.rs | 1 + 1 file changed, 1 insertion(+) create mode 100644 ices/81924.rs diff --git a/ices/81924.rs b/ices/81924.rs new file mode 100644 index 00000000..fa0bdb76 --- /dev/null +++ b/ices/81924.rs @@ -0,0 +1 @@ +#![a = {enum b { From 5c8a4b9d3c6ba20a5f517eecf51aa3087047ff0d Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Wed, 10 Feb 2021 20:57:43 -0500 Subject: [PATCH 3/9] Add 81899 Issue: rust-lang/rust#81899 --- ices/81899.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ices/81899.rs diff --git a/ices/81899.rs b/ices/81899.rs new file mode 100644 index 00000000..4c0a2a6d --- /dev/null +++ b/ices/81899.rs @@ -0,0 +1,10 @@ +const _CONST: &[u8] = &f(&[], |_| {}); + +const fn f(_: &[u8], _: F) -> &[u8] +where + F: FnMut(&u8), +{ + panic!() +} + +fn main() {} From 89266ac3e78cb90936b3eda5926edcec73c35072 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Wed, 10 Feb 2021 21:05:03 -0500 Subject: [PATCH 4/9] Add 81809 Issue: rust-lang/rust#81809 --- ices/81809.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 ices/81809.rs diff --git a/ices/81809.rs b/ices/81809.rs new file mode 100644 index 00000000..7e67c47e --- /dev/null +++ b/ices/81809.rs @@ -0,0 +1,74 @@ +use std::ops::Index; + +pub trait Indexable { + type Index; +} +struct Foo; +struct Bar; +impl Indexable for Foo { type Index = u8; } +impl Indexable for Bar { type Index = u16; } + +pub trait Indexer: Index {} + +struct Store; + +impl Index for Store { + type Output = Foo; + fn index(&self, _: u8) -> &Foo { panic!() } +} +impl Index for Store { + type Output = Bar; + fn index(&self, _: u16) -> &Bar { panic!() } +} +impl Indexer for Store { } +impl Indexer for Store { } + +// implies StoreIndex: Index + Index +trait StoreIndex: Indexer + Indexer {} + +impl StoreIndex for Store {} + +struct Collection { + stores: Vec, +} + +trait StoreCollection { + fn get_store(&self, _: usize) -> Option<&dyn StoreIndex>; +} + +impl StoreCollection for Collection { + // Fails to compile: + // expected: + // Option<&dyn StoreIndex + // found: + // Option<&Store> + /* + fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> { + self.stores.get(i) + } + */ + + // ICE + fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> { + if let Some(s) = self.stores.get(i) { + Some(s as &dyn StoreIndex) + } else { + None + } + } + + // However, if the above is removed in favor of Indexing + // type checking succeeds and the type of `&self.stores[i]` + // is properly inferred + /* + fn get_store(&self, i: usize) -> Option<&dyn StoreIndex> { + if i < self.stores.len() { + Some(&self.stores[i]) + } else { + None + } + } + */ +} + +fn main() {} From cd87d7d04e01f2ad68e6f981a8cfa666b305c337 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Wed, 10 Feb 2021 21:16:57 -0500 Subject: [PATCH 5/9] Add 81786 Issue: rust-lang/rust#81786 --- ices/81786.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ices/81786.sh diff --git a/ices/81786.sh b/ices/81786.sh new file mode 100644 index 00000000..bfaaa34c --- /dev/null +++ b/ices/81786.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +cat > out.rs <<'EOF' +#![feature(auto_traits, negative_impls)] + +auto trait AutoTrait {} + +pub struct Struct { + k: K, + v: V +} + +impl !AutoTrait for *const T {} + +impl AutoTrait for Struct +where + K: AutoTrait, + V: AutoTrait, +{ +} + +impl AutoTrait for Struct {} + +pub struct Wrap<'a> { + inner: &'a Struct, +} + +fn main() {} +EOF + +rustdoc out.rs --output-format json From 01e161338a17dd4556f5919cbdf221e962094b45 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Thu, 11 Feb 2021 13:30:11 -0500 Subject: [PATCH 6/9] Add 81199 Issue: rust-lang/rust#81199 --- ices/81199.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ices/81199.rs diff --git a/ices/81199.rs b/ices/81199.rs new file mode 100644 index 00000000..d3557be9 --- /dev/null +++ b/ices/81199.rs @@ -0,0 +1,18 @@ +#[repr(C)] +union PtrRepr { + const_ptr: *const T, + mut_ptr: *mut T, + components: PtrComponents, +} + +#[repr(C)] +struct PtrComponents { + data_address: *const (), + metadata: ::Metadata, +} + + + +pub trait Pointee { + type Metadata; +} From efc5838e1d829527b798256d8fe8f7fe9f2f6ef8 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Thu, 11 Feb 2021 13:55:50 -0500 Subject: [PATCH 7/9] Add 80351 Issue: rust-lang/rust#80351 --- ices/80351.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 ices/80351.rs diff --git a/ices/80351.rs b/ices/80351.rs new file mode 100644 index 00000000..3d90ee00 --- /dev/null +++ b/ices/80351.rs @@ -0,0 +1,19 @@ +fn main() { + enqueue::<(), _>(|_result| {}); +} + +trait Query<'a> { + type Result: 'a; + fn execute() -> Self::Result; +} + +impl<'a> Query<'a> for () { + type Result = (); + fn execute() -> () { + () + } +} + +fn enqueue Query<'q>, F: 'static + for<'r> FnOnce(>::Result)>(f: F) { + let _: Box = Box::new(move || f(Q::execute())); +} From 4a45148f28787b4e1fe8e342904482a8f6364c3f Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Fri, 12 Feb 2021 16:10:53 -0500 Subject: [PATCH 8/9] Minimize 81199 --- ices/81199.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ices/81199.rs b/ices/81199.rs index d3557be9..a45cbc14 100644 --- a/ices/81199.rs +++ b/ices/81199.rs @@ -1,18 +1,9 @@ -#[repr(C)] union PtrRepr { const_ptr: *const T, mut_ptr: *mut T, - components: PtrComponents, + components: ::Metadata } -#[repr(C)] -struct PtrComponents { - data_address: *const (), - metadata: ::Metadata, -} - - - pub trait Pointee { - type Metadata; + type Metadata; } From 70723822637a079c83b194d35cceb45514d00339 Mon Sep 17 00:00:00 2001 From: Padraic Fanning Date: Fri, 12 Feb 2021 16:12:09 -0500 Subject: [PATCH 9/9] Drop 81974 --- ices/81974.rs | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 ices/81974.rs diff --git a/ices/81974.rs b/ices/81974.rs deleted file mode 100644 index 5e3c6532..00000000 --- a/ices/81974.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![feature(unboxed_closures)] -#![feature(fn_traits)] - -use std::collections::HashMap; -use std::hash::Hash; - -struct CachedFun{ - cache: HashMap, - fun: fn(&mut CachedFun, A) -> B -} - -impl CachedFun { - fn new(fun: fn(&mut Self, A) -> B) -> Self { - CachedFun { - cache: HashMap::new(), - fun - } - } -} - -impl FnOnce for CachedFun where - A: Eq + Hash + Clone, - B: Clone, -{ - type Output = B; - extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { - self.call_mut(a) - } -} - - -impl FnMut for CachedFun where - A: Eq + Hash + Clone, - B: Clone, -{ - extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { - self.cache.get(&a) - .map(|a| a.clone()) - .unwrap_or_else(|| { - let b = (self.fun)(self, a.clone()); - self.cache.insert(a, b.clone()); - b - }) - } -} - -fn main() -> () { - let pesce = |y: &mut CachedFun, x| x + 1; - let cachedcoso = CachedFun::new(pesce); - cachedcoso.call_once(1); -}