-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor librustdoc html backend #73767
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c692ed4
Move `Error` and `RenderInfo` out of `html` module
P1n3appl3 5bc9794
Refactor html backend to use generic interface
P1n3appl3 6a4396b
Extract `Cache` and other types from `html` module
P1n3appl3 a790952
Pull out more types from html
P1n3appl3 65bf5d5
TODO -> FIXME
P1n3appl3 3d707a0
Make requested changes
P1n3appl3 cee8023
More requested changes
P1n3appl3 7621a5b
Refactor DocFS to fix error handling bugs
P1n3appl3 29df050
Pass by value
P1n3appl3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::error; | ||
use std::fmt::{self, Formatter}; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use crate::docfs::PathError; | ||
|
||
#[derive(Debug)] | ||
pub struct Error { | ||
pub file: PathBuf, | ||
pub error: String, | ||
} | ||
|
||
impl error::Error for Error {} | ||
|
||
impl std::fmt::Display for Error { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
let file = self.file.display().to_string(); | ||
if file.is_empty() { | ||
write!(f, "{}", self.error) | ||
} else { | ||
write!(f, "\"{}\": {}", self.file.display(), self.error) | ||
} | ||
} | ||
} | ||
|
||
impl PathError for Error { | ||
fn new<S, P: AsRef<Path>>(e: S, path: P) -> Error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing, but this would be better taking |
||
where | ||
S: ToString + Sized, | ||
{ | ||
Error { file: path.as_ref().to_path_buf(), error: e.to_string() } | ||
} | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! try_none { | ||
($e:expr, $file:expr) => {{ | ||
use std::io; | ||
match $e { | ||
Some(e) => e, | ||
None => { | ||
return Err(Error::new(io::Error::new(io::ErrorKind::Other, "not found"), $file)); | ||
} | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! try_err { | ||
($e:expr, $file:expr) => {{ | ||
match $e { | ||
Ok(e) => e, | ||
Err(e) => return Err(Error::new(e, $file)), | ||
} | ||
}}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing, but do you know why rustdoc uses a separate error type and trait here? It has wrappers around both
io::Error
andstd::error::Error
.