Skip to content

Commit 6413480

Browse files
committed
libsyntax_pos => 2018
1 parent fc6e9a2 commit 6413480

File tree

7 files changed

+51
-60
lines changed

7 files changed

+51
-60
lines changed

src/libsyntax_pos/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "syntax_pos"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "syntax_pos"

src/libsyntax_pos/analyze_source_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn analyze_source_file(
3636
(lines, multi_byte_chars, non_narrow_chars)
3737
}
3838

39-
cfg_if! {
39+
cfg_if::cfg_if! {
4040
if #[cfg(all(any(target_arch = "x86", target_arch = "x86_64")))] {
4141
fn analyze_source_file_dispatch(src: &str,
4242
source_file_start_pos: BytePos,

src/libsyntax_pos/edition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const EDITION_NAME_LIST: &str = "2015|2018";
2727
pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
2828

2929
impl fmt::Display for Edition {
30-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3131
let s = match *self {
3232
Edition::Edition2015 => "2015",
3333
Edition::Edition2018 => "2018",

src/libsyntax_pos/hygiene.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
66
//! DOI=10.1017/S0956796812000093 <https://doi.org/10.1017/S0956796812000093>
77
8-
use GLOBALS;
9-
use Span;
10-
use edition::{Edition, DEFAULT_EDITION};
11-
use symbol::{keywords, Symbol};
8+
use crate::GLOBALS;
9+
use crate::Span;
10+
use crate::edition::{Edition, DEFAULT_EDITION};
11+
use crate::symbol::{keywords, Symbol};
1212

1313
use serialize::{Encodable, Decodable, Encoder, Decoder};
1414
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -525,7 +525,7 @@ impl SyntaxContext {
525525
}
526526

527527
impl fmt::Debug for SyntaxContext {
528-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
528+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
529529
write!(f, "#{}", self.0)
530530
}
531531
}

src/libsyntax_pos/lib.rs

+15-26
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,23 @@
88
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
99
html_root_url = "https://doc.rust-lang.org/nightly/")]
1010

11+
#![deny(rust_2018_idioms)]
12+
1113
#![feature(const_fn)]
1214
#![feature(crate_visibility_modifier)]
1315
#![feature(custom_attribute)]
14-
#![feature(nll)]
1516
#![feature(non_exhaustive)]
1617
#![feature(optin_builtin_traits)]
1718
#![feature(rustc_attrs)]
1819
#![feature(specialization)]
1920
#![feature(step_trait)]
2021
#![cfg_attr(not(stage0), feature(stdsimd))]
2122

22-
extern crate arena;
23-
#[macro_use]
24-
extern crate rustc_data_structures;
25-
26-
#[macro_use]
27-
extern crate scoped_tls;
28-
2923
use serialize::{Encodable, Decodable, Encoder, Decoder};
3024

31-
extern crate serialize;
25+
#[allow(unused_extern_crates)]
3226
extern crate serialize as rustc_serialize; // used by deriving
3327

34-
#[macro_use]
35-
extern crate cfg_if;
36-
37-
extern crate unicode_width;
38-
3928
pub mod edition;
4029
pub mod hygiene;
4130
pub use hygiene::{Mark, SyntaxContext, ExpnInfo, ExpnFormat, CompilerDesugaringKind};
@@ -74,7 +63,7 @@ impl Globals {
7463
}
7564
}
7665

77-
scoped_thread_local!(pub static GLOBALS: Globals);
66+
scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
7867

7968
/// Differentiates between real files and common virtual files.
8069
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)]
@@ -100,8 +89,8 @@ pub enum FileName {
10089
}
10190

