Skip to content

Commit b2c051d

Browse files
committed
v0.30.0
1 parent 569b327 commit b2c051d

File tree

5 files changed

+82
-43
lines changed

5 files changed

+82
-43
lines changed

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
<a name="v0.30.0"></a>
2+
# [v0.30.0](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/v0.30.0) - 2024-09-13
3+
4+
**Breaking Change**: Many structs and fields have been renamed ([rust#128667](https://github.com/rust-lang/rust/pull/128667)):
5+
- `Import` is now `Use`, to better reflect the syntax and [the reference](https://doc.rust-lang.org/stable/reference/items/use-declarations.html).
6+
- `TypeBinding` is now `AssocItemConstraint`, to reflect that is can also work on associated constants, and that it can either require the associated item to equal a term, or satisfy bounds.
7+
- Similarly, `TypeBindingKind` is now `AssocItemConstraintKind`
8+
- `bindings` has been renamed to `constraints` on `GenericArgs::AngleBracketed`
9+
- `ForeignType` has been renamed to `ExternType`, because [that's what the feature is called](https://github.com/rust-lang/rust/issues/43467). "Foreign" refers to types that arn't from the current crate, whereas Extern Types are entirely opaque to the type system (and may be in the current crate).
10+
- `ItemEnum::AssocConst` and `ItemEnum::AssocType`'s `default` field has been renamed to `value`, to clairify that they can appear in both an `impl` and `trait` item.
11+
- `Header` is now `FunctionHeader`, to be clearer what it is.
12+
- `FnDecl` is now `FunctionSignature`, as it's also used for `FunctionPointer` types (and not just function items).
13+
- `decl` field is now `sig`
14+
- Boolean fields are now `is_` or `has_` prefixed for clairity:
15+
- `fields_stripped` is now `has_fields_stripped`
16+
- `variants_stripped` is now `has_stripped_variants`
17+
- `const_` is now `is_const`
18+
- `async_` is now `is_async`
19+
- `unsafe_` is now `is_async`
20+
- `synthetic` is now `is_synthetic`
21+
- `mutable` is now `is_mutable`
22+
- `c_variadic` is now `is_c_variadic`
23+
- `negative` is now `is_negative`
24+
- `glob` is now `is_glob`
25+
26+
<br/>
27+
28+
- Format Version: 34
29+
- Upstream Commit: [`f2696ab4d3095bb6ad6197e55855ebdf00f50b80`](https://github.com/rust-lang/rust/commit/f2696ab4d3095bb6ad6197e55855ebdf00f50b80)
30+
- Diff: [v0.29.1...v0.30.0](https://github.com/aDotInTheVoid/rustdoc-types/compare/v0.29.1...v0.30.0)
31+
132
<a name="v0.29.1"></a>
233
# [v0.29.1](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/v0.29.1) - 2024-08-13
334

COMMIT.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9028b5381b2867bcd4d9cd0ba95ff97607deaaf3
1+
f2696ab4d3095bb6ad6197e55855ebdf00f50b80

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustdoc-types"
3-
version = "0.29.1"
3+
version = "0.30.0"
44
edition = "2018"
55
license = "MIT OR Apache-2.0"
66
description = "Types for rustdoc's json output"

src/lib.rs

+47-39
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313
/// This integer is incremented with every breaking change to the API,
1414
/// and is returned along with the JSON blob as [`Crate::format_version`].
1515
/// Consuming code should assert that this value matches the format version(s) that it supports.
16-
pub const FORMAT_VERSION: u32 = 33;
16+
pub const FORMAT_VERSION: u32 = 34;
1717

1818
/// The root of the emitted JSON blob.
1919
///
@@ -194,7 +194,7 @@ pub enum GenericArgs {
194194
/// ```
195195
args: Vec<GenericArg>,
196196
/// Associated type or constant bindings (e.g. `Item=i32` or `Item: Clone`) for this type.
197-
bindings: Vec<TypeBinding>,
197+
constraints: Vec<AssocItemConstraint>,
198198
},
199199
/// `Fn(A, B) -> C`
200200
Parenthesized {
@@ -258,19 +258,19 @@ pub struct Constant {
258258
/// ^^^^^^^^^^ ^^^^^^^^^^^^^^^
259259
/// ```
260260
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
261-
pub struct TypeBinding {
261+
pub struct AssocItemConstraint {
262262
/// The name of the associated type/constant.
263263
pub name: String,
264264
/// Arguments provided to the associated type/constant.
265265
pub args: GenericArgs,
266266
/// The kind of bound applied to the associated type/constant.
267-
pub binding: TypeBindingKind,
267+
pub binding: AssocItemConstraintKind,
268268
}
269269

270270
/// The way in which an associate type/constant is bound.
271271
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
272272
#[serde(rename_all = "snake_case")]
273-
pub enum TypeBindingKind {
273+
pub enum AssocItemConstraintKind {
274274
/// The required value/type is specified exactly. e.g.
275275
/// ```text
276276
/// Iterator<Item = u32, IntoIter: DoubleEndedIterator>
@@ -311,7 +311,7 @@ pub enum ItemKind {
311311
/// A crate imported via the `extern crate` syntax.
312312
ExternCrate,
313313
/// An import of 1 or more items into scope, using the `use` keyword.
314-
Import,
314+
Use,
315315
/// A `struct` declaration.
316316
Struct,
317317
/// A field of a struct.
@@ -341,7 +341,7 @@ pub enum ItemKind {
341341
/// `type`s from an `extern` block.
342342
///
343343
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/43467)
344-
ForeignType,
344+
ExternType,
345345
/// A macro declaration.
346346
///
347347
/// Corresponds to either `ItemEnum::Macro(_)`
@@ -386,7 +386,7 @@ pub enum ItemEnum {
386386
rename: Option<String>,
387387
},
388388
/// An import of 1 or more items into scope, using the `use` keyword.
389-
Import(Import),
389+
Use(Use),
390390

391391
/// A `union` declaration.
392392
Union(Union),
@@ -429,7 +429,7 @@ pub enum ItemEnum {
429429
/// `type`s from an `extern` block.
430430
///
431431
/// See [the tracking issue](https://github.com/rust-lang/rust/issues/43467)
432-
ForeignType,
432+
ExternType,
433433

434434
/// A macro_rules! declarative macro. Contains a single string with the source
435435
/// representation of the macro with the patterns stripped.
@@ -447,12 +447,19 @@ pub enum ItemEnum {
447447
/// The type of the constant.
448448
#[serde(rename = "type")]
449449
type_: Type,
450-
/// The stringified expression for the default value, if provided, e.g.
450+
/// Inside a trait declaration, this is the default value for the associated constant,
451+
/// if provided.
452+
/// Inside an `impl` block, this is the value assigned to the associated constant,
453+
/// and will always be present.
454+
///
455+
/// The representation is implementation-defined and not guaranteed to be representative of
456+
/// either the resulting value or of the source code.
457+
///
451458
/// ```rust
452459
/// const X: usize = 640 * 1024;
453460
/// // ^^^^^^^^^^
454461
/// ```
455-
default: Option<String>,
462+
value: Option<String>,
456463
},
457464
/// An associated type of a trait or a type.
458465
AssocType {
@@ -467,12 +474,16 @@ pub enum ItemEnum {
467474
/// }
468475
/// ```
469476
bounds: Vec<GenericBound>,
470-
/// The default for this type, if provided, e.g.
477+
/// Inside a trait declaration, this is the default for the associated type, if provided.
478+
/// Inside an impl block, this is the type assigned to the associated type, and will always
479+
/// be present.
480+
///
471481
/// ```rust
472482
/// type X = usize;
473483
/// // ^^^^^
474484
/// ```
475-
default: Option<Type>,
485+
#[serde(rename = "type")]
486+
type_: Option<Type>,
476487
},
477488
}
478489

@@ -497,7 +508,7 @@ pub struct Union {
497508
/// The generic parameters and where clauses on this union.
498509
pub generics: Generics,
499510
/// Whether any fields have been removed from the result, due to being private or hidden.
500-
pub fields_stripped: bool,
511+
pub has_stripped_fields: bool,
501512
/// The list of fields in the union.
502513
///
503514
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::StructField`].
@@ -554,7 +565,7 @@ pub enum StructKind {
554565
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::StructField`].
555566
fields: Vec<Id>,
556567
/// Whether any fields have been removed from the result, due to being private or hidden.
557-
fields_stripped: bool,
568+
has_stripped_fields: bool,
558569
},
559570
}
560571

@@ -564,7 +575,7 @@ pub struct Enum {
564575
/// Information about the type parameters and `where` clauses of the enum.
565576
pub generics: Generics,
566577
/// Whether any variants have been removed from the result, due to being private or hidden.
567-
pub variants_stripped: bool,
578+
pub has_stripped_variants: bool,
568579
/// The list of variants in the enum.
569580
///
570581
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::Variant`]
@@ -621,7 +632,7 @@ pub enum VariantKind {
621632
/// All of the corresponding [`Item`]s are of kind [`ItemEnum::Variant`].
622633
fields: Vec<Id>,
623634
/// Whether any variants have been removed from the result, due to being private or hidden.
624-
fields_stripped: bool,
635+
has_stripped_fields: bool,
625636
},
626637
}
627638

@@ -645,16 +656,13 @@ pub struct Discriminant {
645656

646657
/// A set of fundamental properties of a function.
647658
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
648-
pub struct Header {
659+
pub struct FunctionHeader {
649660
/// Is this function marked as `const`?
650-
#[serde(rename = "const")]
651-
pub const_: bool,
661+
pub is_const: bool,
652662
/// Is this function unsafe?
653-
#[serde(rename = "unsafe")]
654-
pub unsafe_: bool,
663+
pub is_unsafe: bool,
655664
/// Is this function async?
656-
#[serde(rename = "async")]
657-
pub async_: bool,
665+
pub is_async: bool,
658666
/// The ABI used by the function.
659667
pub abi: Abi,
660668
}
@@ -697,11 +705,11 @@ pub enum Abi {
697705
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
698706
pub struct Function {
699707
/// Information about the function signature, or declaration.
700-
pub decl: FnDecl,
708+
pub sig: FunctionSignature,
701709
/// Information about the function’s type parameters and `where` clauses.
702710
pub generics: Generics,
703711
/// Information about core properties of the function, e.g. whether it's `const`, its ABI, etc.
704-
pub header: Header,
712+
pub header: FunctionHeader,
705713
/// Whether the function has a body, i.e. an implementation.
706714
pub has_body: bool,
707715
}
@@ -784,7 +792,7 @@ pub enum GenericParamDefKind {
784792
/// In this example, the generic parameter named `impl Trait` (and which
785793
/// is bound by `Trait`) is synthetic, because it was not originally in
786794
/// the Rust source text.
787-
synthetic: bool,
795+
is_synthetic: bool,
788796
},
789797

790798
/// Denotes a constant parameter.
@@ -894,7 +902,7 @@ pub enum TraitBoundModifier {
894902
}
895903

896904
/// Either a type or a constant, usually stored as the right-hand side of an equation in places like
897-
/// [`TypeBinding`]
905+
/// [`AssocItemConstraint`]
898906
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
899907
#[serde(rename_all = "snake_case")]
900908
pub enum Term {
@@ -963,7 +971,7 @@ pub enum Type {
963971
/// A raw pointer type, e.g. `*mut u32`, `*const u8`, etc.
964972
RawPointer {
965973
/// This is `true` for `*mut _` and `false` for `*const _`.
966-
mutable: bool,
974+
is_mutable: bool,
967975
/// The type of the pointee.
968976
#[serde(rename = "type")]
969977
type_: Box<Type>,
@@ -973,7 +981,7 @@ pub enum Type {
973981
/// The name of the lifetime of the reference, if provided.
974982
lifetime: Option<String>,
975983
/// This is `true` for `&mut i32` and `false` for `&i32`
976-
mutable: bool,
984+
is_mutable: bool,
977985
/// The type of the pointee, e.g. the `i32` in `&'a mut i32`
978986
#[serde(rename = "type")]
979987
type_: Box<Type>,
@@ -1036,7 +1044,7 @@ pub struct Path {
10361044
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10371045
pub struct FunctionPointer {
10381046
/// The signature of the function.
1039-
pub decl: FnDecl,
1047+
pub sig: FunctionSignature,
10401048
/// Used for Higher-Rank Trait Bounds (HRTBs)
10411049
///
10421050
/// ```ignore (incomplete expression)
@@ -1045,12 +1053,12 @@ pub struct FunctionPointer {
10451053
/// ```
10461054
pub generic_params: Vec<GenericParamDef>,
10471055
/// The core properties of the function, such as the ABI it conforms to, whether it's unsafe, etc.
1048-
pub header: Header,
1056+
pub header: FunctionHeader,
10491057
}
10501058

10511059
/// The signature of a function.
10521060
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
1053-
pub struct FnDecl {
1061+
pub struct FunctionSignature {
10541062
/// List of argument names and their type.
10551063
///
10561064
/// Note that not all names will be valid identifiers, as some of
@@ -1063,7 +1071,7 @@ pub struct FnDecl {
10631071
/// ```ignore (incomplete code)
10641072
/// fn printf(fmt: &str, ...);
10651073
/// ```
1066-
pub c_variadic: bool,
1074+
pub is_c_variadic: bool,
10671075
}
10681076

10691077
/// A `trait` declaration.
@@ -1127,18 +1135,18 @@ pub struct Impl {
11271135
/// The list of associated items contained in this impl block.
11281136
pub items: Vec<Id>,
11291137
/// Whether this is a negative impl (e.g. `!Sized` or `!Send`).
1130-
pub negative: bool,
1138+
pub is_negative: bool,
11311139
/// Whether this is an impl that’s implied by the compiler
11321140
/// (for autotraits, e.g. `Send` or `Sync`).
1133-
pub synthetic: bool,
1141+
pub is_synthetic: bool,
11341142
// FIXME: document this
11351143
pub blanket_impl: Option<Type>,
11361144
}
11371145

11381146
/// A `use` statement.
11391147
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
11401148
#[serde(rename_all = "snake_case")]
1141-
pub struct Import {
1149+
pub struct Use {
11421150
/// The full path being imported.
11431151
pub source: String,
11441152
/// May be different from the last segment of `source` when renaming imports:
@@ -1150,7 +1158,7 @@ pub struct Import {
11501158
/// ```
11511159
pub id: Option<Id>,
11521160
/// Whether this statement is a wildcard `use`, e.g. `use source::*;`
1153-
pub glob: bool,
1161+
pub is_glob: bool,
11541162
}
11551163

11561164
/// A procedural macro.
@@ -1205,7 +1213,7 @@ pub struct Static {
12051213
#[serde(rename = "type")]
12061214
pub type_: Type,
12071215
/// This is `true` for mutable statics, declared as `static mut X: T = f();`
1208-
pub mutable: bool,
1216+
pub is_mutable: bool,
12091217
/// The stringified expression for the initial value.
12101218
///
12111219
/// It's not guaranteed that it'll match the actual source code for the initial value.

src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::*;
44
fn test_struct_info_roundtrip() {
55
let s = ItemEnum::Struct(Struct {
66
generics: Generics { params: vec![], where_predicates: vec![] },
7-
kind: StructKind::Plain { fields: vec![], fields_stripped: false },
7+
kind: StructKind::Plain { fields: vec![], has_stripped_fields: false },
88
impls: vec![],
99
});
1010

@@ -23,7 +23,7 @@ fn test_struct_info_roundtrip() {
2323
fn test_union_info_roundtrip() {
2424
let u = ItemEnum::Union(Union {
2525
generics: Generics { params: vec![], where_predicates: vec![] },
26-
fields_stripped: false,
26+
has_stripped_fields: false,
2727
fields: vec![],
2828
impls: vec![],
2929
});

0 commit comments

Comments
 (0)