Skip to content

Commit 753c985

Browse files
committed
Add failing test for #[splat] with dyn AsRef<T> where T: Tuple
1 parent 513ca49 commit 753c985

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//! Test that `#[splat]` on `&dyn AsRef<T>` where `T: Tuple` is an error.
2+
3+
#![allow(incomplete_features)]
4+
#![feature(splat)]
5+
#![feature(tuple_trait)]
6+
7+
fn dyn_asref_splat<T>(#[splat] _t: &dyn AsRef<T>) where T: std::marker::Tuple {}
8+
//~^ ERROR cannot use splat attribute
9+
10+
fn main() {
11+
let s: String = "hello".to_owned();
12+
dyn_asref_splat::<String>(&s);
13+
//~^ ERROR `String` is not a tuple
14+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0277]: cannot use splat attribute; the splatted argument type must be a tuple or unit, not a &'?3 dyn [Binder { value: Trait(std::convert::AsRef<std::string::String>), bound_vars: [] }] + '?3 (&'?3 dyn [Binder { value: Trait(std::convert::AsRef<std::string::String>), bound_vars: [] }] + '?3)
2+
--> $DIR/splat-dyn-asref-tuple-fail.rs:7:36
3+
|
4+
LL | fn dyn_asref_splat<T>(#[splat] _t: &dyn AsRef<T>) where T: std::marker::Tuple {}
5+
| ^^^^^^^^^^^^^
6+
...
7+
LL | dyn_asref_splat::<String>(&s);
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
error[E0277]: `String` is not a tuple
11+
--> $DIR/splat-dyn-asref-tuple-fail.rs:12:23
12+
|
13+
LL | dyn_asref_splat::<String>(&s);
14+
| ^^^^^^ the nightly-only, unstable trait `std::marker::Tuple` is not implemented for `String`
15+
|
16+
note: required by a bound in `dyn_asref_splat`
17+
--> $DIR/splat-dyn-asref-tuple-fail.rs:7:60
18+
|
19+
LL | fn dyn_asref_splat<T>(#[splat] _t: &dyn AsRef<T>) where T: std::marker::Tuple {}
20+
| ^^^^^^^^^^^^^^^^^^ required by this bound in `dyn_asref_splat`
21+
22+
error: aborting due to 2 previous errors
23+
24+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)