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/ui/", # Some have syntax errors, some are whitespace-sensitive.
"/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.
# FIXME: sync submodule list with tidy/bootstrap/etc

View File

@ -542,6 +542,7 @@ fn from_tcx(bound: clean::GenericBound, tcx: TyCtxt<'_>) -> Self {
}
}
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 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
@ -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)]

View File

@ -298,6 +298,7 @@ fn check_generic_bound(&mut self, x: &'a GenericBound) {
generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd));
}
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> {}