Skip to content

Commit

Permalink
libsyntax => 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 6, 2019
1 parent 2596bc1 commit 7bb082d
Show file tree
Hide file tree
Showing 46 changed files with 617 additions and 574 deletions.
1 change: 1 addition & 0 deletions src/libsyntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "syntax"
version = "0.0.0"
edition = "2018"

[lib]
name = "syntax"
Expand Down
62 changes: 32 additions & 30 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// The Rust abstract syntax tree.

pub use self::GenericArgs::*;
pub use self::UnsafeSource::*;
pub use symbol::{Ident, Symbol as Name};
pub use util::parser::ExprPrecedence;

use ext::hygiene::{Mark, SyntaxContext};
use print::pprust;
use ptr::P;
pub use GenericArgs::*;
pub use UnsafeSource::*;
pub use crate::symbol::{Ident, Symbol as Name};
pub use crate::util::parser::ExprPrecedence;

use crate::ext::hygiene::{Mark, SyntaxContext};
use crate::print::pprust;
use crate::ptr::P;
use crate::source_map::{dummy_spanned, respan, Spanned};
use crate::symbol::{keywords, Symbol};
use crate::tokenstream::TokenStream;
use crate::ThinVec;

use rustc_data_structures::indexed_vec::Idx;
#[cfg(target_arch = "x86_64")]
use rustc_data_structures::static_assert;
use rustc_target::spec::abi::Abi;
use source_map::{dummy_spanned, respan, Spanned};
use symbol::{keywords, Symbol};
use syntax_pos::{Span, DUMMY_SP};
use tokenstream::TokenStream;
use ThinVec;

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
Expand All @@ -31,7 +32,7 @@ pub struct Label {
}

impl fmt::Debug for Label {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "label({:?})", self.ident)
}
}
Expand All @@ -43,7 +44,7 @@ pub struct Lifetime {
}

impl fmt::Debug for Lifetime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"lifetime({}: {})",
Expand Down Expand Up @@ -74,13 +75,13 @@ impl<'a> PartialEq<&'a str> for Path {
}

impl fmt::Debug for Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "path({})", pprust::path_to_string(self))
}
}

impl fmt::Display for Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", pprust::path_to_string(self))
}
}
Expand Down Expand Up @@ -219,6 +220,7 @@ impl ParenthesizedArgs {
// hack to ensure that we don't try to access the private parts of `NodeId` in this module
mod node_id_inner {
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::newtype_index;
newtype_index! {
pub struct NodeId {
ENCODABLE = custom
Expand All @@ -227,7 +229,7 @@ mod node_id_inner {
}
}

pub use self::node_id_inner::NodeId;
pub use node_id_inner::NodeId;

impl NodeId {
pub fn placeholder_from_mark(mark: Mark) -> Self {
Expand All @@ -240,7 +242,7 @@ impl NodeId {
}

impl fmt::Display for NodeId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.as_u32(), f)
}
}
Expand Down Expand Up @@ -478,7 +480,7 @@ pub struct Pat {
}

impl fmt::Debug for Pat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "pat({}: {})", self.id, pprust::pat_to_string(self))
}
}
Expand Down Expand Up @@ -676,7 +678,7 @@ pub enum BinOpKind {

impl BinOpKind {
pub fn to_string(&self) -> &'static str {
use self::BinOpKind::*;
use BinOpKind::*;
match *self {
Add => "+",
Sub => "-",
Expand Down Expand Up @@ -713,7 +715,7 @@ impl BinOpKind {
}

pub fn is_comparison(&self) -> bool {
use self::BinOpKind::*;
use BinOpKind::*;
match *self {
Eq | Lt | Le | Ne | Gt | Ge => true,
And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false,
Expand Down Expand Up @@ -792,7 +794,7 @@ impl Stmt {
}

impl fmt::Debug for Stmt {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"stmt({}: {})",
Expand Down Expand Up @@ -1030,7 +1032,7 @@ impl Expr {
}

impl fmt::Debug for Expr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self))
}
}
Expand Down Expand Up @@ -1438,13 +1440,13 @@ pub enum IntTy {
}

impl fmt::Debug for IntTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}

impl fmt::Display for IntTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.ty_to_string())
}
}
Expand Down Expand Up @@ -1519,13 +1521,13 @@ impl UintTy {
}

impl fmt::Debug for UintTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}

impl fmt::Display for UintTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.ty_to_string())
}
}
Expand All @@ -1547,7 +1549,7 @@ pub struct Ty {
}

impl fmt::Debug for Ty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "type({})", pprust::ty_to_string(self))
}
}
Expand Down Expand Up @@ -1832,7 +1834,7 @@ pub enum Defaultness {
}

