Skip to content

Commit 950fe66

Browse files
committed
librustc_errors => 2018
1 parent b139669 commit 950fe66

File tree

7 files changed

+37
-45
lines changed

7 files changed

+37
-45
lines changed

src/librustc_errors/Cargo.toml

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

67
[lib]
78
name = "rustc_errors"

src/librustc_errors/diagnostic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use CodeSuggestion;
2-
use SubstitutionPart;
3-
use Substitution;
4-
use Applicability;
5-
use Level;
1+
use crate::CodeSuggestion;
2+
use crate::SubstitutionPart;
3+
use crate::Substitution;
4+
use crate::Applicability;
5+
use crate::Level;
6+
use crate::snippet::Style;
67
use std::fmt;
78
use syntax_pos::{MultiSpan, Span};
8-
use snippet::Style;
99

1010
#[must_use]
1111
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]

src/librustc_errors/diagnostic_builder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
use Diagnostic;
2-
use DiagnosticId;
3-
use DiagnosticStyledString;
4-
use Applicability;
1+
use crate::Diagnostic;
2+
use crate::DiagnosticId;
3+
use crate::DiagnosticStyledString;
4+
use crate::Applicability;
55

6-
use Level;
7-
use Handler;
6+
use crate::Level;
7+
use crate::Handler;
88
use std::fmt::{self, Debug};
99
use std::ops::{Deref, DerefMut};
1010
use std::thread::panicking;
1111
use syntax_pos::{MultiSpan, Span};
12+
use log::debug;
1213

1314
/// Used for emitting structured error messages and other diagnostic information.
1415
///
@@ -111,8 +112,8 @@ impl<'a> DiagnosticBuilder<'a> {
111112
// implements `Drop`.
112113
let diagnostic;
113114
unsafe {
114-
diagnostic = ::std::ptr::read(&self.diagnostic);
115-
::std::mem::forget(self);
115+
diagnostic = std::ptr::read(&self.diagnostic);
116+
std::mem::forget(self);
116117
};
117118
// Logging here is useful to help track down where in logs an error was
118119
// actually emitted.
@@ -298,7 +299,7 @@ impl<'a> DiagnosticBuilder<'a> {
298299
}
299300

300301
impl<'a> Debug for DiagnosticBuilder<'a> {
301-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
302+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
302303
self.diagnostic.fmt(f)
303304
}
304305
}

src/librustc_errors/emitter.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
use self::Destination::*;
1+
use Destination::*;
22

33
use syntax_pos::{SourceFile, Span, MultiSpan};
44

