Skip to content

Commit 052427e

Browse files
authored
Merge pull request #2873 from mati865/edition2018_next_step
Next step towards Rust 2018...
2 parents 0de3f36 + df3b9cc commit 052427e

File tree

11 files changed

+40
-71
lines changed

11 files changed

+40
-71
lines changed

build.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
//! This build script was originally taken from the Rocket web framework:
1414
//! https://github.com/SergioBenitez/Rocket
1515
16-
extern crate ansi_term;
17-
extern crate rustc_version;
18-
1916
use ansi_term::Colour::Red;
2017
use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMeta};
2118
use std::env;

clippy_lints/src/attrs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//! checks for attributes
22
33
use crate::reexport::*;
4+
use crate::utils::{
5+
in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_then,
6+
without_block_comments,
7+
};
48
use rustc::hir::*;
59
use rustc::lint::*;
610
use rustc::ty::{self, TyCtxt};
711
use semver::Version;
812
use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
913
use syntax::codemap::Span;
10-
use crate::utils::{
11-
in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snippet_opt, span_lint, span_lint_and_then,
12-
without_block_comments,
13-
};
1414

1515
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
1616
/// unless the annotated function is empty or simply panics.

clippy_lints/src/copies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
134134

135135
/// Implementation of `IF_SAME_THEN_ELSE`.
136136
fn lint_same_then_else(cx: &LateContext, blocks: &[&Block]) {
137-
let eq: &Fn(&&Block, &&Block) -> bool = &|&lhs, &rhs| -> bool { SpanlessEq::new(cx).eq_block(lhs, rhs) };
137+
let eq: &dyn Fn(&&Block, &&Block) -> bool = &|&lhs, &rhs| -> bool { SpanlessEq::new(cx).eq_block(lhs, rhs) };
138138

139139
if let Some((i, j)) = search_same_sequenced(blocks, eq) {
140140
span_note_and_lint(
@@ -150,13 +150,13 @@ fn lint_same_then_else(cx: &LateContext, blocks: &[&Block]) {
150150

151151
/// Implementation of `IFS_SAME_COND`.
152152
fn lint_same_cond(cx: &LateContext, conds: &[&Expr]) {
153-
let hash: &Fn(&&Expr) -> u64 = &|expr| -> u64 {
153+
let hash: &dyn Fn(&&Expr) -> u64 = &|expr| -> u64 {
154154
let mut h = SpanlessHash::new(cx, cx.tables);
155155
h.hash_expr(expr);
156156
h.finish()
157157
};
158158

159-
let eq: &Fn(&&Expr, &&Expr) -> bool = &|&lhs, &rhs| -> bool { SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, rhs) };
159+
let eq: &dyn Fn(&&Expr, &&Expr) -> bool = &|&lhs, &rhs| -> bool { SpanlessEq::new(cx).ignore_fn().eq_expr(lhs, rhs) };
160160

161161
if let Some((i, j)) = search_same(conds, hash, eq) {
162162
span_note_and_lint(

clippy_lints/src/lib.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,23 @@
1212
#![feature(iterator_find_map)]
1313
#![feature(macro_at_most_once_rep)]
1414
#![feature(rust_2018_preview)]
15+
#![warn(rust_2018_idioms)]
1516

16-
extern crate cargo_metadata;
1717
#[macro_use]
1818
extern crate rustc;
19-
extern crate rustc_target;
20-
extern crate rustc_typeck;
21-
extern crate syntax;
22-
extern crate syntax_pos;
2319

24-
extern crate toml;
25-
26-
// for unicode nfc normalization
27-
28-
extern crate unicode_normalization;
29-
30-
// for semver check in attrs.rs
31-
32-
extern crate semver;
33-
34-
// for regex checking
35-
36-
extern crate regex_syntax;
37-
38-
// for finding minimal boolean expressions
39-
40-
extern crate quine_mc_cluskey;
41-
42-
extern crate rustc_errors;
43-
extern crate rustc_plugin;
20+
use toml;
21+
use rustc_plugin;
4422

4523
#[macro_use]
4624
extern crate matches as matches_macro;
4725

48-
extern crate serde;
4926
#[macro_use]
5027
extern crate serde_derive;
5128

5229
#[macro_use]
5330
extern crate lazy_static;
5431

55-
extern crate itertools;
56-
extern crate pulldown_cmark;
57-
extern crate url;
58-
5932
#[macro_use]
6033
extern crate if_chain;
6134

@@ -211,7 +184,7 @@ pub mod zero_div_zero;
211184
// end lints modules, do not remove this comment, it’s used in `update_lints`
212185

213186
mod reexport {
214-
pub use syntax::ast::{Name, NodeId};
187+
crate use syntax::ast::{Name, NodeId};
215188
}
216189

217190
#[cfg_attr(rustfmt, rustfmt_skip)]

clippy_lints/src/literal_representation.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(super) enum Radix {
9090

9191
impl Radix {
9292
/// Return a reasonable digit group size for this radix.
93-
pub fn suggest_grouping(&self) -> usize {
93+
crate fn suggest_grouping(&self) -> usize {
9494
match *self {
9595
Radix::Binary | Radix::Hexadecimal => 4,
9696
Radix::Octal | Radix::Decimal => 3,
@@ -101,19 +101,19 @@ impl Radix {
101101
#[derive(Debug)]
102102
pub(super) struct DigitInfo<'a> {
103103
/// Characters of a literal between the radix prefix and type suffix.
104-
pub digits: &'a str,
104+
crate digits: &'a str,
105105
/// Which radix the literal was represented in.
106-
pub radix: Radix,
106+
crate radix: Radix,
107107
/// The radix prefix, if present.
108-
pub prefix: Option<&'a str>,
108+
crate prefix: Option<&'a str>,
109109
/// The type suffix, including preceding underscore if present.
110-
pub suffix: Option<&'a str>,
110+
crate suffix: Option<&'a str>,
111111
/// True for floating-point literals.
112-
pub float: bool,
112+
crate float: bool,
113113
}
114114

115115
impl<'a> DigitInfo<'a> {
116-
pub fn new(lit: &'a str, float: bool) -> Self {
116+
crate fn new(lit: &'a str, float: bool) -> Self {
117117
// Determine delimiter for radix prefix, if present, and radix.
118118
let radix = if lit.starts_with("0x") {
119119
Radix::Hexadecimal
@@ -160,7 +160,7 @@ impl<'a> DigitInfo<'a> {
160160
}
161161

162162
/// Returns digits grouped in a sensible way.
163-
pub fn grouping_hint(&self) -> String {
163+
crate fn grouping_hint(&self) -> String {
164164
let group_size = self.radix.suggest_grouping();
165165
if self.digits.contains('.') {
166166
let mut parts = self.digits.split('.');
@@ -227,7 +227,7 @@ enum WarningType {
227227
}
228228

229229
impl WarningType {
230-
pub fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: syntax_pos::Span) {
230+
crate fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: syntax_pos::Span) {
231231
match self {
232232
WarningType::UnreadableLiteral => span_lint_and_sugg(
233233
cx,

clippy_lints/src/needless_continue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! For example, the lint would catch
44
//!
5-
//! ```
5+
//! ```ignore
66
//! while condition() {
77
//! update_condition();
88
//! if x {
@@ -16,7 +16,7 @@
1616
//!
1717
//! And suggest something like this:
1818
//!
19-
//! ```
19+
//! ```ignore
2020
//! while condition() {
2121
//! update_condition();
2222
//! if x {
@@ -365,7 +365,7 @@ fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) {
365365
///
366366
/// is transformed to
367367
///
368-
/// ```
368+
/// ```ignore
369369
/// {
370370
/// let x = 5;
371371
/// ```
@@ -388,7 +388,7 @@ pub fn erode_from_back(s: &str) -> String {
388388
/// any number of opening braces are eaten, followed by any number of newlines.
389389
/// e.g., the string
390390
///
391-
/// ```
391+
/// ```ignore
392392
/// {
393393
/// something();
394394
/// inside_a_block();
@@ -397,7 +397,7 @@ pub fn erode_from_back(s: &str) -> String {
397397
///
398398
/// is transformed to
399399
///
400-
/// ```
400+
/// ```ignore
401401
/// something();
402402
/// inside_a_block();
403403
/// }

clippy_lints/src/question_mark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl LintPass for QuestionMarkPass {
4343
impl QuestionMarkPass {
4444
/// Check if the given expression on the given context matches the following structure:
4545
///
46-
/// ```
46+
/// ```ignore
4747
/// if option.is_none() {
4848
/// return None;
4949
/// }

clippy_lints/src/utils/conf.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ lazy_static! {
7676
macro_rules! define_Conf {
7777
($(#[$doc: meta] ($rust_name: ident, $rust_name_str: expr, $default: expr => $($ty: tt)+),)+) => {
7878
pub use self::helpers::Conf;
79+
// FIXME(mati865): remove #[allow(rust_2018_idioms)] when it's fixed:
80+
//
81+
// warning: `extern crate` is not idiomatic in the new edition
82+
// --> src/utils/conf.rs:82:22
83+
// |
84+
// 82 | #[derive(Deserialize)]
85+
// | ^^^^^^^^^^^ help: convert it to a `use`
86+
//
87+
#[allow(rust_2018_idioms)]
7988
mod helpers {
8089
/// Type used to store lint configuration.
8190
#[derive(Deserialize)]
@@ -92,7 +101,7 @@ macro_rules! define_Conf {
92101
mod $rust_name {
93102
use serde;
94103
use serde::Deserialize;
95-
pub fn deserialize<'de, D: serde::Deserializer<'de>>(deserializer: D)
104+
crate fn deserialize<'de, D: serde::Deserializer<'de>>(deserializer: D)
96105
-> Result<define_Conf!(TY $($ty)+), D::Error> {
97106
type T = define_Conf!(TY $($ty)+);
98107
Ok(T::deserialize(deserializer).unwrap_or_else(|e| {

clippy_lints/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
612612
/// These suggestions can be parsed by rustfix to allow it to automatically fix your code.
613613
/// In the example below, `help` is `"try"` and `sugg` is the suggested replacement `".any(|x| x > 2)"`.
614614
///
615-
/// ```
615+
/// ```ignore
616616
/// error: This `.fold` can be more succinctly expressed as `.any`
617617
/// --> $DIR/methods.rs:390:13
618618
/// |

src/driver.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33
#![feature(rustc_private)]
44
#![allow(unknown_lints, missing_docs_in_private_items)]
55

6-
extern crate clippy_lints;
7-
extern crate getopts;
8-
extern crate rustc;
9-
extern crate rustc_codegen_utils;
10-
extern crate rustc_driver;
11-
extern crate rustc_errors;
12-
extern crate rustc_plugin;
13-
extern crate syntax;
14-
15-
use rustc_driver::{driver::CompileController, Compilation};
6+
use rustc_driver::{self, driver::CompileController, Compilation};
7+
use rustc_plugin;
168
use std::process::{exit, Command};
179

1810
#[allow(print_stdout)]

0 commit comments

Comments
 (0)