10291
impl std::fmt::Display for FileName {
103-
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
104-
use self::FileName::*;
92+
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
93+
use FileName::*;
10594
match *self {
10695
Real(ref path) => write!(fmt, "{}", path.display()),
10796
Macros(ref name) => write!(fmt, "<{} macros>", name),
@@ -127,7 +116,7 @@ impl From<PathBuf> for FileName {
127116

128117
impl FileName {
129118
pub fn is_real(&self) -> bool {
130-
use self::FileName::*;
119+
use FileName::*;
131120
match *self {
132121
Real(_) => true,
133122
Macros(_) |
@@ -143,7 +132,7 @@ impl FileName {
143132
}
144133

145134
pub fn is_macros(&self) -> bool {
146-
use self::FileName::*;
135+
use FileName::*;
147136
match *self {
148137
Real(_) |
149138
Anon(_) |
@@ -611,7 +600,7 @@ impl serialize::UseSpecializedDecodable for Span {
611600
}
612601
}
613602

614-
pub fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
603+
pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
615604
f.debug_struct("Span")
616605
.field("lo", &span.lo())
617606
.field("hi", &span.hi())
@@ -620,13 +609,13 @@ pub fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result {
620609
}
621610

622611
impl fmt::Debug for Span {
623-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
612+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
624613
SPAN_DEBUG.with(|span_debug| span_debug.get()(*self, f))
625614
}
626615
}
627616

628617
impl fmt::Debug for SpanData {
629-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
618+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
630619
SPAN_DEBUG.with(|span_debug| span_debug.get()(Span::new(self.lo, self.hi, self.ctxt), f))
631620
}
632621
}
@@ -1009,7 +998,7 @@ impl Decodable for SourceFile {
1009998
// `crate_of_origin` has to be set by the importer.
1010999
// This value matches up with rustc::hir::def_id::INVALID_CRATE.
10111000
// That constant is not available here unfortunately :(
1012-
crate_of_origin: ::std::u32::MAX - 1,
1001+
crate_of_origin: std::u32::MAX - 1,
10131002
start_pos,
10141003
end_pos,
10151004
src: None,
@@ -1025,7 +1014,7 @@ impl Decodable for SourceFile {
10251014
}
10261015

10271016
impl fmt::Debug for SourceFile {
1028-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
1017+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
10291018
write!(fmt, "SourceFile({})", self.name)
10301019
}
10311020
}
@@ -1111,7 +1100,7 @@ impl SourceFile {
11111100

11121101
/// Get a line from the list of pre-computed line-beginnings.
11131102
/// The line number here is 0-based.
1114-
pub fn get_line(&self, line_number: usize) -> Option<Cow<str>> {
1103+
pub fn get_line(&self, line_number: usize) -> Option<Cow<'_, str>> {
11151104
fn get_until_newline(src: &str, begin: usize) -> &str {
11161105
// We can't use `lines.get(line_number+1)` because we might
11171106
// be parsing when we call this function and thus the current
@@ -1353,7 +1342,7 @@ pub struct FileLines {
13531342
pub lines: Vec<LineInfo>
13541343
}
13551344

1356-
thread_local!(pub static SPAN_DEBUG: Cell<fn(Span, &mut fmt::Formatter) -> fmt::Result> =
1345+
thread_local!(pub static SPAN_DEBUG: Cell<fn(Span, &mut fmt::Formatter<'_>) -> fmt::Result> =
13571346
Cell::new(default_span_debug));
13581347

13591348
#[derive(Debug)]

src/libsyntax_pos/span_encoding.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// The encoding format for inline spans were obtained by optimizing over crates in rustc/libstd.
55
// See https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28
66

7-
use GLOBALS;
8-
use {BytePos, SpanData};
9-
use hygiene::SyntaxContext;
7+
use crate::GLOBALS;
8+
use crate::{BytePos, SpanData};
9+
use crate::hygiene::SyntaxContext;
1010

1111
use rustc_data_structures::fx::FxHashMap;
1212
use std::hash::{Hash, Hasher};

src/libsyntax_pos/symbol.rs

+25-24
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
use arena::DroplessArena;
66
use rustc_data_structures::fx::FxHashMap;
77
use rustc_data_structures::indexed_vec::Idx;
8+
use rustc_data_structures::newtype_index;
89
use serialize::{Decodable, Decoder, Encodable, Encoder};
910

1011
use std::fmt;
1112
use std::str;
1213
use std::cmp::{PartialEq, Ordering, PartialOrd, Ord};
1314
use std::hash::{Hash, Hasher};
1415

15-
use hygiene::SyntaxContext;
16-
use {Span, DUMMY_SP, GLOBALS};
16+
use crate::hygiene::SyntaxContext;
17+
use crate::{Span, DUMMY_SP, GLOBALS};
1718

1819
#[derive(Copy, Clone, Eq)]
1920
pub struct Ident {
@@ -100,13 +101,13 @@ impl Hash for Ident {
100101
}
101102

102103
impl fmt::Debug for Ident {
103-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
104+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104105
write!(f, "{}{:?}", self.name, self.span.ctxt())
105106
}
106107
}
107108

108109
impl fmt::Display for Ident {
109-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
110+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110111
fmt::Display::fmt(&self.name, f)
111112
}
112113
}
@@ -181,7 +182,7 @@ impl Symbol {
181182
pub fn as_str(self) -> LocalInternedString {
182183
with_interner(|interner| unsafe {
183184
LocalInternedString {
184-
string: ::std::mem::transmute::<&str, &str>(interner.get(self))
185+
string: std::mem::transmute::<&str, &str>(interner.get(self))
185186
}
186187
})
187188
}
@@ -198,7 +199,7 @@ impl Symbol {
198199
}
199200

200201
impl fmt::Debug for Symbol {
201-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
202+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202203
let is_gensymed = with_interner(|interner| interner.is_gensymed(*self));
203204
if is_gensymed {
204205
write!(f, "{}({:?})", self, self.0)
@@ -209,7 +210,7 @@ impl fmt::Debug for Symbol {
209210
}
210211

211212
impl fmt::Display for Symbol {
212-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
213+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
213214
fmt::Display::fmt(&self.as_str(), f)
214215
}
215216
}
@@ -226,7 +227,7 @@ impl Decodable for Symbol {
226227
}
227228
}
228229

229-
impl<T: ::std::ops::Deref<Target=str>> PartialEq<T> for Symbol {
230+
impl<T: std::ops::Deref<Target=str>> PartialEq<T> for Symbol {
230231
fn eq(&self, other: &T) -> bool {
231232
self.as_str() == other.deref()
232233
}
@@ -335,7 +336,7 @@ macro_rules! declare_keywords {(
335336
};
336337
)*
337338

338-
impl ::std::str::FromStr for Keyword {
339+
impl std::str::FromStr for Keyword {
339340
type Err = ();
340341

341342
fn from_str(s: &str) -> Result<Self, ()> {
@@ -519,40 +520,40 @@ impl LocalInternedString {
519520
}
520521
}
521522

522-
impl<U: ?Sized> ::std::convert::AsRef<U> for LocalInternedString
523+
impl<U: ?Sized> std::convert::AsRef<U> for LocalInternedString
523524
where
524-
str: ::std::convert::AsRef<U>
525+
str: std::convert::AsRef<U>
525526
{
526527
fn as_ref(&self) -> &U {
527528
self.string.as_ref()
528529
}
529530
}
530531

531-
impl<T: ::std::ops::Deref<Target = str>> ::std::cmp::PartialEq<T> for LocalInternedString {
532+
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for LocalInternedString {
532533
fn eq(&self, other: &T) -> bool {
533534
self.string == other.deref()
534535
}
535536
}
536537

537-
impl ::std::cmp::PartialEq<LocalInternedString> for str {
538+
impl std::cmp::PartialEq<LocalInternedString> for str {
538539
fn eq(&self, other: &LocalInternedString) -> bool {
539540
self == other.string
540541
}
541542
}
542543

543-
impl<'a> ::std::cmp::PartialEq<LocalInternedString> for &'a str {
544+
impl<'a> std::cmp::PartialEq<LocalInternedString> for &'a str {
544545
fn eq(&self, other: &LocalInternedString) -> bool {
545546
*self == other.string
546547
}
547548
}
548549

549-
impl ::std::cmp::PartialEq<LocalInternedString> for String {
550+
impl std::cmp::PartialEq<LocalInternedString> for String {
550551
fn eq(&self, other: &LocalInternedString) -> bool {
551552
self == other.string
552553
}
553554
}
554555

555-
impl<'a> ::std::cmp::PartialEq<LocalInternedString> for &'a String {
556+
impl<'a> std::cmp::PartialEq<LocalInternedString> for &'a String {
556557
fn eq(&self, other: &LocalInternedString) -> bool {
557558
*self == other.string
558559
}
@@ -561,19 +562,19 @@ impl<'a> ::std::cmp::PartialEq<LocalInternedString> for &'a String {
561562
impl !Send for LocalInternedString {}
562563
impl !Sync for LocalInternedString {}
563564

564-
impl ::std::ops::Deref for LocalInternedString {
565+
impl std::ops::Deref for LocalInternedString {
565566
type Target = str;
566567
fn deref(&self) -> &str { self.string }
567568
}
568569

569570
impl fmt::Debug for LocalInternedString {
570-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
571+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
571572
fmt::Debug::fmt(self.string, f)
572573
}
573574
}
574575

575576
impl fmt::Display for LocalInternedString {
576-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
577+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
577578
fmt::Display::fmt(self.string, f)
578579
}
579580
}
@@ -640,7 +641,7 @@ impl Ord for InternedString {
640641
}
641642
}
642643

643-
impl<T: ::std::ops::Deref<Target = str>> PartialEq<T> for InternedString {
644+
impl<T: std::ops::Deref<Target = str>> PartialEq<T> for InternedString {
644645
fn eq(&self, other: &T) -> bool {
645646
self.with(|string| string == other.deref())
646647
}
@@ -676,20 +677,20 @@ impl<'a> PartialEq<InternedString> for &'a String {
676677
}
677678
}
678679

679-
impl ::std::convert::From<InternedString> for String {
680+
impl std::convert::From<InternedString> for String {
680681
fn from(val: InternedString) -> String {
681682
val.as_symbol().to_string()
682683
}
683684
}
684685

685686
impl fmt::Debug for InternedString {
686-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
687+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
687688
self.with(|str| fmt::Debug::fmt(&str, f))
688689
}
689690
}
690691

691692
impl fmt::Display for InternedString {
692-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
693+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
693694
self.with(|str| fmt::Display::fmt(&str, f))
694695
}
695696
}
@@ -709,7 +710,7 @@ impl Encodable for InternedString {
709710
#[cfg(test)]
710711
mod tests {
711712
use super::*;
712-
use Globals;
713+
use crate::Globals;
713714

714715
#[test]
715716
fn interner_tests() {

0 commit comments

Comments
 (0)