Comments (6)
And here is the result of reducing that expanded code:
trait Bar<X> {
type Y;
}
struct Example<A>(A);
impl<X, T> Bar<X> for Example<T> {
type Y = Option<T>;
}
struct Foo<A, B> {
x: <Example<A> as Bar<B>>::Y,
}
struct __FooProjection<'pin, A, B> {
x: &'pin mut <Example<A> as Bar<B>>::Y,
}
from pin-project.
It looks like the compiler is giving the correct error here. From the infer_outlives
rfc:
In turn, if this associated type were used in a struct, where-clauses would be required. As we'll see in the reference-level explanation, this is a consequence of the fact that we do inference without regard for associated type normalization, but it makes for a relatively simple rule -- explicit where clauses are needed in the preseence of impls like the one above:
struct Foo<'a, T>
where T: 'a // still required, not inferred from `field`
{
field: <Vec<T> as MakeRef<'a>>::Type
}
I think the solution is for pin-project
to always generate T: 'pin
for each type parameter T
.
from pin-project.
@Aaron1011 it might be safer to add this bound instead:
where Foo<A, B>: 'pin
This also seems to fix the problem.
trait Bar<X> {
type Y;
}
struct Example<A>(A);
impl<X, T> Bar<X> for Example<T> {
type Y = Option<T>;
}
struct Foo<A, B> {
x: <Example<A> as Bar<B>>::Y,
}
struct __FooProjection<'pin, A, B> where Foo<A, B>: 'pin {
x: &'pin mut <Example<A> as Bar<B>>::Y,
}
Just in case there are parameters which don't need to have that constraint, we can leave that to the compiler to figure out.
from pin-project.
@Diggsey: That's a good idea - I'll do that instead.
from pin-project.
Published 0.4.9 which fixes this issue.
from pin-project.
Nice! 👍
from pin-project.
Related Issues (20)
- pin_project cannot be used with structs that hold mutable references HOT 4
- "unused result" warning with 0.4.18 HOT 2
- ?Sized type parameters don't work
- Tracking issue for 1.0.0 release HOT 5
- Prepare for uplift of drop-bounds lint HOT 3
- Generated `#[deny(safe_packed_borrows)]` is not compatible with `#![forbid(future_incompatible)]` HOT 5
- #[pin_project] panics with `internal error: entered unreachable code` when used inside a MBE with vis HOT 2
- error: cannot find attribute `derive` in this scope HOT 3
- Rust-Analyzer compatibility HOT 7
- Cannot build with RUSTFLAGS="-Zsanitizer=address" HOT 2
- Leaked UB in enums HOT 10
- Ambiguous macro use does not compile HOT 3
- `parse_quote_spanned` macro name-collides with `syn::parse_quote_spanned` HOT 1
- #![feature(negative_impls)] breaks the guarantee for Unpin provided by pin-project HOT 1
- Can bypass #[repr(packed)] checking since rust 1.57 HOT 2
- Allow #[pin_project(!Unpin)] to `impl !Unpin` HOT 1
- provide project method on `&mut Pin<&mut Self>` HOT 2
- Why was 1.0.10 yanked from crates.io? HOT 6
- Pin-projecting in-line tuples HOT 2
- docs: Add FAQ section?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pin-project.