-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize types before looking for opaques
- Loading branch information
1 parent
742d3f0
commit d8bd153
Showing
3 changed files
with
73 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![feature(type_alias_impl_trait)] | ||
#![allow(unused)] | ||
#![deny(improper_ctypes)] | ||
|
||
pub trait TraitA { | ||
type Assoc; | ||
} | ||
|
||
impl TraitA for u32 { | ||
type Assoc = u32; | ||
} | ||
|
||
pub trait TraitB { | ||
type Assoc; | ||
} | ||
|
||
impl<T> TraitB for T | ||
where | ||
T: TraitA, | ||
{ | ||
type Assoc = <T as TraitA>::Assoc; | ||
} | ||
|
||
type AliasA = impl TraitA<Assoc = u32>; | ||
|
||
type AliasB = impl TraitB; | ||
|
||
fn use_of_a() -> AliasA { | ||
3 | ||
} | ||
|
||
fn use_of_b() -> AliasB { | ||
3 | ||
} | ||
|
||
extern "C" { | ||
fn lint_me() -> <AliasB as TraitB>::Assoc; | ||
//~^ ERROR `extern` block uses type `AliasB`, which is not FFI-safe | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: `extern` block uses type `AliasB`, which is not FFI-safe | ||
--> $DIR/opaque-ty-ffi-normalization-cycle.rs:37:21 | ||
| | ||
LL | fn lint_me() -> <AliasB as TraitB>::Assoc; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= note: opaque types have no C equivalent | ||
note: the lint level is defined here | ||
--> $DIR/opaque-ty-ffi-normalization-cycle.rs:3:9 | ||
| | ||
LL | #![deny(improper_ctypes)] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|