Test define opaques in extern items
This commit is contained in:
parent
f8df298d74
commit
0827f76586
3 changed files with 34 additions and 1 deletions
|
@ -52,7 +52,10 @@ pub(crate) fn expand(
|
|||
.collect(),
|
||||
);
|
||||
} else {
|
||||
ecx.dcx().span_err(meta_item.span, "only functions and methods can define opaque types");
|
||||
ecx.dcx().span_err(
|
||||
meta_item.span,
|
||||
"only functions, statics, and consts can define opaque types",
|
||||
);
|
||||
}
|
||||
|
||||
vec![item]
|
||||
|
|
16
tests/ui/impl-trait/define-via-extern.rs
Normal file
16
tests/ui/impl-trait/define-via-extern.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type Hi = impl Sized;
|
||||
|
||||
extern "C" {
|
||||
#[define_opaque(Hi)] fn foo();
|
||||
//~^ ERROR only functions, statics, and consts can define opaque types
|
||||
|
||||
#[define_opaque(Hi)] static HI: Hi;
|
||||
//~^ ERROR only functions, statics, and consts can define opaque types
|
||||
}
|
||||
|
||||
#[define_opaque(Hi)]
|
||||
fn main() {
|
||||
let _: Hi = 0;
|
||||
}
|
14
tests/ui/impl-trait/define-via-extern.stderr
Normal file
14
tests/ui/impl-trait/define-via-extern.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error: only functions, statics, and consts can define opaque types
|
||||
--> $DIR/define-via-extern.rs:6:5
|
||||
|
|
||||
LL | #[define_opaque(Hi)] fn foo();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: only functions, statics, and consts can define opaque types
|
||||
--> $DIR/define-via-extern.rs:9:5
|
||||
|
|
||||
LL | #[define_opaque(Hi)] static HI: Hi;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue