Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ffi/fixtures/reject/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ fixtures/reject/src/lib.rs:1597:1: rust2-ffi: cannot export fn `cow_error_later`
help: make the future's error `Cow<str>`, which crosses as its message, or an owned value
fixtures/reject/src/lib.rs:1602:1: rust2-ffi: cannot export fn `cow_param`: Cow other than a returned string or bytes `std::borrow::Cow<'_, str>`
help: take `&str`, `&[u8]`, or an owned value instead, and return `Cow` only as a whole `Cow<str>` or `Cow<[u8]>`
fixtures/reject/src/lib.rs:1623:2: rust2-ffi: cannot export method `Knot<reject::Rope<u8>>::tie`: instance deeper than any type the API spells `reject::Tie<reject::Knot<reject::Rope<u8>>>`
help: spell the instance in a signature of its own, such as a function returning it, or stop nesting generic types in a method's signature
fixtures/reject/src/lib.rs:162:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::held::Local`
help: use a type that maps, such as `BTreeMap` for a `HashMap` and `Vec` for an iterator, or wrap it in a type of your own whose methods take and return mapped types
fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell<std::vec::Vec<String>>`: type argument `std::vec::Vec<String>`
Expand Down
33 changes: 33 additions & 0 deletions ffi/fixtures/reject/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,3 +1602,36 @@ pub async fn cow_error_later(bytes: &[u8]) -> Result<u8, std::borrow::Cow<'_, [u
pub fn cow_param(text: std::borrow::Cow<'_, str>) -> usize {
text.len()
}

/// Three generic types whose methods each wrap their own in the next: inferring from
/// `Rope<u8>` names `Knot<Rope<u8>>`, as deep as `Rope::knot` spells, whose `tie` names
/// `Tie<Knot<Rope<u8>>>`, deeper than any type the crate spells, which ends inference
/// there though no type holds its own.
pub struct Rope<T>(T);

pub struct Knot<T>(T);

pub struct Tie<T>(T);

impl<T> Rope<T> {
pub fn knot(self) -> Knot<Rope<T>> {
Knot(self)
}
}

impl<T> Knot<T> {
pub fn tie(self) -> Tie<Knot<T>> {
Tie(self)
}
}

pub fn rope(value: u8) -> Rope<u8> {
Rope(value)
}

/// An impl with no public member spells nothing, so it raises no instance's depth past
/// what the API spells: `Tie<Knot<Rope<u8>>>` stays refused.
impl<T> Rope<Knot<Tie<T>>> {
#[allow(dead_code, reason = "private, so no part of the API")]
fn private(&self) {}
}
Loading