Semver question: Is the non-qualified call to `.as_dyn_error()` intentional?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Leggi in impl/src/expand.rs la parte relativa alla chiamata .as_dyn_error() generata e in src/aserror.rs il trait nascosto AsDynError. Riproduci il comportamento di risoluzione dei metodi descritto nell’issue, quindi determina se i metodi esterni sono supportati. Il lavoro è completo quando il contratto è documentato oppure si decide di usare una chiamata completamente qualificata, tenendo conto dell’impatto sulla compatibilità.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Right now the thiserror macro will generate code that invokes the hidden AsDynError trait. However it doesn't use a fully qualified path, but instead uses method-call resolution, where an inherent method on the field type shadows the trait method.
Is this an intentional choice to allow external implementations of the method?
Context: In rootcause we got a feature request to support placing a rootcause report inside enums with thiserror impls using #[error(transparent)].
While we don't recommend this way of combining thiserror and rootcause, we do consider it a helpful feature to make migrations of large codebases easier.
We added the feature using a Deref impl, but we had to roll back the change.
However after rolling back the change, I noticed that the #[error(transparent)] code still worked. It turns out, this is because we also named our method .as_dyn_error(), so everything happened to still work.
This makes me a bit worried, as "internal" changes in thiserror can now cause accidental breakage in consumers that use both thiserror and rootcause.
It'd be good to know where you land on this. If external as_dyn_error() impls are fair game, then we will document that this is a supported (but non-recommended) way to combine rootcause with thiserror. Otherwise we'd rather you make the call fully-qualified so the behavior breaks now instead of by accident later.
- Lingua principale
- Rust
- Stelle
- 5.6k
- Fork
- 220
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dtolnay/thiserror
-
Improve #[from] documentation example.Forse già presa @SatvikMishra08 l’ha presa 50 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
No `unused field` warnings are produced on enums deriving thiserror::ErrorForse già presa @usmanovbf l’ha presa 240 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
example from documentation does not compileForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Tutte le issue di dtolnay/thiserror
Issue simili
-
Selected chart highlights only its values, not its series names and category labelsForse già presa @Higgs32584 l’ha presa oggi. Apertabug priority: low ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
storytold/gridcraft#4390 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
bug bugfix priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
quarto-dev/q2#1219 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100