From 4d1a30c92b50c5965ed26449758fca81bee15747 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 21 Mar 2018 01:58:25 +0300 Subject: Remove most of `PartialEq` impls from AST and HIR structures --- src/libsyntax_ext/deriving/generic/mod.rs | 8 ++------ src/libsyntax_ext/deriving/generic/ty.rs | 9 ++++----- src/libsyntax_ext/format_foreign.rs | 8 ++++---- src/libsyntax_ext/proc_macro_registrar.rs | 11 ++++++----- 4 files changed, 16 insertions(+), 20 deletions(-) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index aad69c109f9..a9f60fd053c 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -188,7 +188,6 @@ pub use self::StaticFields::*; pub use self::SubstructureFields::*; use std::cell::RefCell; -use std::collections::HashSet; use std::vec; use rustc_target::spec::abi::Abi; @@ -617,7 +616,6 @@ impl<'a> TraitDef<'a> { .map(|ty_param| ty_param.ident.name) .collect(); - let mut processed_field_types = HashSet::new(); for field_ty in field_tys { let tys = find_type_parameters(&field_ty, &ty_param_names, self.span, cx); @@ -625,11 +623,9 @@ impl<'a> TraitDef<'a> { // if we have already handled this type, skip it if let ast::TyKind::Path(_, ref p) = ty.node { if p.segments.len() == 1 && - ty_param_names.contains(&p.segments[0].ident.name) || - processed_field_types.contains(&p.segments) { + ty_param_names.contains(&p.segments[0].ident.name) { continue; }; - processed_field_types.insert(p.segments.clone()); } let mut bounds: Vec<_> = self.additional_bounds .iter() @@ -913,7 +909,7 @@ impl<'a> MethodDef<'a> { Self_ if nonstatic => { self_args.push(arg_expr); } - Ptr(ref ty, _) if **ty == Self_ && nonstatic => { + Ptr(ref ty, _) if (if let Self_ = **ty { true } else { false }) && nonstatic => { self_args.push(cx.expr_deref(trait_.span, arg_expr)) } _ => { diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 0b809ab585c..dcccb187bef 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -24,8 +24,7 @@ use syntax_pos::Span; use syntax_pos::symbol::keywords; /// The types of pointers -#[derive(Clone, Eq, PartialEq)] -#[allow(dead_code)] +#[derive(Clone)] pub enum PtrTy<'a> { /// &'lifetime mut Borrowed(Option<&'a str>, ast::Mutability), @@ -35,7 +34,7 @@ pub enum PtrTy<'a> { /// A path, e.g. `::std::option::Option::` (global). Has support /// for type parameters and a lifetime. -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub struct Path<'a> { path: Vec<&'a str>, lifetime: Option<&'a str>, @@ -43,7 +42,7 @@ pub struct Path<'a> { kind: PathKind, } -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub enum PathKind { Local, Global, @@ -107,7 +106,7 @@ impl<'a> Path<'a> { } /// A type. Supports pointers, Self, and literals -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone)] pub enum Ty<'a> { Self_, /// &/Box/ Ty diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 2393af76c34..1cf21b5c3ae 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -12,7 +12,7 @@ pub mod printf { use super::strcursor::StrCursor as Cur; /// Represents a single `printf`-style substitution. - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, Debug)] pub enum Substitution<'a> { /// A formatted output substitution. Format(Format<'a>), @@ -40,7 +40,7 @@ pub mod printf { } } - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, Debug)] /// A single `printf`-style formatting directive. pub struct Format<'a> { /// The entire original formatting directive. @@ -213,7 +213,7 @@ pub mod printf { } /// A general number used in a `printf` formatting directive. - #[derive(Copy, Clone, Eq, PartialEq, Debug)] + #[derive(Copy, Clone, Debug)] pub enum Num { // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it @@ -739,7 +739,7 @@ pub mod printf { pub mod shell { use super::strcursor::StrCursor as Cur; - #[derive(Clone, Eq, PartialEq, Debug)] + #[derive(Clone, Debug)] pub enum Substitution<'a> { Ordinal(u8), Name(&'a str), diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index ab2bb446631..5cbd9782575 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -103,7 +103,7 @@ 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 == ast::VisibilityKind::Public { + vis.node.is_public() { self.handler.span_err(sp, "`proc-macro` crate types cannot \ export any items other than functions \ @@ -181,7 +181,7 @@ impl<'a> CollectProcMacros<'a> { Vec::new() }; - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_public() { self.derives.push(ProcMacroDerive { span: item.span, trait_name, @@ -206,7 +206,7 @@ impl<'a> CollectProcMacros<'a> { return; } - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_public() { self.attr_macros.push(ProcMacroDef { span: item.span, function_name: item.ident, @@ -229,7 +229,7 @@ impl<'a> CollectProcMacros<'a> { return; } - if self.in_root && item.vis.node == ast::VisibilityKind::Public { + if self.in_root && item.vis.node.is_public() { self.bang_macros.push(ProcMacroDef { span: item.span, function_name: item.ident, @@ -271,7 +271,8 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { for attr in &item.attrs { if is_proc_macro_attr(&attr) { if let Some(prev_attr) = found_attr { - let msg = if attr.path == prev_attr.path { + let msg = if attr.path.segments[0].ident.name == + prev_attr.path.segments[0].ident.name { format!("Only one `#[{}]` attribute is allowed on any given function", attr.path) } else { -- cgit 1.4.1-3-g733a5 From e3acb341b2ff743e186c032326d24bfa8827bedc Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 27 Jun 2018 01:59:07 +0300 Subject: Remove some tests using AST comparisons, fix other tests --- src/libsyntax/parse/lexer/mod.rs | 6 +- src/libsyntax/parse/mod.rs | 230 ++++-------------------------- src/libsyntax/util/parser_testing.rs | 8 -- src/libsyntax_ext/format_foreign.rs | 8 +- src/test/run-pass-fulldeps/issue-35829.rs | 59 -------- 5 files changed, 34 insertions(+), 277 deletions(-) delete mode 100644 src/test/run-pass-fulldeps/issue-35829.rs (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 92fcf865042..bf790e6143a 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1842,7 +1842,8 @@ mod tests { tok: token::Ident(id, false), sp: Span::new(BytePos(21), BytePos(23), NO_EXPANSION), }; - assert_eq!(tok1, tok2); + assert_eq!(tok1.tok, tok2.tok); + assert_eq!(tok1.sp, tok2.sp); assert_eq!(string_reader.next_token().tok, token::Whitespace); // the 'main' id is already read: assert_eq!(string_reader.pos.clone(), BytePos(28)); @@ -1852,7 +1853,8 @@ mod tests { tok: mk_ident("main"), sp: Span::new(BytePos(24), BytePos(28), NO_EXPANSION), }; - assert_eq!(tok3, tok4); + assert_eq!(tok3.tok, tok4.tok); + assert_eq!(tok3.sp, tok4.sp); // the lparen is already read: assert_eq!(string_reader.pos.clone(), BytePos(29)) }) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index c443f240780..1754e5f1b9a 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -673,22 +673,40 @@ fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler)>) }) } +/// `SeqSep` : a sequence separator (token) +/// and whether a trailing separator is allowed. +pub struct SeqSep { + pub sep: Option, + pub trailing_sep_allowed: bool, +} + +impl SeqSep { + pub fn trailing_allowed(t: token::Token) -> SeqSep { + SeqSep { + sep: Some(t), + trailing_sep_allowed: true, + } + } + + pub fn none() -> SeqSep { + SeqSep { + sep: None, + trailing_sep_allowed: false, + } + } +} + #[cfg(test)] mod tests { use super::*; - use syntax_pos::{self, Span, BytePos, Pos, NO_EXPANSION}; - use codemap::{respan, Spanned}; + use syntax_pos::{Span, BytePos, Pos, NO_EXPANSION}; use ast::{self, Ident, PatKind}; - use rustc_target::spec::abi::Abi; use attr::first_attr_value_str_by_name; use parse; - use parse::parser::Parser; use print::pprust::item_to_string; - use ptr::P; use tokenstream::{self, TokenTree}; - use util::parser_testing::{string_to_stream, string_to_parser}; - use util::parser_testing::{string_to_expr, string_to_item, string_to_stmt}; - use util::ThinVec; + use util::parser_testing::string_to_stream; + use util::parser_testing::{string_to_expr, string_to_item}; use with_globals; // produce a syntax_pos::span @@ -696,42 +714,6 @@ mod tests { Span::new(BytePos(a), BytePos(b), NO_EXPANSION) } - fn str2seg(s: &str, lo: u32, hi: u32) -> ast::PathSegment { - ast::PathSegment::from_ident(Ident::new(Symbol::intern(s), sp(lo, hi))) - } - - #[test] fn path_exprs_1() { - with_globals(|| { - assert!(string_to_expr("a".to_string()) == - P(ast::Expr{ - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, ast::Path { - span: sp(0, 1), - segments: vec![str2seg("a", 0, 1)], - }), - span: sp(0, 1), - attrs: ThinVec::new(), - })) - }) - } - - #[test] fn path_exprs_2 () { - with_globals(|| { - assert!(string_to_expr("::a::b".to_string()) == - P(ast::Expr { - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, ast::Path { - span: sp(0, 6), - segments: vec![ast::PathSegment::crate_root(sp(0, 0)), - str2seg("a", 2, 3), - str2seg("b", 5, 6)] - }), - span: sp(0, 6), - attrs: ThinVec::new(), - })) - }) - } - #[should_panic] #[test] fn bad_path_expr_1() { with_globals(|| { @@ -832,143 +814,6 @@ mod tests { }) } - #[test] fn ret_expr() { - with_globals(|| { - assert!(string_to_expr("return d".to_string()) == - P(ast::Expr{ - id: ast::DUMMY_NODE_ID, - node:ast::ExprKind::Ret(Some(P(ast::Expr{ - id: ast::DUMMY_NODE_ID, - node:ast::ExprKind::Path(None, ast::Path{ - span: sp(7, 8), - segments: vec![str2seg("d", 7, 8)], - }), - span:sp(7,8), - attrs: ThinVec::new(), - }))), - span:sp(0,8), - attrs: ThinVec::new(), - })) - }) - } - - #[test] fn parse_stmt_1 () { - with_globals(|| { - assert!(string_to_stmt("b;".to_string()) == - Some(ast::Stmt { - node: ast::StmtKind::Expr(P(ast::Expr { - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, ast::Path { - span:sp(0,1), - segments: vec![str2seg("b", 0, 1)], - }), - span: sp(0,1), - attrs: ThinVec::new()})), - id: ast::DUMMY_NODE_ID, - span: sp(0,1)})) - }) - } - - fn parser_done(p: Parser){ - assert_eq!(p.token.clone(), token::Eof); - } - - #[test] fn parse_ident_pat () { - with_globals(|| { - let sess = ParseSess::new(FilePathMapping::empty()); - let mut parser = string_to_parser(&sess, "b".to_string()); - assert!(panictry!(parser.parse_pat()) - == P(ast::Pat{ - id: ast::DUMMY_NODE_ID, - node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable), - Ident::new(Symbol::intern("b"), sp(0, 1)), - None), - span: sp(0,1)})); - parser_done(parser); - }) - } - - // check the contents of the tt manually: - #[test] fn parse_fundecl () { - with_globals(|| { - // this test depends on the intern order of "fn" and "i32" - let item = string_to_item("fn a (b : i32) { b; }".to_string()).map(|m| { - m.map(|mut m| { - m.tokens = None; - m - }) - }); - assert_eq!(item, - Some( - P(ast::Item{ident:Ident::from_str("a"), - attrs:Vec::new(), - id: ast::DUMMY_NODE_ID, - tokens: None, - node: ast::ItemKind::Fn(P(ast::FnDecl { - inputs: vec![ast::Arg{ - ty: P(ast::Ty{id: ast::DUMMY_NODE_ID, - node: ast::TyKind::Path(None, ast::Path{ - span:sp(10,13), - segments: vec![str2seg("i32", 10, 13)], - }), - span:sp(10,13) - }), - pat: P(ast::Pat { - id: ast::DUMMY_NODE_ID, - node: PatKind::Ident( - ast::BindingMode::ByValue( - ast::Mutability::Immutable), - Ident::new(Symbol::intern("b"), sp(6, 7)), - None - ), - span: sp(6,7) - }), - id: ast::DUMMY_NODE_ID - }], - output: ast::FunctionRetTy::Default(sp(15, 15)), - variadic: false - }), - ast::FnHeader { - unsafety: ast::Unsafety::Normal, - asyncness: ast::IsAsync::NotAsync, - constness: Spanned { - span: sp(0,2), - node: ast::Constness::NotConst, - }, - abi: Abi::Rust, - }, - ast::Generics{ - params: Vec::new(), - where_clause: ast::WhereClause { - id: ast::DUMMY_NODE_ID, - predicates: Vec::new(), - span: syntax_pos::DUMMY_SP, - }, - span: syntax_pos::DUMMY_SP, - }, - P(ast::Block { - stmts: vec![ast::Stmt { - node: ast::StmtKind::Semi(P(ast::Expr{ - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Path(None, - ast::Path{ - span:sp(17,18), - segments: vec![str2seg("b", 17, 18)], - }), - span: sp(17,18), - attrs: ThinVec::new()})), - id: ast::DUMMY_NODE_ID, - span: sp(17,19)}], - id: ast::DUMMY_NODE_ID, - rules: ast::BlockCheckMode::Default, // no idea - span: sp(15,21), - recovered: false, - })), - vis: respan(sp(0, 0), ast::VisibilityKind::Inherited), - span: sp(0,21)}))); - }) - } - #[test] fn parse_use() { with_globals(|| { let use_s = "use foo::bar::baz;"; @@ -1133,26 +978,3 @@ mod tests { }); } } - -/// `SeqSep` : a sequence separator (token) -/// and whether a trailing separator is allowed. -pub struct SeqSep { - pub sep: Option, - pub trailing_sep_allowed: bool, -} - -impl SeqSep { - pub fn trailing_allowed(t: token::Token) -> SeqSep { - SeqSep { - sep: Some(t), - trailing_sep_allowed: true, - } - } - - pub fn none() -> SeqSep { - SeqSep { - sep: None, - trailing_sep_allowed: false, - } - } -} diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 42cd7c8faa5..46b7f2d7bda 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -63,14 +63,6 @@ pub fn string_to_item (source_str : String) -> Option> { }) } -/// Parse a string, return a stmt -pub fn string_to_stmt(source_str : String) -> Option { - let ps = ParseSess::new(FilePathMapping::empty()); - with_error_checking_parse(source_str, &ps, |p| { - p.parse_stmt() - }) -} - /// Parse a string, return a pat. Uses "irrefutable"... which doesn't /// (currently) affect parsing. pub fn string_to_pat(source_str: String) -> P { diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 1cf21b5c3ae..ff9663cdd3c 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -12,7 +12,7 @@ pub mod printf { use super::strcursor::StrCursor as Cur; /// Represents a single `printf`-style substitution. - #[derive(Clone, Debug)] + #[derive(Clone, PartialEq, Debug)] pub enum Substitution<'a> { /// A formatted output substitution. Format(Format<'a>), @@ -40,7 +40,7 @@ pub mod printf { } } - #[derive(Clone, Debug)] + #[derive(Clone, PartialEq, Debug)] /// A single `printf`-style formatting directive. pub struct Format<'a> { /// The entire original formatting directive. @@ -213,7 +213,7 @@ pub mod printf { } /// A general number used in a `printf` formatting directive. - #[derive(Copy, Clone, Debug)] + #[derive(Copy, Clone, PartialEq, Debug)] pub enum Num { // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it @@ -739,7 +739,7 @@ pub mod printf { pub mod shell { use super::strcursor::StrCursor as Cur; - #[derive(Clone, Debug)] + #[derive(Clone, PartialEq, Debug)] pub enum Substitution<'a> { Ordinal(u8), Name(&'a str), diff --git a/src/test/run-pass-fulldeps/issue-35829.rs b/src/test/run-pass-fulldeps/issue-35829.rs deleted file mode 100644 index 798c214bc47..00000000000 --- a/src/test/run-pass-fulldeps/issue-35829.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-cross-compile -#![feature(quote, rustc_private)] - -extern crate syntax; -extern crate rustc_data_structures; - -use syntax::ext::base::{ExtCtxt, DummyResolver}; -use syntax::ext::expand::ExpansionConfig; -use syntax::parse::ParseSess; -use syntax::codemap::{FilePathMapping, dummy_spanned}; -use syntax::print::pprust::expr_to_string; -use syntax::ast::{ExprKind, LitKind, RangeLimits}; -use syntax::ptr::P; - -use rustc_data_structures::sync::Lrc; - -fn main() { - syntax::with_globals(|| run()); -} - -fn run() { - let parse_sess = ParseSess::new(FilePathMapping::empty()); - let exp_cfg = ExpansionConfig::default("issue_35829".to_owned()); - let mut resolver = DummyResolver; - let cx = ExtCtxt::new(&parse_sess, exp_cfg, &mut resolver); - - // check byte string - let byte_string = quote_expr!(&cx, b"one"); - let byte_string_lit_kind = LitKind::ByteStr(Lrc::new(b"one".to_vec())); - assert_eq!(byte_string.node, ExprKind::Lit(P(dummy_spanned(byte_string_lit_kind)))); - - // check raw byte string - let raw_byte_string = quote_expr!(&cx, br###"#"two"#"###); - let raw_byte_string_lit_kind = LitKind::ByteStr(Lrc::new(b"#\"two\"#".to_vec())); - assert_eq!(raw_byte_string.node, ExprKind::Lit(P(dummy_spanned(raw_byte_string_lit_kind)))); - - // check dotdoteq - let closed_range = quote_expr!(&cx, 0 ..= 1); - assert_eq!(closed_range.node, ExprKind::Range( - Some(quote_expr!(&cx, 0)), - Some(quote_expr!(&cx, 1)), - RangeLimits::Closed - )); - - // test case from 35829 - let expr_35829 = quote_expr!(&cx, std::io::stdout().write(b"one")); - assert_eq!(expr_to_string(&expr_35829), r#"std::io::stdout().write(b"one")"#); -} -- cgit 1.4.1-3-g733a5 From 7d142c1e53165fea78314117f59e13257d7bf85d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 6 Jul 2018 23:18:38 +0300 Subject: Address comments --- src/librustc/hir/mod.rs | 2 +- src/librustc_passes/ast_validation.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 6 +++--- src/librustdoc/clean/mod.rs | 4 +--- src/libsyntax/ast.rs | 5 +++-- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/test.rs | 2 +- src/libsyntax_ext/proc_macro_registrar.rs | 10 ++++------ 8 files changed, 15 insertions(+), 18 deletions(-) (limited to 'src/libsyntax_ext') diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 09fc824750d..5984f8ce5b1 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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 } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 4a9d3e6a114..f27ca444672 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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 { diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index e0de60556a2..34dcdfb757f 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -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())) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index de9c8370cdb..030b36c2212 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1855,7 +1855,7 @@ impl<'tcx> Clean 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, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a7ce4404fb8..209e0b6d787 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8bd4a7d71d7..62bb5fbd04f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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) { diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index b4e1dd75b3b..d8b8d13a38c 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -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 }; diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs index 5cbd9782575..2522fa769c5 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -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, -- cgit 1.4.1-3-g733a5