Add rustdoc-json support for use<>

This commit is contained in:
Michael Goulet 2024-07-11 19:50:03 -04:00
parent 843f5dd93b
commit bd135e487f
5 changed files with 13 additions and 1 deletions

View file

@ -22,6 +22,8 @@ ignore = [
"/tests/rustdoc-ui/", # Some have syntax errors, some are whitespace-sensitive. "/tests/rustdoc-ui/", # Some have syntax errors, some are whitespace-sensitive.
"/tests/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/ui-fulldeps/", # Some are whitespace-sensitive (e.g. `// ~ERROR` comments).
# #[cfg(bootstrap)] so that t-release sees this when they search for it
"/tests/rustdoc-json/impl-trait-precise-capturing.rs",
# Do not format submodules. # Do not format submodules.
# FIXME: sync submodule list with tidy/bootstrap/etc # FIXME: sync submodule list with tidy/bootstrap/etc

View file

@ -542,6 +542,7 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
} }
} }
Outlives(lifetime) => GenericBound::Outlives(convert_lifetime(lifetime)), Outlives(lifetime) => GenericBound::Outlives(convert_lifetime(lifetime)),
Use(args) => GenericBound::Use(args.into_iter().map(|arg| arg.to_string()).collect()),
} }
} }
} }

View file

@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
/// rustdoc format-version. /// 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 /// 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 /// about the language items in the local crate, as well as info about external items to allow
@ -538,6 +538,8 @@ pub enum GenericBound {
modifier: TraitBoundModifier, modifier: TraitBoundModifier,
}, },
Outlives(String), Outlives(String),
/// `use<'a, T>` precise-capturing bound syntax
Use(Vec<String>),
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

View file

@ -298,6 +298,7 @@ impl<'a> Validator<'a> {
generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd)); generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd));
} }
GenericBound::Outlives(_) => {} GenericBound::Outlives(_) => {}
GenericBound::Use(_) => {}
} }
} }

View file

@ -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> {}