5-
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
6-
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
7-
use styled_buffer::StyledBuffer;
5+
use crate::{Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
6+
use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
7+
use crate::styled_buffer::StyledBuffer;
88

99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_data_structures::sync::Lrc;
11-
use atty;
1211
use std::borrow::Cow;
1312
use std::io::prelude::*;
1413
use std::io;
1514
use std::cmp::{min, Reverse};
1615
use termcolor::{StandardStream, ColorChoice, ColorSpec, BufferWriter};
1716
use termcolor::{WriteColor, Color, Buffer};
18-
use unicode_width;
1917

2018
const ANONYMIZED_LINE_NUM: &str = "LL";
2119

2220
/// Emitter trait for emitting errors.
2321
pub trait Emitter {
2422
/// Emit a structured diagnostic.
25-
fn emit(&mut self, db: &DiagnosticBuilder);
23+
fn emit(&mut self, db: &DiagnosticBuilder<'_>);
2624

2725
/// Check if should show explanations about "rustc --explain"
2826
fn should_show_explain(&self) -> bool {
@@ -31,7 +29,7 @@ pub trait Emitter {
3129
}
3230

3331
impl Emitter for EmitterWriter {
34-
fn emit(&mut self, db: &DiagnosticBuilder) {
32+
fn emit(&mut self, db: &DiagnosticBuilder<'_>) {
3533
let mut primary_span = db.span.clone();
3634
let mut children = db.children.clone();
3735
let mut suggestions: &[_] = &[];
@@ -1431,7 +1429,7 @@ fn emit_to_destination(rendered_buffer: &[Vec<StyledString>],
14311429
dst: &mut Destination,
14321430
short_message: bool)
14331431
-> io::Result<()> {
1434-
use lock;
1432+
use crate::lock;
14351433

14361434
let mut dst = dst.writable();
14371435

src/librustc_errors/lib.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,15 @@
66
#![allow(unused_attributes)]
77
#![feature(range_contains)]
88
#![cfg_attr(unix, feature(libc))]
9-
#![feature(nll)]
109
#![feature(optin_builtin_traits)]
10+
#![deny(rust_2018_idioms)]
1111

12-
extern crate atty;
13-
extern crate termcolor;
14-
#[cfg(unix)]
15-
extern crate libc;
16-
#[macro_use]
17-
extern crate log;
18-
extern crate rustc_data_structures;
19-
extern crate serialize as rustc_serialize;
20-
extern crate syntax_pos;
21-
extern crate unicode_width;
12+
#[allow(unused_extern_crates)]
13+
extern crate serialize as rustc_serialize; // used by deriving
2214

2315
pub use emitter::ColorConfig;
2416

25-
use self::Level::*;
17+
use Level::*;
2618

2719
use emitter::{Emitter, EmitterWriter};
2820

@@ -144,7 +136,7 @@ impl CodeSuggestion {
144136
use syntax_pos::{CharPos, Loc, Pos};
145137

146138
fn push_trailing(buf: &mut String,
147-
line_opt: Option<&Cow<str>>,
139+
line_opt: Option<&Cow<'_, str>>,
148140
lo: &Loc,
149141
hi_opt: Option<&Loc>) {
150142
let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize()));
@@ -247,7 +239,7 @@ impl FatalError {
247239
}
248240

249241
impl fmt::Display for FatalError {
250-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
242+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
251243
write!(f, "parser fatal error")
252244
}
253245
}
@@ -264,7 +256,7 @@ impl error::Error for FatalError {
264256
pub struct ExplicitBug;
265257

266258
impl fmt::Display for ExplicitBug {
267-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
259+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
268260
write!(f, "parser internal bug")
269261
}
270262
}
@@ -496,7 +488,7 @@ impl Handler {
496488
DiagnosticBuilder::new(self, Level::Fatal, msg)
497489
}
498490

499-
pub fn cancel(&self, err: &mut DiagnosticBuilder) {
491+
pub fn cancel(&self, err: &mut DiagnosticBuilder<'_>) {
500492
err.cancel();
501493
}
502494

@@ -698,12 +690,12 @@ impl Handler {
698690
self.taught_diagnostics.borrow_mut().insert(code.clone())
699691
}
700692

701-
pub fn force_print_db(&self, mut db: DiagnosticBuilder) {
693+
pub fn force_print_db(&self, mut db: DiagnosticBuilder<'_>) {
702694
self.emitter.borrow_mut().emit(&db);
703695
db.cancel();
704696
}
705697

706-
fn emit_db(&self, db: &DiagnosticBuilder) {
698+
fn emit_db(&self, db: &DiagnosticBuilder<'_>) {
707699
let diagnostic = &**db;
708700

709701
TRACK_DIAGNOSTICS.with(|track_diagnostics| {
@@ -749,7 +741,7 @@ pub enum Level {
749741
}
750742

751743
impl fmt::Display for Level {
752-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
744+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
753745
self.to_str().fmt(f)
754746
}
755747
}

src/librustc_errors/snippet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code for annotating snippets.
22

3-
use Level;
3+
use crate::Level;
44

55
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
66
pub struct Line {

src/librustc_errors/styled_buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code for creating styled buffers
22

3-
use snippet::{Style, StyledString};
3+
use crate::snippet::{Style, StyledString};
44

55
#[derive(Debug)]
66
pub struct StyledBuffer {

0 commit comments

Comments
 (0)