parent
f94eaeaf73
commit
708f053807
4 changed files with 148 additions and 0 deletions
57
src/test/ui/associated-types/issue-65774-1.rs
Normal file
57
src/test/ui/associated-types/issue-65774-1.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait MyDisplay { fn method(&self) { } }
|
||||
|
||||
impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }
|
||||
|
||||
struct T;
|
||||
|
||||
trait MPU {
|
||||
type MpuConfig: MyDisplay = T;
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl MPU for S { }
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
|
||||
trait MyWrite {
|
||||
fn my_write(&self, _: &dyn MyDisplay) { }
|
||||
}
|
||||
|
||||
trait ProcessType {
|
||||
fn process_detail_fmt(&self, _: &mut dyn MyWrite);
|
||||
}
|
||||
|
||||
struct Process;
|
||||
|
||||
impl ProcessType for Process {
|
||||
fn process_detail_fmt(&self, writer: &mut dyn MyWrite)
|
||||
{
|
||||
|
||||
let mut val: Option<<S as MPU>::MpuConfig> = None;
|
||||
let valref: &mut <S as MPU>::MpuConfig = val.as_mut().unwrap();
|
||||
|
||||
// // This causes a different ICE (but its similar if you squint right):
|
||||
// //
|
||||
// // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
|
||||
//
|
||||
// writer.my_write(valref)
|
||||
|
||||
// This one causes the ICE:
|
||||
// FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)), depth=1),Unimplemented)
|
||||
let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
|
||||
closure(valref);
|
||||
}
|
||||
}
|
||||
|
||||
fn create() -> &'static dyn ProcessType {
|
||||
let input: Option<&mut Process> = None;
|
||||
let process: &mut Process = input.unwrap();
|
||||
process
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
create();
|
||||
}
|
||||
17
src/test/ui/associated-types/issue-65774-1.stderr
Normal file
17
src/test/ui/associated-types/issue-65774-1.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-1.rs:10:21
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --------- required by `MPU`
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-1.rs:16:6
|
||||
|
|
||||
LL | impl MPU for S { }
|
||||
| ^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
57
src/test/ui/associated-types/issue-65774-2.rs
Normal file
57
src/test/ui/associated-types/issue-65774-2.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait MyDisplay { fn method(&self) { } }
|
||||
|
||||
impl<'a, T: MyDisplay> MyDisplay for &'a mut T { }
|
||||
|
||||
struct T;
|
||||
|
||||
trait MPU {
|
||||
type MpuConfig: MyDisplay = T;
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl MPU for S { }
|
||||
//~^ ERROR the trait bound `T: MyDisplay` is not satisfied
|
||||
|
||||
trait MyWrite {
|
||||
fn my_write(&self, _: &dyn MyDisplay) { }
|
||||
}
|
||||
|
||||
trait ProcessType {
|
||||
fn process_detail_fmt(&self, _: &mut dyn MyWrite);
|
||||
}
|
||||
|
||||
struct Process;
|
||||
|
||||
impl ProcessType for Process {
|
||||
fn process_detail_fmt(&self, writer: &mut dyn MyWrite)
|
||||
{
|
||||
|
||||
let mut val: Option<<S as MPU>::MpuConfig> = None;
|
||||
let valref: &mut <S as MPU>::MpuConfig = val.as_mut().unwrap();
|
||||
|
||||
// // This causes a different ICE (but its similar if you squint right):
|
||||
// //
|
||||
// // `Unimplemented` selecting `Binder(<T as MyDisplay>)` during codegen
|
||||
//
|
||||
writer.my_write(valref)
|
||||
|
||||
// This one causes the ICE:
|
||||
// FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as MyDisplay>)), depth=1),Unimplemented)
|
||||
/*let closure = |config: &mut <S as MPU>::MpuConfig| writer.my_write(&config);
|
||||
closure(valref);*/
|
||||
}
|
||||
}
|
||||
|
||||
fn create() -> &'static dyn ProcessType {
|
||||
let input: Option<&mut Process> = None;
|
||||
let process: &mut Process = input.unwrap();
|
||||
process
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
create();
|
||||
}
|
||||
17
src/test/ui/associated-types/issue-65774-2.stderr
Normal file
17
src/test/ui/associated-types/issue-65774-2.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-2.rs:10:21
|
||||
|
|
||||
LL | trait MPU {
|
||||
| --------- required by `MPU`
|
||||
LL | type MpuConfig: MyDisplay = T;
|
||||
| ^^^^^^^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error[E0277]: the trait bound `T: MyDisplay` is not satisfied
|
||||
--> $DIR/issue-65774-2.rs:16:6
|
||||
|
|
||||
LL | impl MPU for S { }
|
||||
| ^^^ the trait `MyDisplay` is not implemented for `T`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue