Comments (9)
Ah no worries! I was able to adapt this and get something working, albeit not as egonomically as desired.
In any case thanks for the quick responses here, it's definitely appreciated!
from rust.
The hidden type of impl Host
ends up as &'a U
and we currently don't have an implied U: 'a
bound here. This breaks the invariants of our type system, using a pattern which can result in actual unsoundnesses. I don't think your snippet is unsound as is, but also don't know how we would fix #114936 without breaking your example
from rust.
your code snippet does not seem to compile in 1.77 or 1.76? 🤔 https://rust.godbolt.org/z/vzhn87bfz
from rust.
That may be a godbolt issue perhaps? https://rust.godbolt.org/z/e6nxK5oaq shows it passing with 77/76 and locally 1.77.0 compiles the example for me.
from rust.
@alexcrichton: The code you shared in the issue has an extra + 'a
, causing it to fail both before and after 1.78.
from rust.
Er apologies, that's my mistake. I was trying various versions locally and got the wires crossed. I've updated the above which also explains why the two godbolt links are differing in results.
I was surprised that this actually worked on 1.77.0, so is this actually a soundness issue fixed by #118882?
from rust.
Ah ok, if this is expected no worries, I just wanted to confirm!
Would you happen to know off the top of your head if there's a way we could somehow get this working? The ideal thing we want is:
fn foo<T>(f: impl Fn(&mut T) -> impl Host) { ... }
and we're trying to hack around it of sorts with a custom GetHost
trait, but I'm having a tough time figuring out how to model this use case.
from rust.
Ah well in any case this appears to be expected so there's no issue here I believe. We'll work on getting something alternative working instead.
from rust.
Would you happen to know off the top of your head if there's a way we could somehow get this working? The ideal thing we want is:
It's really hard as you need a for<'a> U: 'a
bound which currently forces U
to be 'static
while ideally it would only allow instantiating 'a
with lifetimes which outlive 'a
. We will support this in a few years as these kinds of bounds are necessary to fix e.g. #25860
but up until then I also don't have a nice fix for this :/
from rust.
Related Issues (20)
- Tracking Issue for `#[global_registration]` HOT 1
- #[rustc_pass_by_value] prevents lldb from showing the information correctly HOT 6
- bootstrap rustc shim: FATAL: RUSTC_STAGE was not set HOT 1
- Lifetime inference fails for closures returning references to their parameters HOT 2
- vtable symbols are not marked artificial in DWARF HOT 2
- ICE: rustdoc: Cannot turn `UnevaluatedConst` into `AliasTy` HOT 1
- An unexpected expanded result from procedural macro
- suggestion to use generic parameter in case of "error[E0782]: trait objects must include the `dyn` keyword" HOT 2
- The extra newline in unpretty=hir
- Unclear lifetime mismatch error with anonymous lifetimes HOT 1
- DWARF information encodes discriminant values for tagged enums incorrectly
- BufWriter is happy with non-mutable Writer HOT 4
- [ICE]: opaque type with non-universal region args HOT 1
- ICE: `elem.index() < self.domain_size` HOT 1
- ICE: `cargo check` panics on toolchain `stable-x86_64-unknown-linux-gnu` HOT 6
- rustc can not be launched on Windows 7 x64 HOT 4
- `rustc_macros`: Make it possible to derive both `Diagnostic` and `LintDiagnostic` on the same type HOT 4
- Tracking Issue for PanicHookInfo::payload_as_str()
- rustdoc-json-types: Rename and document Impl::synthetic HOT 3
- ICE: ` unhandled type: {type error}`
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 rust.