Skip to content

Commit b4f057f

Browse files
committed
fix typos, more Self
typos in comments, remove references to crate-info, Self type in ordered_json and sorted_template
1 parent 4b418cd commit b4f057f

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

src/librustdoc/html/render/ordered_json.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use itertools::Itertools as _;
55
use serde::{Deserialize, Serialize};
66
use serde_json::Value;
77

8-
/// Prerenedered json.
8+
/// Prerendered json.
99
///
1010
/// Both the Display and serde_json::to_string implementations write the serialized json
1111
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
@@ -16,25 +16,21 @@ pub(crate) struct OrderedJson(String);
1616
impl OrderedJson {
1717
/// If you pass in an array, it will not be sorted.
1818
pub(crate) fn serialize<T: Serialize>(item: T) -> Result<Self, serde_json::Error> {
19-
Ok(OrderedJson(serde_json::to_string(&item)?))
19+
Ok(Self(serde_json::to_string(&item)?))
2020
}
2121

2222
/// Serializes and sorts
23-
pub(crate) fn array_sorted<T: Borrow<OrderedJson>, I: IntoIterator<Item = T>>(
24-
items: I,
25-
) -> Self {
23+
pub(crate) fn array_sorted<T: Borrow<Self>, I: IntoIterator<Item = T>>(items: I) -> Self {
2624
let items = items
2725
.into_iter()
2826
.sorted_unstable_by(|a, b| a.borrow().cmp(&b.borrow()))
2927
.format_with(",", |item, f| f(item.borrow()));
30-
OrderedJson(format!("[{}]", items))
28+
Self(format!("[{}]", items))
3129
}
3230

33-
pub(crate) fn array_unsorted<T: Borrow<OrderedJson>, I: IntoIterator<Item = T>>(
34-
items: I,
35-
) -> Self {
31+
pub(crate) fn array_unsorted<T: Borrow<Self>, I: IntoIterator<Item = T>>(items: I) -> Self {
3632
let items = items.into_iter().format_with(",", |item, f| f(item.borrow()));
37-
OrderedJson(format!("[{items}]"))
33+
Self(format!("[{items}]"))
3834
}
3935
}
4036

@@ -48,7 +44,7 @@ impl From<Value> for OrderedJson {
4844
fn from(value: Value) -> Self {
4945
let serialized =
5046
serde_json::to_string(&value).expect("Serializing a Value to String should never fail");
51-
OrderedJson(serialized)
47+
Self(serialized)
5248
}
5349
}
5450

@@ -69,7 +65,7 @@ pub(crate) struct EscapedJson(OrderedJson);
6965

7066
impl From<OrderedJson> for EscapedJson {
7167
fn from(json: OrderedJson) -> Self {
72-
EscapedJson(json)
68+
Self(json)
7369
}
7470
}
7571

src/librustdoc/html/render/sorted_template.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct Offset {
2828

2929
impl<F> SortedTemplate<F> {
3030
/// Generate this template from arbitary text.
31-
/// Will insert wherever the substring `magic` can be found.
31+
/// Will insert wherever the substring `delimiter` can be found.
3232
/// Errors if it does not appear exactly once.
3333
pub(crate) fn from_template(template: &str, delimiter: &str) -> Result<Self, Error> {
3434
let mut split = template.split(delimiter);
@@ -45,7 +45,7 @@ impl<F> SortedTemplate<F> {
4545
pub(crate) fn from_before_after<S: ToString, T: ToString>(before: S, after: T) -> Self {
4646
let before = before.to_string();
4747
let after = after.to_string();
48-
SortedTemplate { format: PhantomData, before, after, fragments: Default::default() }
48+
Self { format: PhantomData, before, after, fragments: Default::default() }
4949
}
5050
}
5151

@@ -100,7 +100,7 @@ impl<F: FileFormat> FromStr for SortedTemplate<F> {
100100
.ok_or(Error("invalid fragment length: expected to find separator here"))?;
101101
fragments.insert(fragment.to_string());
102102
}
103-
Ok(SortedTemplate {
103+
Ok(Self {
104104
format: PhantomData,
105105
before: before.to_string(),
106106
after: s.to_string(),

src/librustdoc/html/render/write_shared.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use crate::html::static_files::{self, suffix_path};
5555
use crate::visit::DocVisitor;
5656
use crate::{try_err, try_none};
5757

58-
/// Write crate-info.json cross-crate information, static files, invocation-specific files, etc. to disk
58+
/// Write cross-crate information files, static files, invocation-specific files, etc. to disk
5959
pub(crate) fn write_shared(
6060
cx: &mut Context<'_>,
6161
krate: &Crate,
@@ -184,7 +184,7 @@ fn write_search_desc(
184184
Ok(())
185185
}
186186

187-
/// Written to `crate-info.json`. Contains pre-rendered contents to insert into the CCI template
187+
/// Contains pre-rendered contents to insert into the CCI template
188188
#[derive(Serialize, Deserialize, Clone, Debug)]
189189
struct CrateInfo {
190190
src_files_js: PartsAndLocations<SourcesPart>,

0 commit comments

Comments
 (0)