Skip to content

Commit bd135e4

Browse files
Add rustdoc-json support for use<>
1 parent 843f5dd commit bd135e4

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

rustfmt.toml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ignore = [
2222
"/tests/rustdoc-ui/", # Some have syntax errors, some are whitespace-sensitive.
2323
"/tests/ui/", # Some have syntax errors, some are whitespace-sensitive.
2424
"/tests/ui-fulldeps/", # Some are whitespace-sensitive (e.g. `// ~ERROR` comments).
25+
# #[cfg(bootstrap)] so that t-release sees this when they search for it
26+
"/tests/rustdoc-json/impl-trait-precise-capturing.rs",
2527

2628
# Do not format submodules.
2729
# FIXME: sync submodule list with tidy/bootstrap/etc

src/librustdoc/json/conversions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ impl FromWithTcx<clean::GenericBound> for GenericBound {
542542
}
543543
}
544544
Outlives(lifetime) => GenericBound::Outlives(convert_lifetime(lifetime)),
545+
Use(args) => GenericBound::Use(args.into_iter().map(|arg| arg.to_string()).collect()),
545546
}
546547
}
547548
}

src/rustdoc-json-types/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88
use std::path::PathBuf;
99

1010
/// rustdoc format-version.
11-
pub const FORMAT_VERSION: u32 = 31;
11+
pub const FORMAT_VERSION: u32 = 32;
1212

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

543545
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

src/tools/jsondoclint/src/validator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ impl<'a> Validator<'a> {
298298
generic_params.iter().for_each(|gpd| self.check_generic_param_def(gpd));
299299
}
300300
GenericBound::Outlives(_) => {}
301+
GenericBound::Use(_) => {}
301302
}
302303
}
303304

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(precise_capturing)]
2+
3+
// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[0]" \"\'a\"
4+
// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[1]" \"T\"
5+
// @is "$.index[*][?(@.name=='hello')].inner.function.decl.output.impl_trait[1].use[2]" \"N\"
6+
pub fn hello<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {}

0 commit comments

Comments
 (0)