Skip to content

Commit a03ce81

Browse files
committed
Rollup merge of rust-lang#22273 - nagisa:doc-deprecated, r=alexcrichton
Since we don’t have Deprecated stability level anymore, the only other source of information is deprecated-since version, which conveniently to us, only exists if the symbol is deprecated. Fixes rust-lang#21789
2 parents d264ef2 + 6a67d86 commit a03ce81

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,7 @@ pub struct Stability {
24902490
pub level: attr::StabilityLevel,
24912491
pub feature: String,
24922492
pub since: String,
2493+
pub deprecated_since: String,
24932494
pub reason: String
24942495
}
24952496

@@ -2500,6 +2501,8 @@ impl Clean<Stability> for attr::Stability {
25002501
feature: self.feature.to_string(),
25012502
since: self.since.as_ref().map_or("".to_string(),
25022503
|interned| interned.to_string()),
2504+
deprecated_since: self.deprecated_since.as_ref().map_or("".to_string(),
2505+
|istr| istr.to_string()),
25032506
reason: self.reason.as_ref().map_or("".to_string(),
25042507
|interned| interned.to_string()),
25052508
}

src/librustdoc/html/format.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,11 @@ impl<'a> fmt::Display for Stability<'a> {
711711
match *stab {
712712
Some(ref stability) => {
713713
write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
714-
lvl = stability.level,
714+
lvl = if stability.deprecated_since.is_empty() {
715+
format!("{}", stability.level)
716+
} else {
717+
"Deprecated".to_string()
718+
},
715719
reason = stability.reason)
716720
}
717721
None => Ok(())
@@ -725,7 +729,11 @@ impl<'a> fmt::Display for ConciseStability<'a> {
725729
match *stab {
726730
Some(ref stability) => {
727731
write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>",
728-
lvl = stability.level,
732+
lvl = if stability.deprecated_since.is_empty() {
733+
format!("{}", stability.level)
734+
} else {
735+
"Deprecated".to_string()
736+
},
729737
colon = if stability.reason.len() > 0 { ": " } else { "" },
730738
reason = stability.reason)
731739
}
@@ -763,6 +771,9 @@ impl fmt::Display for ModuleSummary {
763771
try!(write!(f, "<span class='summary Unstable' \
764772
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
765773
(100 * cnt.unstable) as f64/tot as f64));
774+
try!(write!(f, "<span class='summary Deprecated' \
775+
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
776+
(100 * cnt.deprecated) as f64/tot as f64));
766777
try!(write!(f, "<span class='summary Unmarked' \
767778
style='width: {:.4}%; display: inline-block'>&nbsp</span>",
768779
(100 * cnt.unmarked) as f64/tot as f64));
@@ -778,11 +789,12 @@ impl fmt::Display for ModuleSummary {
778789
let mut context = Vec::new();
779790

780791
let tot = self.counts.total();
781-
let (stable, unstable, unmarked) = if tot == 0 {
782-
(0, 0, 0)
792+
let (stable, unstable, deprecated, unmarked) = if tot == 0 {
793+
(0, 0, 0, 0)
783794
} else {
784795
((100 * self.counts.stable)/tot,
785796
(100 * self.counts.unstable)/tot,
797+
(100 * self.counts.deprecated)/tot,
786798
(100 * self.counts.unmarked)/tot)
787799
};
788800

@@ -794,11 +806,12 @@ its children (percentages total for {name}):
794806
<blockquote>
795807
<a class='stability Stable'></a> stable ({}%),<br/>
796808
<a class='stability Unstable'></a> unstable ({}%),<br/>
809+
<a class='stability Deprecated'></a> deprecated ({}%),<br/>
797810
<a class='stability Unmarked'></a> unmarked ({}%)
798811
</blockquote>
799812
The counts do not include methods or trait
800813
implementations that are visible only through a re-exported type.",
801-
stable, unstable, unmarked,
814+
stable, unstable, deprecated, unmarked,
802815
name=self.name));
803816
try!(write!(f, "<table>"));
804817
try!(fmt_inner(f, &mut context, self));

src/librustdoc/stability_summary.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ use html::render::cache;
2929
/// The counts for each stability level.
3030
#[derive(Copy)]
3131
pub struct Counts {
32-
pub unstable: uint,
33-
pub stable: uint,
32+
pub deprecated: u64,
33+
pub unstable: u64,
34+
pub stable: u64,
3435

3536
/// No stability level, inherited or otherwise.
36-
pub unmarked: uint,
37+
pub unmarked: u64,
3738
}
3839

3940
impl Add for Counts {
4041
type Output = Counts;
4142

4243
fn add(self, other: Counts) -> Counts {
4344
Counts {
45+
deprecated: self.deprecated + other.deprecated,
4446
unstable: self.unstable + other.unstable,
4547
stable: self.stable + other.stable,
4648
unmarked: self.unmarked + other.unmarked,
@@ -51,14 +53,15 @@ impl Add for Counts {
5153
impl Counts {
5254
fn zero() -> Counts {
5355
Counts {
56+
deprecated: 0,
5457
unstable: 0,
5558
stable: 0,
5659
unmarked: 0,
5760
}
5861
}
5962

60-
pub fn total(&self) -> uint {
61-
self.unstable + self.stable + self.unmarked
63+
pub fn total(&self) -> u64 {
64+
self.deprecated + self.unstable + self.stable + self.unmarked
6265
}
6366
}
6467

@@ -94,9 +97,14 @@ fn visible(item: &Item) -> bool {
9497
fn count_stability(stab: Option<&Stability>) -> Counts {
9598
match stab {
9699
None => Counts { unmarked: 1, .. Counts::zero() },
97-
Some(ref stab) => match stab.level {
98-
Unstable => Counts { unstable: 1, .. Counts::zero() },
99-
Stable => Counts { stable: 1, .. Counts::zero() },
100+
Some(ref stab) => {
101+
if !stab.deprecated_since.is_empty() {
102+
return Counts { deprecated: 1, .. Counts::zero() };
103+
}
104+
match stab.level {
105+
Unstable => Counts { unstable: 1, .. Counts::zero() },
106+
Stable => Counts { stable: 1, .. Counts::zero() },
107+
}
100108
}
101109
}
102110
}

0 commit comments

Comments
 (0)