Implied bounds on nested references + variance = soundness hole
<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/25860)* <!-- homu-ignore:end --> The combination of variance and implied bounds for nested references opens a hole in the current type system: ``` rust static UNIT: &'static &'static () = &&(); fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v } fn bad<'a, T>(x: &'a T) -> &'static T { let f: fn(&'static &'a (), &'a T) -> &'static T = foo; f(UNIT, x) } ``` This hole has been fixed in #129021 for non-higher-ranked function pointers. The underlying issue still persists. ```rust static UNIT: &'static &'static () = &&(); fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T, _: &()) -> &'a T { v } fn bad<'a, T>(x: &'a T) -> &'static T { let f: fn(_, &'a T, &()) -> &'static T = foo; f(UNIT, x, &()) } fn main() {} ```
Posted by aturon on May 28, 2015, 5:37 PM
Tags
Related issues
- Custom games stuck on "finding server" for all european servers
- Feature request: add ACP (Agent Client Protocol) stdio JSON-RPC mode
- Forza Horizon 6 (2483190)
- Turn off integrated browser for default
- Weekly updates are too frequent
- [BUG] Max 20x plan: 100% usage after 2 hours of light work (5 commits, no agents)
Raise real-world problems, find people facing the same issue, and discuss solutions.7,000 issues0 comments
github (Sysadmin)
Custom games stuck on "finding server" for all european servers
Feature request: add ACP (Agent Client Protocol) stdio JSON-RPC mode
Forza Horizon 6 (2483190)
Turn off integrated browser for default
Weekly updates are too frequent
[BUG] Max 20x plan: 100% usage after 2 hours of light work (5 commits, no agents)
Add gemini-3.1-pro-preview
[TF2] Feature request: Bring Back Quickplay
Implied bounds on nested references + variance = soundness hole
<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/25860)* <!-- homu-ignore:end --> The combination of variance and implied bounds for nested references opens a hole in the current type system: ``` rust static UNIT: &'static &'static () = &&(); fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v } fn bad<'a, T>(x: &'a T) -> &'static T { let f: fn(&'static &'a (), &'a T) -> &'static T = foo; f(UNIT, x) } ``` This hole has been fixed in #129021 for non-higher-ranked function pointers. The underlying issue still persists. ```rust static UNIT: &'static &'static () = &&(); fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T, _: &()) -> &'a T { v } fn bad<'a, T>(x: &'a T) -> &'static T { let f: fn(_, &'a T, &()) -> &'static T = foo; f(UNIT, x, &()) } fn main() {} ```
Comments (0)
No comments yet. Start the discussion.