Comments (4)
AFAIK, you'll need double-boxing if you want to store unsized data with a single-width pointer. Presumably you're getting the size to dealloc from vtable
? I don't believe there's a user-facing way to free an object of a dynamic size, but @dtolnay would know better.
You could still do struct Inner { backtrace: Backtrace, data: Box<Fail> }
.
from failure.
AFAIK, you'll need double-boxing if you want to store unsized data with a single-width pointer.
Aren't we essentially going to be leaking the data (because of the bitmasking) and then reconstructing the address of it every time? We can make the second pointer null (and then swap it with the vtable pointer)?
Stuff about how to free the object is a good question, we would probably want to store the size inline.
from failure.
Basically what we're talking about doing is reimplementing dynamic dispatch in unsafe code instead of using real trait objects.
from failure.
This isn't really related but its also about doing unsafe vtable shenanigans:
it would be great to be able to follow the std::error::Error::cause
chain to its conclusion instead of just bottoming out at the first non-Fail
error we come to. We could do that if we could manufacture a fake vtable somehow.
The Fail vtable has two methods: backtrace (which in the fake one would use the default implementation) and cause. cause is the tricky method. We'd have to call the std::Error::Error::cause
method from the original vtable and then perform this very same vtable swap on the result.
No idea how to implement this even if it were possible on stable today.
from failure.
Related Issues (20)
- Addition of name member to Fail trait is a semver-breaking change HOT 4
- Should `backtrace` dependency be optional? HOT 1
- Compat should override method source() HOT 1
- Repository field for `failure_derive` and `failure` do not match HOT 1
- Support for an alloc feature? HOT 1
- failure-v0.1.5 fails to compile with rustc-1.37.0 HOT 6
- Add option to derive Debug identical to Display HOT 1
- Collaborate on a "core::Error" crate with snafu, anyhow and other error crates HOT 1
- Update failure_derive dependencies HOT 1
- support `at` method using for locate error
- Move Repository To rust-lang HOT 7
- Fix guide example code
- Memory safe violation by abusing `__private_get_type_id__` HOT 1
- Propagate never type
- error: /lib64/libc.so.6: version `GLIBC_2.18' not found HOT 2
- 'backtrace' is forcing an increased MinSRV; pin 'backtrace' to `version = "<= 0.3.30"` HOT 6
- [FEATURE REQUEST] Add ability to `bail!` and `ensure!` error types.
- failure_derive won't build with quote 1.0.3 HOT 16
- Why does this exist? HOT 2
- "trailing semicolons in expression macro bodies" breaks with bail
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 failure.