example from documentation does not compile
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 45/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rust
調査の方向性
まず、PublicError、ErrorRepr、Foo、throw_foo の定義を含むドキュメントの例を見つけ、示されているとおりにコンパイルします。その例で E0277 や E0308 が発生しなくなったこと、および文書化されているエラー処理の動作が維持されていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
// Private and free to change across minor version of the crate.
#[derive(thiserror::Error, Debug)] // PublicError is public, but opaque and easy to keep compatible.
#[error(transparent)]
pub struct PublicError(#[from] ErrorRepr);
impl PublicError {
// Accessors for anything we do want to expose publicly.
}
// Private and free to change across minor version of the crate.
#[derive(thiserror::Error, Debug)]
enum ErrorRepr {
#[error("foo")]
Foo(#[from] Foo),
}
#[derive(thiserror::Error, Debug)]
#[error("foo_text")]
struct Foo;
fn throw_foo() -> Result<(), Foo> {
return Err(Foo);
}
fn main() -> Result<(), PublicError> {
throw_foo()?;
println!("Hello, world!");
}
error[E0277]: `?` couldn't convert the error to `PublicError`
--> src/main.rs:26:16
|
25 | fn main() -> Result<(), PublicError> {
| ----------------------- expected `PublicError` because of this
26 | throw_foo()?;
| -----------^ the trait `From<Foo>` is not implemented for `PublicError`
| |
| this can't be annotated with `?` because it has type `Result<_, Foo>`
|
note: `PublicError` needs to implement `From<Foo>`
--> src/main.rs:4:1
|
4 | pub struct PublicError(#[from] ErrorRepr);
| ^^^^^^^^^^^^^^^^^^^^^^
note: alternatively, `Foo` needs to implement `Into<PublicError>`
--> src/main.rs:19:1
|
19 | struct Foo;
| ^^^^^^^^^^
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the trait `From<Foo>` is not implemented for `PublicError`
but trait `From<ErrorRepr>` is implemented for it
= help: for that trait implementation, expected `ErrorRepr`, found `Foo`
error[E0308]: mismatched types
--> src/main.rs:25:14
|
25 | fn main() -> Result<(), PublicError> {
| ---- ^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<(), PublicError>`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected enum `Result<(), PublicError>`
found unit type `()`
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `tetete` (bin "tetete") due to 2 previous errors
- 主要言語
- Rust
- スター
- 5.6k
- フォーク
- 220
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dtolnay/thiserror のほかの issue
-
Improve #[from] documentation example.対応中かも @SatvikMishra08 が 50 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
No `unused field` warnings are produced on enums deriving thiserror::Error対応中かも @usmanovbf が 240 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
dtolnay/thiserror の issue をすべて見る
似ている issue
-
Selected chart highlights only its values, not its series names and category labels対応中かも @Higgs32584 が今日担当しました。 オープンbug priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
storytold/gridcraft#4390 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
bug bugfix priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
quarto-dev/q2#1219 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100