Skip to content

Hide synthetic generic params #33

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

Merged
merged 2 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/implementation/intermediate_public_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,20 @@ impl Display for D<&FnDecl> {

impl Display for D<&Vec<GenericParamDef>> {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if !self.0.is_empty() {
write!(f, "<{}>", Joiner(self.0, ", ", D))?;
let params_without_synthetics: Vec<_> = self
.0
.iter()
// For now we use a heuristic that I think is pretty solid.
// Once https://github.com/rust-lang/rust/pull/94150 is fixed
// we should replace this with a solid and simple check for `.synthetic`
.filter(|p| !p.name.starts_with("impl "))
.collect();
if !&params_without_synthetics.is_empty() {
write!(
f,
"<{}>",
Joiner(&params_without_synthetics, ", ", |x| D(*x))
)?;
}

Ok(())
Expand Down Expand Up @@ -416,7 +428,7 @@ impl Display for D<&GenericArgs> {
if !inputs.is_empty() {
write!(
f,
"Fn<{}>{}",
"({}){}",
Joiner(inputs, ", ", D),
Optional(" -> ", output.as_ref().map(D))
)?;
Expand Down
26 changes: 13 additions & 13 deletions tests/rustdoc_json/bat-v0.19.0-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ pub enum variant bat::style::StyleComponent::Rule
pub enum variant bat::style::StyleComponent::Snip
pub fn bat::Input::from(input: input::Input<'a>) -> Self
pub fn bat::Input::from_bytes(bytes: &'a [u8]) -> Self
pub fn bat::Input::from_file<impl AsRef<Path>: AsRef<Path>>(path: impl AsRef<Path>) -> Self
pub fn bat::Input::from_file(path: impl AsRef<Path>) -> Self
pub fn bat::Input::from_reader<R: Read, 'a>(reader: R) -> Self
pub fn bat::Input::from_stdin() -> Self
pub fn bat::Input::kind<impl Into<String>: Into<String>>(self, kind: impl Into<String>) -> Self
pub fn bat::Input::name<impl AsRef<Path>: AsRef<Path>>(self, name: impl AsRef<Path>) -> Self
pub fn bat::Input::title<impl Into<String>: Into<String>>(self, title: impl Into<String>) -> Self
pub fn bat::Input::kind(self, kind: impl Into<String>) -> Self
pub fn bat::Input::name(self, name: impl AsRef<Path>) -> Self
pub fn bat::Input::title(self, title: impl Into<String>) -> Self
pub fn bat::MappingTarget::clone(&self) -> MappingTarget<'a>
pub fn bat::MappingTarget::eq(&self, other: &MappingTarget<'a>) -> bool
pub fn bat::MappingTarget::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
Expand All @@ -60,12 +60,12 @@ pub fn bat::PrettyPrinter::header(&mut self, yes: bool) -> &mut Self
pub fn bat::PrettyPrinter::highlight(&mut self, line: usize) -> &mut Self
pub fn bat::PrettyPrinter::highlight_range(&mut self, from: usize, to: usize) -> &mut Self
pub fn bat::PrettyPrinter::input(&mut self, input: Input<'a>) -> &mut Self
pub fn bat::PrettyPrinter::input_file<impl AsRef<Path>: AsRef<Path>>(&mut self, path: impl AsRef<Path>) -> &mut Self
pub fn bat::PrettyPrinter::input_file(&mut self, path: impl AsRef<Path>) -> &mut Self
pub fn bat::PrettyPrinter::input_files<I, P>(&mut self, paths: I) -> &mut Self where I: IntoIterator<Item = P>, P: AsRef<Path>
pub fn bat::PrettyPrinter::input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self
pub fn bat::PrettyPrinter::input_from_reader<R: Read, 'a>(&mut self, reader: R) -> &mut Self
pub fn bat::PrettyPrinter::input_stdin(&mut self) -> &mut Self
pub fn bat::PrettyPrinter::inputs<impl IntoIterator<Item = Input<'a>>: IntoIterator<Item = Input<'a>>>(&mut self, inputs: impl IntoIterator<Item = Input<'a>>) -> &mut Self
pub fn bat::PrettyPrinter::inputs(&mut self, inputs: impl IntoIterator<Item = Input<'a>>) -> &mut Self
pub fn bat::PrettyPrinter::language(&mut self, language: &'a str) -> &mut Self
pub fn bat::PrettyPrinter::line_numbers(&mut self, yes: bool) -> &mut Self
pub fn bat::PrettyPrinter::line_ranges(&mut self, ranges: LineRanges) -> &mut Self
Expand All @@ -79,7 +79,7 @@ pub fn bat::PrettyPrinter::syntax_mapping(&mut self, mapping: SyntaxMapping<'a>)
pub fn bat::PrettyPrinter::syntaxes(&self) -> impl Iterator<Item = &SyntaxReference>
pub fn bat::PrettyPrinter::tab_width(&mut self, tab_width: Option<usize>) -> &mut Self
pub fn bat::PrettyPrinter::term_width(&mut self, width: usize) -> &mut Self
pub fn bat::PrettyPrinter::theme<impl AsRef<str>: AsRef<str>>(&mut self, theme: impl AsRef<str>) -> &mut Self
pub fn bat::PrettyPrinter::theme(&mut self, theme: impl AsRef<str>) -> &mut Self
pub fn bat::PrettyPrinter::themes(&self) -> impl Iterator<Item = &str>
pub fn bat::PrettyPrinter::true_color(&mut self, yes: bool) -> &mut Self
pub fn bat::PrettyPrinter::use_italics(&mut self, yes: bool) -> &mut Self
Expand All @@ -102,10 +102,10 @@ pub fn bat::assets::HighlightingAssets::default_theme() -> &'static str
pub fn bat::assets::HighlightingAssets::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
pub fn bat::assets::HighlightingAssets::from_binary() -> Self
pub fn bat::assets::HighlightingAssets::from_cache(cache_path: &Path) -> Result<Self>
pub fn bat::assets::HighlightingAssets::get_syntax_for_path<impl AsRef<Path>: AsRef<Path>>(&self, path: impl AsRef<Path>, mapping: &SyntaxMapping<'_>) -> Result<SyntaxReferenceInSet<'_>>
pub fn bat::assets::HighlightingAssets::get_syntax_for_path(&self, path: impl AsRef<Path>, mapping: &SyntaxMapping<'_>) -> Result<SyntaxReferenceInSet<'_>>
pub fn bat::assets::HighlightingAssets::get_syntaxes(&self) -> Result<&[SyntaxReference]>
pub fn bat::assets::HighlightingAssets::set_fallback_theme(&mut self, theme: &'static str)
pub fn bat::assets::HighlightingAssets::syntax_for_file_name<impl AsRef<Path>: AsRef<Path>>(&self, file_name: impl AsRef<Path>, mapping: &SyntaxMapping<'_>) -> Option<&SyntaxReference>
pub fn bat::assets::HighlightingAssets::syntax_for_file_name(&self, file_name: impl AsRef<Path>, mapping: &SyntaxMapping<'_>) -> Option<&SyntaxReference>
pub fn bat::assets::HighlightingAssets::syntaxes(&self) -> &[SyntaxReference]
pub fn bat::assets::HighlightingAssets::themes(&self) -> impl Iterator<Item = &str>
pub fn bat::assets::SyntaxReferenceInSet::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
Expand All @@ -129,7 +129,7 @@ pub fn bat::config::VisibleLines::fmt(&self, f: &mut $crate::fmt::Formatter<'_>)
pub fn bat::config::get_pager_executable(config_pager: Option<&str>) -> Option<String>
pub fn bat::controller::Controller::new<'a>(config: &'a Config<'_>, assets: &'a HighlightingAssets) -> Controller<'a>
pub fn bat::controller::Controller::run(&self, inputs: Vec<Input<'_>>) -> Result<bool>
pub fn bat::controller::Controller::run_with_error_handler<impl Fn(&Error, &mut dyn Write): FnFn<&Error, &mut Write>>(&self, inputs: Vec<Input<'_>>, handle_error: impl FnFn<&Error, &mut Write>) -> Result<bool>
pub fn bat::controller::Controller::run_with_error_handler(&self, inputs: Vec<Input<'_>>, handle_error: impl Fn(&Error, &mut Write)) -> Result<bool>
pub fn bat::error::Error::fmt(&self, __formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
pub fn bat::error::Error::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
pub fn bat::error::Error::from(s: &'static str) -> Self
Expand All @@ -146,12 +146,12 @@ pub fn bat::input::Input::description_mut(&mut self) -> &mut InputDescription
pub fn bat::input::Input::from(_: Input<'a>) -> Self
pub fn bat::input::Input::from_reader(reader: Box<Read + 'a>) -> Self
pub fn bat::input::Input::is_stdin(&self) -> bool
pub fn bat::input::Input::ordinary_file<impl AsRef<Path>: AsRef<Path>>(path: impl AsRef<Path>) -> Self
pub fn bat::input::Input::ordinary_file(path: impl AsRef<Path>) -> Self
pub fn bat::input::Input::stdin() -> Self
pub fn bat::input::Input::with_name<impl AsRef<Path>: AsRef<Path>>(self, provided_name: Option<impl AsRef<Path>>) -> Self
pub fn bat::input::Input::with_name(self, provided_name: Option<impl AsRef<Path>>) -> Self
pub fn bat::input::InputDescription::clone(&self) -> InputDescription
pub fn bat::input::InputDescription::kind(&self) -> Option<&String>
pub fn bat::input::InputDescription::new<impl Into<String>: Into<String>>(name: impl Into<String>) -> Self
pub fn bat::input::InputDescription::new(name: impl Into<String>) -> Self
pub fn bat::input::InputDescription::set_kind(&mut self, kind: Option<String>)
pub fn bat::input::InputDescription::set_summary(&mut self, summary: Option<String>)
pub fn bat::input::InputDescription::set_title(&mut self, title: Option<String>)
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc_json/syntect-v4.6.0-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub fn syntect::parsing::ScopeRepository::build(&mut self, s: &str) -> Result<Sc
pub fn syntect::parsing::ScopeRepository::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
pub fn syntect::parsing::ScopeRepository::to_string(&self, scope: Scope) -> String
pub fn syntect::parsing::ScopeStack::apply(&mut self, op: &ScopeStackOp)
pub fn syntect::parsing::ScopeStack::apply_with_hook<F>(&mut self, op: &ScopeStackOp, hook: F) where F: FnMutFn<BasicScopeStackOp, &[Scope]>
pub fn syntect::parsing::ScopeStack::apply_with_hook<F>(&mut self, op: &ScopeStackOp, hook: F) where F: FnMut(BasicScopeStackOp, &[Scope])
pub fn syntect::parsing::ScopeStack::as_slice(&self) -> &[Scope]
pub fn syntect::parsing::ScopeStack::bottom_n(&self, n: usize) -> &[Scope]
pub fn syntect::parsing::ScopeStack::clone(&self) -> ScopeStack
Expand Down