Comments (4)
oh interesting. I wonder if anyhow
or eyre
have run into this, too, since that's where that code comes from.
from miette.
Interesting. I went thorough all the issues in anyhow
and eyre
and found no discussions on this.
Partially related, I see there are newer changes to https://github.com/dtolnay/anyhow/blob/master/src/error.rs and https://github.com/eyre-rs/eyre/blob/master/eyre/src/error.rs, may I copy some of the relevant changes over? For example I see one commit adding #[cold]
attributes.
Now a quick investigation on the generated llvm ir:
; miette::eyreish::error::object_downcast
; Function Attrs: uwtable
define ptr @_ZN6miette7eyreish5error15object_downcast17h036d603efeb56cf6E(ptr %e, i64 %0, i64 %1) unnamed_addr #1 {
start:
%_5 = alloca %"core::any::TypeId", align 8
%_0 = alloca ptr, align 8
%target = alloca %"core::any::TypeId", align 8
store i64 %0, ptr %target, align 8
%2 = getelementptr inbounds i8, ptr %target, i64 8
store i64 %1, ptr %2, align 8
; call core::any::TypeId::of
%3 = call { i64, i64 } @_ZN4core3any6TypeId2of17h7dd1498b91903dceE()
%4 = extractvalue { i64, i64 } %3, 0
%5 = extractvalue { i64, i64 } %3, 1
store i64 %4, ptr %_5, align 8
%6 = getelementptr inbounds i8, ptr %_5, i64 8
store i64 %5, ptr %6, align 8
; call <core::any::TypeId as core::cmp::PartialEq>::eq
%_3 = call zeroext i1 @"_ZN58_$LT$core..any..TypeId$u20$as$u20$core..cmp..PartialEq$GT$2eq17h3ec8c0e5dcb956b2E"(ptr align 8 %_5, ptr align 8 %target)
br i1 %_3, label %bb3, label %bb9
bb9: ; preds = %start
store ptr null, ptr %_0, align 8
br label %bb10
bb3: ; preds = %start
; call miette::eyreish::ptr::Ref<T>::cast
%unerased = call ptr @"_ZN6miette7eyreish3ptr12Ref$LT$T$GT$4cast17hb52e031c6b285058E"(ptr %e)
; call miette::eyreish::ptr::Ref<T>::as_ptr
%_13 = call ptr @"_ZN6miette7eyreish3ptr12Ref$LT$T$GT$6as_ptr17h4a06fcac3ef26180E"(ptr %unerased)
%_12 = getelementptr inbounds i8, ptr %_13, i64 24
; call core::ptr::non_null::NonNull<T>::new_unchecked
%_10 = call ptr @"_ZN4core3ptr8non_null16NonNull$LT$T$GT$13new_unchecked17h0f63ba3cd42f3548E"(ptr %_12)
; call miette::eyreish::ptr::Ref<T>::from_raw
%_9 = call ptr @"_ZN6miette7eyreish3ptr12Ref$LT$T$GT$8from_raw17h17a12303579934dfE"(ptr %_10)
; call miette::eyreish::ptr::Ref<T>::cast
%_8 = call ptr @"_ZN6miette7eyreish3ptr12Ref$LT$T$GT$4cast17h228ea4cc31de5266E"(ptr %_9)
store ptr %_8, ptr %_0, align 8
br label %bb10
bb10: ; preds = %bb3, %bb9
%7 = load ptr, ptr %_0, align 8, !noundef !3
ret ptr %7
}
353 copies of this is pretty big, I'll find some other time to investigate further.
from miette.
One way to mitigate this is to merge all the error structs into a single num 🤔
Ok I think I'm doing it all wrong, I shouldn't define so many diagnostics, I should define one LinterDiagnostic
instead and reuse it through out the codebase ...
from miette.
Ok it was pointed out that I totally missed MietteDiagnostic
from the docs for the past 2 years ...
from miette.
Related Issues (20)
- Unclear which part of long lines is being pointed to HOT 1
- Change `link` label to something else HOT 1
- New Crates.io Release? HOT 3
- Potentially broken word wrapping on `main` HOT 3
- Update owo-colors to v4? HOT 5
- Can't get `syntect-highlighter` to work HOT 3
- Remove severity from diagnostic output HOT 1
- Add `UnwrapPretty` trait HOT 5
- Compile to wasm32-unknown-unknown / Compile without `terminal_size` HOT 4
- Errors with zero-length span and no context lines are mostly pointless HOT 1
- 要是错误提示能使用中文输出就好了! HOT 5
- Failing tests with `--all-features` HOT 1
- Feature request: output an error as `json::Value` or `serde_json::Value` directly HOT 2
- Feature request: Span line limit for diagnostics HOT 3
- Help: Sub Errors HOT 3
- Is there a reason that `Report` doesn't implement `Error` and `Diagnostic`? HOT 2
- Converting a `Report` to a `Box<dyn Diagnostic>` wipes all `Diagnostic` information HOT 1
- Add `#[cold]` to some of the constructor functions HOT 3
- `#[label]` derive doesn't seem to work with `Option<T>` where `T` implements `Into<SourceSpan>` but not `Copy`
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 miette.