impl fmt::Display for Unsafety {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(
match *self {
Unsafety::Normal => "normal",
Expand All @@ -1852,7 +1854,7 @@ pub enum ImplPolarity {
}

impl fmt::Debug for ImplPolarity {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ImplPolarity::Positive => "positive".fmt(f),
ImplPolarity::Negative => "negative".fmt(f),
Expand Down
17 changes: 9 additions & 8 deletions src/libsyntax/attr/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Parsing and validation of builtin attributes

use ast::{self, Attribute, MetaItem, Name, NestedMetaItemKind};
use errors::{Applicability, Handler};
use feature_gate::{Features, GatedCfg};
use parse::ParseSess;
use crate::ast::{self, Attribute, MetaItem, Name, NestedMetaItemKind};
use crate::errors::{Applicability, Handler};
use crate::feature_gate::{Features, GatedCfg};
use crate::parse::ParseSess;

use syntax_pos::{symbol::Symbol, Span};

use super::{list_contains_name, mark_used, MetaItemKind};
Expand Down Expand Up @@ -188,7 +189,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
-> Option<Stability>
where I: Iterator<Item = &'a Attribute>
{
use self::StabilityLevel::*;
use StabilityLevel::*;

let mut stab: Option<Stability> = None;
let mut rustc_depr: Option<RustcDeprecation> = None;
Expand Down Expand Up @@ -694,7 +695,7 @@ pub enum IntType {
impl IntType {
#[inline]
pub fn is_signed(self) -> bool {
use self::IntType::*;
use IntType::*;

match self {
SignedInt(..) => true,
Expand All @@ -711,7 +712,7 @@ impl IntType {
/// structure layout, `packed` to remove padding, and `transparent` to elegate representation
/// concerns to the only non-ZST field.
pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
use self::ReprAttr::*;
use ReprAttr::*;

let mut acc = Vec::new();
let diagnostic = &sess.span_diagnostic;
Expand Down Expand Up @@ -831,7 +832,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
}

fn int_type_of_word(s: &str) -> Option<IntType> {
use self::IntType::*;
use IntType::*;

match s {
"i8" => Some(SignedInt(ast::IntTy::I8)),
Expand Down
42 changes: 22 additions & 20 deletions src/libsyntax/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@

mod builtin;

pub use self::builtin::{
pub use builtin::{
cfg_matches, contains_feature_attr, eval_condition, find_crate_name, find_deprecation,
find_repr_attrs, find_stability, find_unwind_attr, Deprecation, InlineAttr, OptimizeAttr,
IntType, ReprAttr, RustcDeprecation, Stability, StabilityLevel, UnwindAttr,
};
pub use self::IntType::*;
pub use self::ReprAttr::*;
pub use self::StabilityLevel::*;

use ast;
use ast::{AttrId, Attribute, AttrStyle, Name, Ident, Path, PathSegment};
use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind, GenericParam};
use mut_visit::visit_clobber;
use source_map::{BytePos, Spanned, respan, dummy_spanned};
pub use IntType::*;
pub use ReprAttr::*;
pub use StabilityLevel::*;

use crate::ast;
use crate::ast::{AttrId, Attribute, AttrStyle, Name, Ident, Path, PathSegment};
use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
use crate::ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind, GenericParam};
use crate::mut_visit::visit_clobber;
use crate::source_map::{BytePos, Spanned, respan, dummy_spanned};
use crate::parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
use crate::parse::parser::Parser;
use crate::parse::{self, ParseSess, PResult};
use crate::parse::token::{self, Token};
use crate::ptr::P;
use crate::symbol::Symbol;
use crate::ThinVec;
use crate::tokenstream::{TokenStream, TokenTree, DelimSpan};
use crate::GLOBALS;

use log::debug;
use syntax_pos::{FileName, Span};
use parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
use parse::parser::Parser;
use parse::{self, ParseSess, PResult};
use parse::token::{self, Token};
use ptr::P;
use symbol::Symbol;
use ThinVec;
use tokenstream::{TokenStream, TokenTree, DelimSpan};
use GLOBALS;

use std::iter;
use std::ops::DerefMut;
Expand Down
21 changes: 11 additions & 10 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use attr::HasAttrs;
use feature_gate::{
use crate::attr::HasAttrs;
use crate::feature_gate::{
feature_err,
EXPLAIN_STMT_ATTR_SYNTAX,
Features,
get_features,
GateIssue,
};
use attr;
use ast;
use edition::Edition;
use errors::Applicability;
use mut_visit::*;
use parse::{token, ParseSess};
use ptr::P;
use crate::attr;
use crate::ast;
use crate::edition::Edition;
use crate::errors::Applicability;
use crate::mut_visit::*;
use crate::parse::{token, ParseSess};
use crate::ptr::P;
use crate::util::map_in_place::MapInPlace;

use smallvec::SmallVec;
use util::map_in_place::MapInPlace;

/// A folder that strips out items that do not belong in the current configuration.
pub struct StripUnconfigured<'a> {
Expand Down
9 changes: 5 additions & 4 deletions src/libsyntax/diagnostics/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use std::error::Error;
use rustc_serialize::json::as_json;

use syntax_pos::{Span, FileName};
use ext::base::ExtCtxt;
use diagnostics::plugin::{ErrorMap, ErrorInfo};

use crate::ext::base::ExtCtxt;
use crate::diagnostics::plugin::{ErrorMap, ErrorInfo};

/// JSON encodable/decodable version of `ErrorInfo`.
#[derive(PartialEq, RustcDecodable, RustcEncodable)]
Expand All @@ -34,7 +35,7 @@ pub struct ErrorLocation {

impl ErrorLocation {
/// Create an error location from a span.
pub fn from_span(ecx: &ExtCtxt, sp: Span) -> ErrorLocation {
pub fn from_span(ecx: &ExtCtxt<'_>, sp: Span) -> ErrorLocation {
let loc = ecx.source_map().lookup_char_pos_adj(sp.lo());
ErrorLocation {
filename: loc.filename,
Expand Down Expand Up @@ -62,7 +63,7 @@ fn get_metadata_path(directory: PathBuf, name: &str) -> PathBuf {
///
/// For our current purposes the prefix is the target architecture and the name is a crate name.
/// If an error occurs steps will be taken to ensure that no file is created.
pub fn output_metadata(ecx: &ExtCtxt, prefix: &str, name: &str, err_map: &ErrorMap)
pub fn output_metadata(ecx: &ExtCtxt<'_>, prefix: &str, name: &str, err_map: &ErrorMap)
-> Result<(), Box<dyn Error>>
{
// Create the directory to place the file in.
Expand Down
Loading

0 comments on commit 7bb082d

Please sign in to comment.