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
/// 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 {
ImplTrait
}

View File

@ -68,7 +68,7 @@ impl<'a> AstValidator<'a> {
vis.span,
E0449,
"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");
}
if let Some(note) = note {

View File

@ -65,14 +65,14 @@ macro_rules! down_cast_data {
macro_rules! access_from {
($save_ctxt:expr, $vis:expr, $id:expr) => {
Access {
public: $vis.node.is_public(),
public: $vis.node.is_pub(),
reachable: $save_ctxt.analysis.access_levels.is_reachable($id),
}
};
($save_ctxt:expr, $item:expr) => {
Access {
public: $item.vis.node.is_public(),
public: $item.vis.node.is_pub(),
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()
.enumerate()
.filter_map(|(i, f)| {
if include_priv_fields || f.vis.node.is_public() {
if include_priv_fields || f.vis.node.is_pub() {
f.ident
.map(|i| 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 {
Lifetime,
Type {
@ -1866,8 +1866,6 @@ pub enum GenericParamDefKind {
},
}
impl Eq for GenericParamDefKind {}
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
pub struct GenericParamDef {
pub name: String,

View File

@ -1581,7 +1581,8 @@ impl TyKind {
pub fn is_implicit_self(&self) -> bool {
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 }
}
}
@ -1982,7 +1983,7 @@ pub enum VisibilityKind {
}
impl VisibilityKind {
pub fn is_public(&self) -> bool {
pub fn is_pub(&self) -> bool {
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
// 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.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.
let has_output = match decl.output {
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
};

View File

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