Skip to content

Commit

Permalink
Add rustdoc-json support for use<>
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jul 11, 2024
1 parent 2994bb4 commit db0136d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ignore = [
"/tests/rustdoc-ui/", # Some have syntax errors, some are whitespace-sensitive.
"/tests/ui/", # Some have syntax errors, some are whitespace-sensitive.
"/tests/ui-fulldeps/", # Some are whitespace-sensitive (e.g. `// ~ERROR` comments).
"/tests/rustdoc-json/impl-trait-precise-capturing.rs",

# Do not format submodules.
# FIXME: sync submodule list with tidy/bootstrap/etc
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
}
}
Outlives(lifetime) => GenericBound::Outlives(convert_lifetime(lifetime)),
Use(args) => GenericBound::Use(args.into_iter().map(|arg| arg.to_string()).collect()),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/rustdoc-json-types/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 31;
pub const FORMAT_VERSION: u32 = 32;

/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
Expand Down Expand Up @@ -538,6 +538,8 @@ pub enum GenericBound {
modifier: TraitBoundModifier,
},
Outlives(String),
/// `use<'a, T>` precise-capturing bound syntax
Use(Vec<String>),
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/tools/jsondoclint/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ impl<'a> Validator<'a> {
generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd));
}
GenericBound::Outlives(_) => {}
GenericBound::Use(_) => {}
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/rustdoc-json/impl-trait-precise-capturing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![feature(precise_capturing)]

// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[0]" \"\'a\"
// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[1]" \"T\"
// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[2]" \"N\"
pub fn hello<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {}

0 comments on commit db0136d

Please sign in to comment.