chore: 将工具链更新到2024-07-23 (#864)

* chore: 将工具链更新到2024-07-23
This commit is contained in:
LoGin
2024-07-25 00:55:02 +08:00
committed by GitHub
parent 634349e0eb
commit bd70d2d1f4
150 changed files with 237 additions and 200 deletions

View File

@ -0,0 +1,27 @@
use intertrait::cast::*;
use intertrait::*;
use std::sync::Arc;
#[cast_to([sync, sync] Greet)]
struct Data;
trait Source: CastFromSync {}
trait Greet {
fn greet(&self);
}
impl Greet for Data {
fn greet(&self) {
println!("Hello");
}
}
impl Source for Data {}
fn main() {
let data = Arc::new(Data);
let source: Arc<dyn Source> = data;
let greet = source.cast::<dyn Greet>();
greet.unwrap_or_else(|_| panic!("can't happen")).greet();
}

View File

@ -0,0 +1,5 @@
error: Duplicated flag: sync
--> $DIR/duplicate-flags.rs:5:18
|
5 | #[cast_to([sync, sync] Greet)]
| ^^^^

View File

@ -0,0 +1,31 @@
use intertrait::*;
use intertrait::cast::*;
use std::marker::PhantomData;
#[cast_to(Greet)]
struct Data<T: 'static> {
phantom: PhantomData<T>,
}
trait Source: CastFrom {}
trait Greet {
fn greet(&self);
}
impl<T: 'static> Greet for Data<T> {
fn greet(&self) {
println!("Hello");
}
}
impl<T: 'static> Source for Data<T> {}
fn main() {
let data = Data::<i32> {
phantom: PhantomData,
};
let source: &dyn Source = &data;
let greet = source.cast::<dyn Greet>();
greet.unwrap().greet();
}

View File

@ -0,0 +1,5 @@
error: #[cast_to(..)] can't be used on a generic type definition
--> tests/ui/on-generic-type.rs:6:12
|
6 | struct Data<T: 'static> {
| ^^^^^^^^^^^^

View File

@ -0,0 +1,14 @@
use intertrait::*;
struct Data;
#[cast_to]
impl Data {
fn hello() {
println!("hello!");
}
}
fn main() {
let _ = Data;
}

View File

@ -0,0 +1,5 @@
error: #[cast_to] should only be on an impl of a trait
--> $DIR/on-type-impl.rs:6:6
|
6 | impl Data {
| ^^^^

View File

@ -0,0 +1,27 @@
use intertrait::cast::*;
use intertrait::*;
use std::sync::Arc;
#[cast_to([sync, send] Greet)]
struct Data;
trait Source: CastFromSync {}
trait Greet {
fn greet(&self);
}
impl Greet for Data {
fn greet(&self) {
println!("Hello");
}
}
impl Source for Data {}
fn main() {
let data = Arc::new(Data);
let source: Arc<dyn Source> = data;
let greet = source.cast::<dyn Greet>();
greet.unwrap_or_else(|_| panic!("can't happen")).greet();
}

View File

@ -0,0 +1,5 @@
error: Unknown flag: send
--> $DIR/unknown-flag.rs:5:18
|
5 | #[cast_to([sync, send] Greet)]
| ^^^^