forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#133478 - aDotInTheVoid:finally, r=fmease jsondocck: Parse, don't validate commands. Centralizes knowledge of jsondocck syntax into the parser, so the checker doesn't need to know what the indexes are. [Vaguely related zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/jsondocck.20rewrite) I'm very happy this is negative LoC, despite adding a big, documented enum! r? ``@fmease``
- Loading branch information
Showing
3 changed files
with
169 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,7 @@ | ||
use std::error::Error; | ||
use std::fmt; | ||
|
||
use crate::Command; | ||
|
||
#[derive(Debug)] | ||
pub enum CkError { | ||
/// A check failed. File didn't exist or failed to match the command | ||
FailedCheck(String, Command), | ||
/// An error triggered by some other error | ||
Induced(Box<dyn Error>), | ||
} | ||
|
||
impl fmt::Display for CkError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
CkError::FailedCheck(msg, cmd) => { | ||
write!(f, "Failed check: {} on line {}", msg, cmd.lineno) | ||
} | ||
CkError::Induced(err) => write!(f, "Check failed: {}", err), | ||
} | ||
} | ||
} | ||
|
||
impl<T: Error + 'static> From<T> for CkError { | ||
fn from(err: T) -> CkError { | ||
CkError::Induced(Box::new(err)) | ||
} | ||
pub struct CkError { | ||
pub message: String, | ||
pub command: Command, | ||
} |
Oops, something went wrong.