Rollup merge of #80136 - aDotInTheVoid:74824-test, r=Mark-Simulacrum
Add test for issue #74824 It was fixed a while ago, but doesn't have a test. Closes #74824
This commit is contained in:
commit
26f2d8e80b
27
src/test/ui/generic-associated-types/issue-74824.rs
Normal file
27
src/test/ui/generic-associated-types/issue-74824.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
trait UnsafeCopy {
|
||||
type Copy<T>: Copy = Box<T>;
|
||||
//~^ ERROR the trait bound `Box<T>: Copy` is not satisfied
|
||||
//~^^ ERROR the trait bound `T: Clone` is not satisfied
|
||||
fn copy<T>(x: &Self::Copy<T>) -> Self::Copy<T> {
|
||||
*x
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> UnsafeCopy for T {}
|
||||
|
||||
fn main() {
|
||||
let b = Box::new(42usize);
|
||||
let copy = <()>::copy(&b);
|
||||
|
||||
let raw_b = Box::deref(&b) as *const _;
|
||||
let raw_copy = Box::deref(©) as *const _;
|
||||
|
||||
// assert the addresses.
|
||||
assert_eq!(raw_b, raw_copy);
|
||||
}
|
27
src/test/ui/generic-associated-types/issue-74824.stderr
Normal file
27
src/test/ui/generic-associated-types/issue-74824.stderr
Normal file
@ -0,0 +1,27 @@
|
||||
error[E0277]: the trait bound `Box<T>: Copy` is not satisfied
|
||||
--> $DIR/issue-74824.rs:8:5
|
||||
|
|
||||
LL | type Copy<T>: Copy = Box<T>;
|
||||
| ^^^^^^^^^^^^^^----^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `UnsafeCopy::Copy`
|
||||
| the trait `Copy` is not implemented for `Box<T>`
|
||||
|
||||
error[E0277]: the trait bound `T: Clone` is not satisfied
|
||||
--> $DIR/issue-74824.rs:8:5
|
||||
|
|
||||
LL | type Copy<T>: Copy = Box<T>;
|
||||
| ^^^^^^^^^^^^^^----^^^^^^^^^^
|
||||
| | |
|
||||
| | required by this bound in `UnsafeCopy::Copy`
|
||||
| the trait `Clone` is not implemented for `T`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Clone` for `Box<T>`
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | type Copy<T: Clone>: Copy = Box<T>;
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user