Skip to content

Commit b72e52b

Browse files
committed
Support nightly-2025-07-17 and later
See rust-lang/rust#142936. Closes cargo-public-api#805.
1 parent 7bd0f11 commit b72e52b

File tree

8 files changed

+59
-41
lines changed

8 files changed

+59
-41
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Install the `cargo public-api` subcommand with a recent regular **stable** Rust
1010
cargo +stable install cargo-public-api --locked
1111
```
1212

13-
Ensure **nightly-2025-06-22** or later is installed (does not need to be the active toolchain) so `cargo public-api` can build rustdoc JSON for you:
13+
Ensure **nightly-2025-07-17** or later is installed (does not need to be the active toolchain) so `cargo public-api` can build rustdoc JSON for you:
1414

1515
```sh
1616
rustup install nightly --profile minimal
@@ -155,12 +155,12 @@ cargo public-api -sss
155155

156156
| Version | Understands the rustdoc JSON output of |
157157
| ---------------- | --------------------------------------- |
158-
| 0.48.x | nightly-2025-06-22 — |
158+
| 0.49.x | nightly-2025-07-17 — |
159+
| 0.48.x | nightly-2025-06-22 — nightly-2025-07-16 |
159160
| 0.47.x | nightly-2025-03-24 — nightly-2025-06-21 |
160161
| 0.46.x | nightly-2025-03-16 — nightly-2025-03-23 |
161162
| 0.45.x | nightly-2025-03-14 — nightly-2025-03-15 |
162163
| 0.43.x — 0.44.x | nightly-2025-01-25 — nightly-2025-03-13 |
163-
| 0.40.x — 0.42.x | nightly-2024-10-18 — nightly-2025-01-24 |
164164
| earlier versions | see [here](https://github.com/cargo-public-api/cargo-public-api/blob/main/scripts/release-helper/src/version_info.rs) |
165165

166166
# Contributing

cargo-public-api/MINIMUM_NIGHTLY_RUST_VERSION_FOR_TESTS

Lines changed: 0 additions & 1 deletion
This file was deleted.

public-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ version = "1.0.104"
2323
features = ["unbounded_depth"]
2424

2525
[dependencies.rustdoc-types]
26-
version = "0.53.0"
26+
version = "0.54.0"
2727

2828
[dev-dependencies]
2929
anyhow = "1.0.75"

public-api/src/item_processor.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
public_item::PublicItem, render::RenderingContext,
66
};
77
use rustdoc_types::{
8-
Crate, Id, Impl, Item, ItemEnum, Module, Struct, StructKind, Type, Use, VariantKind,
8+
Attribute, Crate, Id, Impl, Item, ItemEnum, Module, Struct, StructKind, Type, Use, VariantKind,
99
};
1010
use std::{
1111
collections::{HashMap, VecDeque},
@@ -397,10 +397,7 @@ pub(crate) enum ImplKind {
397397
impl ImplKind {
398398
fn from(impl_item: &Item, impl_: &Impl) -> Self {
399399
let has_blanket_impl = impl_.blanket_impl.is_some();
400-
let is_automatically_derived = impl_item
401-
.attrs
402-
.iter()
403-
.any(|a| a == "#[automatically_derived]");
400+
let is_automatically_derived = impl_item.attrs.contains(&Attribute::AutomaticallyDerived);
404401

405402
// See https://github.com/rust-lang/rust/blob/54f20bbb8a7aeab93da17c0019c1aaa10329245a/src/librustdoc/json/conversions.rs#L589-L590
406403
match (impl_.is_synthetic, has_blanket_impl) {

public-api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub use public_item::PublicItem;
6262
/// The rustdoc JSON format is still changing, so every now and then we update
6363
/// this library to support the latest format. If you use this version of
6464
/// nightly or later, you should be fine.
65-
pub const MINIMUM_NIGHTLY_RUST_VERSION: &str = "nightly-2025-06-22";
65+
pub const MINIMUM_NIGHTLY_RUST_VERSION: &str = "nightly-2025-07-17";
6666
// End-marker for scripts/release-helper/src/bin/update-version-info/main.rs
6767

6868
/// See [`Builder`] method docs for what each field means.

public-api/src/render.rs

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::intermediate_public_item::IntermediatePublicItem;
44
use crate::nameable_item::NameableItem;
55
use crate::path_component::PathComponent;
66
use crate::tokens::Token;
7-
use std::{cmp::Ordering, collections::HashMap, vec};
7+
use std::{borrow::Cow, cmp::Ordering, collections::HashMap};
88

99
use rustdoc_types::{
10-
Abi, AssocItemConstraint, AssocItemConstraintKind, Constant, Crate, FunctionHeader,
11-
FunctionPointer, FunctionSignature, GenericArg, GenericArgs, GenericBound, GenericParamDef,
12-
GenericParamDefKind, Generics, Id, Impl, Item, ItemEnum, MacroKind, Path, PolyTrait,
13-
StructKind, Term, Trait, TraitBoundModifier, Type, VariantKind, WherePredicate,
10+
Abi, AssocItemConstraint, AssocItemConstraintKind, Attribute, AttributeRepr, Constant, Crate,
11+
FunctionHeader, FunctionPointer, FunctionSignature, GenericArg, GenericArgs, GenericBound,
12+
GenericParamDef, GenericParamDefKind, Generics, Id, Impl, Item, ItemEnum, MacroKind, Path,
13+
PolyTrait, ReprKind, StructKind, Term, Trait, TraitBoundModifier, Type, VariantKind,
14+
WherePredicate,
1415
};
1516

1617
/// A simple macro to write `Token::Whitespace` in less characters.
@@ -41,9 +42,46 @@ impl<'c> RenderingContext<'c> {
4142
let mut tokens = vec![];
4243

4344
for attr in &item.attrs {
44-
let attr = attr.trim();
45-
if attr_relevant_for_public_apis(attr) {
46-
tokens.push(Token::Annotation(attr.to_string()));
45+
if let Some(annotation) = match attr {
46+
Attribute::ExportName(name) => Some(format!("#[export_name = \"{name}\"]")),
47+
Attribute::LinkSection(section) => Some(format!("#[link_section = \"{section}\"]")),
48+
Attribute::NoMangle => Some("#[no_mangle]".to_string()),
49+
Attribute::NonExhaustive => Some("#[non_exhaustive]".to_string()),
50+
Attribute::Repr(AttributeRepr {
51+
kind,
52+
align,
53+
packed,
54+
int,
55+
}) => {
56+
let mut items: Vec<Cow<'static, str>> = vec![];
57+
if let Some(kind) = match kind {
58+
ReprKind::Rust => None,
59+
ReprKind::C => Some("C"),
60+
ReprKind::Transparent => Some("transparent"),
61+
ReprKind::Simd => Some("simd"),
62+
} {
63+
items.push(Cow::Borrowed(kind));
64+
}
65+
if let Some(align) = align {
66+
items.push(Cow::Owned(format!("align({align})")))
67+
}
68+
if let Some(packed) = packed {
69+
items.push(Cow::Owned(format!("packed({packed})")))
70+
}
71+
if let Some(int) = int {
72+
items.push(Cow::Owned(int.to_string()))
73+
}
74+
(!items.is_empty()).then(|| {
75+
let mut s = String::new();
76+
s.push_str("#[repr(");
77+
s.push_str(&items.join(", "));
78+
s.push_str(")]");
79+
s
80+
})
81+
}
82+
_ => None,
83+
} {
84+
tokens.push(Token::Annotation(annotation));
4785
tokens.push(ws!());
4886
}
4987
}
@@ -1023,26 +1061,6 @@ impl<'c> RenderingContext<'c> {
10231061
}
10241062
}
10251063

1026-
/// Our list of allowed attributes comes from
1027-
/// <https://github.com/rust-lang/rust/blob/68d0b29098/src/librustdoc/html/render/mod.rs#L941-L942>
1028-
fn attr_relevant_for_public_apis(attr: &str) -> bool {
1029-
let keywords = [
1030-
"export_name",
1031-
"link_section",
1032-
"no_mangle",
1033-
"non_exhaustive",
1034-
"repr",
1035-
];
1036-
1037-
for keyword in keywords {
1038-
if attr.to_lowercase().contains(keyword) {
1039-
return true;
1040-
}
1041-
}
1042-
1043-
false
1044-
}
1045-
10461064
fn pub_() -> Vec<Token> {
10471065
vec![Token::qualifier("pub"), ws!()]
10481066
}

scripts/release-helper/src/version_info.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ pub struct CargoPublicApiVersionInfo {
66
}
77

88
pub static TABLE: &[CargoPublicApiVersionInfo] = &[
9+
CargoPublicApiVersionInfo {
10+
cargo_public_api_version: "0.49.x",
11+
min_nightly_rust_version: "nightly-2025-07-17",
12+
},
913
CargoPublicApiVersionInfo {
1014
cargo_public_api_version: "0.48.x",
1115
min_nightly_rust_version: "nightly-2025-06-22",

0 commit comments

Comments
 (0)