Address comments

This commit is contained in:
Vadim Petrochenkov 2018-07-06 23:18:38 +03:00
parent e3acb341b2
commit 7d142c1e53
8 changed files with 15 additions and 18 deletions

View file

@ -568,7 +568,7 @@ impl Generics {
/// Synthetic Type Parameters are converted to an other form during lowering, this allows /// Synthetic Type Parameters are converted to an other form during lowering, this allows
/// to track the original form they had. Useful for error messages. /// to track the original form they had. Useful for error messages.
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum SyntheticTyParamKind { pub enum SyntheticTyParamKind {
ImplTrait ImplTrait
} }

View file

@ -68,7 +68,7 @@ impl<'a> AstValidator<'a> {
vis.span, vis.span,
E0449, E0449,
"unnecessary visibility qualifier"); "unnecessary visibility qualifier");
if vis.node.is_public() { if vis.node.is_pub() {
err.span_label(vis.span, "`pub` not permitted here because it's implied"); err.span_label(vis.span, "`pub` not permitted here because it's implied");
} }
if let Some(note) = note { if let Some(note) = note {

View file

@ -65,14 +65,14 @@ macro_rules! down_cast_data {
macro_rules! access_from { macro_rules! access_from {
($save_ctxt:expr, $vis:expr, $id:expr) => { ($save_ctxt:expr, $vis:expr, $id:expr) => {
Access { Access {
public: $vis.node.is_public(), public: $vis.node.is_pub(),
reachable: $save_ctxt.analysis.access_levels.is_reachable($id), reachable: $save_ctxt.analysis.access_levels.is_reachable($id),
} }
}; };
($save_ctxt:expr, $item:expr) => { ($save_ctxt:expr, $item:expr) => {
Access { Access {
public: $item.vis.node.is_public(), public: $item.vis.node.is_pub(),
reachable: $save_ctxt.analysis.access_levels.is_reachable($item.id), reachable: $save_ctxt.analysis.access_levels.is_reachable($item.id),
} }
}; };
@ -523,7 +523,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
.iter() .iter()
.enumerate() .enumerate()
.filter_map(|(i, f)| { .filter_map(|(i, f)| {
if include_priv_fields || f.vis.node.is_public() { if include_priv_fields || f.vis.node.is_pub() {
f.ident f.ident
.map(|i| i.to_string()) .map(|i| i.to_string())
.or_else(|| Some(i.to_string())) .or_else(|| Some(i.to_string()))

View file

@ -1855,7 +1855,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
} }
} }
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug, Hash)] #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub enum GenericParamDefKind { pub enum GenericParamDefKind {
Lifetime, Lifetime,
Type { Type {
@ -1866,8 +1866,6 @@ pub enum GenericParamDefKind {
}, },
} }
impl Eq for GenericParamDefKind {}
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub struct GenericParamDef { pub struct GenericParamDef {
pub name: String, pub name: String,

View file

@ -1581,7 +1581,8 @@ impl TyKind {
pub fn is_implicit_self(&self) -> bool { pub fn is_implicit_self(&self) -> bool {
if let TyKind::ImplicitSelf = *self { true } else { false } if let TyKind::ImplicitSelf = *self { true } else { false }
} }
pub(crate) fn is_empty_tuple(&self) -> bool {
crate fn is_unit(&self) -> bool {
if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false } if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false }
} }
} }
@ -1982,7 +1983,7 @@ pub enum VisibilityKind {
} }
impl VisibilityKind { impl VisibilityKind {
pub fn is_public(&self) -> bool { pub fn is_pub(&self) -> bool {
if let VisibilityKind::Public = *self { true } else { false } if let VisibilityKind::Public = *self { true } else { false }
} }
} }

View file

@ -6999,7 +6999,7 @@ impl<'a> Parser<'a> {
// Verify whether we have encountered a struct or method definition where the user forgot to // Verify whether we have encountered a struct or method definition where the user forgot to
// add the `struct` or `fn` keyword after writing `pub`: `pub S {}` // add the `struct` or `fn` keyword after writing `pub`: `pub S {}`
if visibility.node.is_public() && if visibility.node.is_pub() &&
self.check_ident() && self.check_ident() &&
self.look_ahead(1, |t| *t != token::Not) self.look_ahead(1, |t| *t != token::Not)
{ {

View file

@ -353,7 +353,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
// type implements the `Termination` trait as `libtest` enforces that. // type implements the `Termination` trait as `libtest` enforces that.
let has_output = match decl.output { let has_output = match decl.output {
ast::FunctionRetTy::Default(..) => false, ast::FunctionRetTy::Default(..) => false,
ast::FunctionRetTy::Ty(ref t) if t.node.is_empty_tuple() => false, ast::FunctionRetTy::Ty(ref t) if t.node.is_unit() => false,
_ => true _ => true
}; };

View file

@ -101,9 +101,7 @@ fn is_proc_macro_attr(attr: &ast::Attribute) -> bool {
impl<'a> CollectProcMacros<'a> { impl<'a> CollectProcMacros<'a> {
fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) { fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) {
if self.is_proc_macro_crate && if self.is_proc_macro_crate && self.in_root && vis.node.is_pub() {
self.in_root &&
vis.node.is_public() {
self.handler.span_err(sp, self.handler.span_err(sp,
"`proc-macro` crate types cannot \ "`proc-macro` crate types cannot \
export any items other than functions \ export any items other than functions \
@ -181,7 +179,7 @@ impl<'a> CollectProcMacros<'a> {
Vec::new() Vec::new()
}; };
if self.in_root && item.vis.node.is_public() { if self.in_root && item.vis.node.is_pub() {
self.derives.push(ProcMacroDerive { self.derives.push(ProcMacroDerive {
span: item.span, span: item.span,
trait_name, trait_name,
@ -206,7 +204,7 @@ impl<'a> CollectProcMacros<'a> {
return; return;
} }
if self.in_root && item.vis.node.is_public() { if self.in_root && item.vis.node.is_pub() {
self.attr_macros.push(ProcMacroDef { self.attr_macros.push(ProcMacroDef {
span: item.span, span: item.span,
function_name: item.ident, function_name: item.ident,
@ -229,7 +227,7 @@ impl<'a> CollectProcMacros<'a> {
return; return;
} }
if self.in_root && item.vis.node.is_public() { if self.in_root && item.vis.node.is_pub() {
self.bang_macros.push(ProcMacroDef { self.bang_macros.push(ProcMacroDef {
span: item.span, span: item.span,
function_name: item.ident, function_name: item.ident,