Skip to content

Commit 5a0d747

Browse files
Remove clean::Mutability enum
1 parent 0a440b1 commit 5a0d747

File tree

4 files changed

+11
-28
lines changed

4 files changed

+11
-28
lines changed

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use syntax::symbol::sym;
77
use syntax_pos::hygiene::MacroKind;
88
use syntax_pos::Span;
99

10-
use rustc::hir;
10+
use rustc::hir::{self, Mutability};
1111
use rustc::hir::def::{Res, DefKind, CtorKind};
1212
use rustc::hir::def_id::DefId;
1313
use rustc_metadata::creader::LoadedMacro;
@@ -472,7 +472,7 @@ fn build_const(cx: &DocContext<'_>, did: DefId) -> clean::Constant {
472472
fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static {
473473
clean::Static {
474474
type_: cx.tcx.type_of(did).clean(cx),
475-
mutability: if mutable {clean::Mutable} else {clean::Immutable},
475+
mutability: if mutable { Mutability::Mutable } else { Mutability::Immutable },
476476
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
477477
}
478478
}

src/librustdoc/clean/mod.rs

+6-17
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub use utils::{get_auto_trait_and_blanket_impls, krate, register_res};
4646

4747
pub use self::types::*;
4848
pub use self::types::Type::*;
49-
pub use self::types::Mutability::*;
5049
pub use self::types::ItemEnum::*;
5150
pub use self::types::SelfTy::*;
5251
pub use self::types::FunctionRetTy::*;
@@ -1321,15 +1320,14 @@ impl Clean<Type> for hir::Ty {
13211320

13221321
match self.kind {
13231322
TyKind::Never => Never,
1324-
TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
1323+
TyKind::Ptr(ref m) => RawPointer(m.mutbl, box m.ty.clean(cx)),
13251324
TyKind::Rptr(ref l, ref m) => {
13261325
let lifetime = if l.is_elided() {
13271326
None
13281327
} else {
13291328
Some(l.clean(cx))
13301329
};
1331-
BorrowedRef {lifetime, mutability: m.mutbl.clean(cx),
1332-
type_: box m.ty.clean(cx)}
1330+
BorrowedRef {lifetime, mutability: m.mutbl, type_: box m.ty.clean(cx)}
13331331
}
13341332
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
13351333
TyKind::Array(ref ty, ref length) => {
@@ -1547,10 +1545,10 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
15471545
let n = print_const(cx, n);
15481546
Array(box ty.clean(cx), n)
15491547
}
1550-
ty::RawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
1548+
ty::RawPtr(mt) => RawPointer(mt.mutbl, box mt.ty.clean(cx)),
15511549
ty::Ref(r, ty, mutbl) => BorrowedRef {
15521550
lifetime: r.clean(cx),
1553-
mutability: mutbl.clean(cx),
1551+
mutability: mutbl,
15541552
type_: box ty.clean(cx),
15551553
},
15561554
ty::FnDef(..) |
@@ -2073,7 +2071,7 @@ impl Clean<Item> for doctree::Static<'_> {
20732071
deprecation: cx.deprecation(self.id).clean(cx),
20742072
inner: StaticItem(Static {
20752073
type_: self.type_.clean(cx),
2076-
mutability: self.mutability.clean(cx),
2074+
mutability: self.mutability,
20772075
expr: print_const_expr(cx, self.expr),
20782076
}),
20792077
}
@@ -2098,15 +2096,6 @@ impl Clean<Item> for doctree::Constant<'_> {
20982096
}
20992097
}
21002098

2101-
impl Clean<Mutability> for hir::Mutability {
2102-
fn clean(&self, _: &DocContext<'_>) -> Mutability {
2103-
match self {
2104-
&hir::Mutability::Mut => Mutable,
2105-
&hir::Mutability::Not => Immutable,
2106-
}
2107-
}
2108-
}
2109-
21102099
impl Clean<ImplPolarity> for ty::ImplPolarity {
21112100
fn clean(&self, _: &DocContext<'_>) -> ImplPolarity {
21122101
match self {
@@ -2296,7 +2285,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
22962285
hir::ForeignItemKind::Static(ref ty, mutbl) => {
22972286
ForeignStaticItem(Static {
22982287
type_: ty.clean(cx),
2299-
mutability: mutbl.clean(cx),
2288+
mutability: *mutbl,
23002289
expr: String::new(),
23012290
})
23022291
}

src/librustdoc/clean/types.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::sync::Arc;
1010

1111
use rustc::middle::lang_items;
1212
use rustc::middle::stability;
13-
use rustc::hir;
13+
use rustc::hir::{self, Mutability};
1414
use rustc::hir::def::Res;
1515
use rustc::hir::def_id::{CrateNum, DefId};
1616
use rustc::ty::layout::VariantIdx;
@@ -1450,12 +1450,6 @@ pub struct Constant {
14501450
pub expr: String,
14511451
}
14521452

1453-
#[derive(Debug, Clone, PartialEq, Eq, Copy, Hash)]
1454-
pub enum Mutability {
1455-
Mutable,
1456-
Immutable,
1457-
}
1458-
14591453
#[derive(Clone, PartialEq, Debug)]
14601454
pub enum ImplPolarity {
14611455
Positive,

src/librustdoc/html/render.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ use syntax_pos::hygiene::MacroKind;
5454
use rustc::hir::def_id::DefId;
5555
use rustc::middle::privacy::AccessLevels;
5656
use rustc::middle::stability;
57-
use rustc::hir;
57+
use rustc::hir::{self, Mutability};
5858
use rustc::util::nodemap::{FxHashMap, FxHashSet};
5959
use rustc_data_structures::flock;
6060
use rustc_feature::UnstableFeatures;
6161

62-
use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability};
62+
use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy};
6363
use crate::config::RenderOptions;
6464
use crate::docfs::{DocFS, ErrorStorage, PathError};
6565
use crate::doctree;

0 commit comments

Comments
 (0)