mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
33 lines
630 B
Rust
33 lines
630 B
Rust
struct MutType;
|
|
|
|
pub trait MutTrait {
|
|
fn function(&mut self)
|
|
where
|
|
Self: Sized;
|
|
//~^ this has a `Sized` requirement
|
|
}
|
|
|
|
impl MutTrait for MutType {
|
|
fn function(&mut self) {}
|
|
}
|
|
|
|
struct Type;
|
|
|
|
pub trait Trait {
|
|
fn function(&self)
|
|
where
|
|
Self: Sized;
|
|
//~^ this has a `Sized` requirement
|
|
}
|
|
|
|
impl Trait for Type {
|
|
fn function(&self) {}
|
|
}
|
|
|
|
fn main() {
|
|
(&mut MutType as &mut dyn MutTrait).function();
|
|
//~^ ERROR the `function` method cannot be invoked on a trait object
|
|
(&Type as &dyn Trait).function();
|
|
//~^ ERROR the `function` method cannot be invoked on a trait object
|
|
}
|