Skip to content

Commit 28bab68

Browse files
committed
Auto merge of #12826 - fasterthanlime:in-tree-warnings, r=Veykril
Enable (and fix) extra lint groups required for in-tree build This enables 3 lint groups that are required to build rust-analyzer as an "in-tree" (git subtree) tool in `rust-lang/rust`, and fixes all relevant diagnostics. This change is tracked in: * #12818 Maintainer impact: more warnings, should be easy enough to fix them (it's mostly looking out for "rust-2015-isms", the lint group is poorly named). If you forget some, they'll show up during a `ra=>rust` sync.
2 parents 0ded8e7 + 7e285e1 commit 28bab68

File tree

262 files changed

+1125
-896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+1125
-896
lines changed

crates/base-db/src/change.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Change {
1717
}
1818

1919
impl fmt::Debug for Change {
20-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
20+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2121
let mut d = fmt.debug_struct("Change");
2222
if let Some(roots) = &self.roots {
2323
d.field("roots", roots);

crates/base-db/src/input.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl CrateName {
104104
}
105105

106106
impl fmt::Display for CrateName {
107-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
107+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
108108
self.0.fmt(f)
109109
}
110110
}
@@ -187,7 +187,7 @@ impl From<CrateName> for CrateDisplayName {
187187
}
188188

189189
impl fmt::Display for CrateDisplayName {
190-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
190+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
191191
self.crate_name.fmt(f)
192192
}
193193
}

crates/base-db/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! base_db defines basic database traits. The concrete DB is defined by ide.
2+
3+
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
4+
25
mod input;
36
mod change;
47
pub mod fixture;
@@ -54,7 +57,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
5457
pub trait FileLoader {
5558
/// Text of the file.
5659
fn file_text(&self, file_id: FileId) -> Arc<String>;
57-
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>;
60+
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
5861
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
5962
}
6063

@@ -113,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
113116
fn file_text(&self, file_id: FileId) -> Arc<String> {
114117
SourceDatabaseExt::file_text(self.0, file_id)
115118
}
116-
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
119+
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
117120
// FIXME: this *somehow* should be platform agnostic...
118121
let source_root = self.0.file_source_root(path.anchor);
119122
let source_root = self.0.source_root(source_root);

crates/cfg/src/cfg_expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl CfgExpr {
8585
}
8686
}
8787

88-
fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
88+
fn next_cfg_expr(it: &mut SliceIter<'_, tt::TokenTree>) -> Option<CfgExpr> {
8989
let name = match it.next() {
9090
None => return None,
9191
Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) => ident.text.clone(),

crates/cfg/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
22
3+
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
4+
35
mod cfg_expr;
46
mod dnf;
57
#[cfg(test)]

crates/flycheck/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//! another compatible command (f.x. clippy) in a background thread and provide
33
//! LSP diagnostics based on the output of the command.
44
5+
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
6+
57
use std::{
68
fmt, io,
79
process::{ChildStderr, ChildStdout, Command, Stdio},

crates/hir-def/src/generics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl GenericParams {
195195
}
196196
}
197197

198-
pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx, node: &dyn HasGenericParams) {
198+
pub(crate) fn fill(&mut self, lower_ctx: &LowerCtx<'_>, node: &dyn HasGenericParams) {
199199
if let Some(params) = node.generic_param_list() {
200200
self.fill_params(lower_ctx, params)
201201
}
@@ -206,7 +206,7 @@ impl GenericParams {
206206

207207
pub(crate) fn fill_bounds(
208208
&mut self,
209-
lower_ctx: &LowerCtx,
209+
lower_ctx: &LowerCtx<'_>,
210210
node: &dyn ast::HasTypeBounds,
211211
target: Either<TypeRef, LifetimeRef>,
212212
) {
@@ -217,7 +217,7 @@ impl GenericParams {
217217
}
218218
}
219219

220-
fn fill_params(&mut self, lower_ctx: &LowerCtx, params: ast::GenericParamList) {
220+
fn fill_params(&mut self, lower_ctx: &LowerCtx<'_>, params: ast::GenericParamList) {
221221
for type_or_const_param in params.type_or_const_params() {
222222
match type_or_const_param {
223223
ast::TypeOrConstParam::Type(type_param) => {
@@ -259,7 +259,7 @@ impl GenericParams {
259259
}
260260
}
261261

262-
fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) {
262+
fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx<'_>, where_clause: ast::WhereClause) {
263263
for pred in where_clause.predicates() {
264264
let target = if let Some(type_ref) = pred.ty() {
265265
Either::Left(TypeRef::from_ast(lower_ctx, type_ref))
@@ -293,7 +293,7 @@ impl GenericParams {
293293

294294
fn add_where_predicate_from_bound(
295295
&mut self,
296-
lower_ctx: &LowerCtx,
296+
lower_ctx: &LowerCtx<'_>,
297297
bound: ast::TypeBound,
298298
hrtb_lifetimes: Option<&Box<[Name]>>,
299299
target: Either<TypeRef, LifetimeRef>,

crates/hir-def/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! Note that `hir_def` is a work in progress, so not all of the above is
88
//! actually true.
99
10+
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
11+
1012
#[allow(unused)]
1113
macro_rules! eprintln {
1214
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };

crates/hir-def/src/nameres/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ impl ModCollector<'_, '_> {
15091509
let module = self.def_collector.def_map.module_id(self.module_id);
15101510
let def_map = &mut self.def_collector.def_map;
15111511
let update_def =
1512-
|def_collector: &mut DefCollector, id, name: &Name, vis, has_constructor| {
1512+
|def_collector: &mut DefCollector<'_>, id, name: &Name, vis, has_constructor| {
15131513
def_collector.def_map.modules[self.module_id].scope.declare(id);
15141514
def_collector.update(
15151515
self.module_id,

crates/hir-def/src/path.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub enum GenericArg {
8888
impl Path {
8989
/// Converts an `ast::Path` to `Path`. Works with use trees.
9090
/// It correctly handles `$crate` based path from macro call.
91-
pub fn from_src(path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
91+
pub fn from_src(path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
9292
lower::lower_path(path, ctx)
9393
}
9494

@@ -188,7 +188,10 @@ impl<'a> PathSegments<'a> {
188188
}
189189

190190
impl GenericArgs {
191-
pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
191+
pub(crate) fn from_ast(
192+
lower_ctx: &LowerCtx<'_>,
193+
node: ast::GenericArgList,
194+
) -> Option<GenericArgs> {
192195
lower::lower_generic_args(lower_ctx, node)
193196
}
194197

crates/hir-def/src/path/lower.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515

1616
/// Converts an `ast::Path` to `Path`. Works with use trees.
1717
/// It correctly handles `$crate` based path from macro call.
18-
pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
18+
pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
1919
let mut kind = PathKind::Plain;
2020
let mut type_anchor = None;
2121
let mut segments = Vec::new();
@@ -149,7 +149,7 @@ pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
149149
}
150150

151151
pub(super) fn lower_generic_args(
152-
lower_ctx: &LowerCtx,
152+
lower_ctx: &LowerCtx<'_>,
153153
node: ast::GenericArgList,
154154
) -> Option<GenericArgs> {
155155
let mut args = Vec::new();
@@ -196,7 +196,7 @@ pub(super) fn lower_generic_args(
196196
/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
197197
/// -> Z` (which desugars to `Fn<(X, Y), Output=Z>`).
198198
fn lower_generic_args_from_fn_path(
199-
ctx: &LowerCtx,
199+
ctx: &LowerCtx<'_>,
200200
params: Option<ast::ParamList>,
201201
ret_type: Option<ast::RetType>,
202202
) -> Option<GenericArgs> {

crates/hir-def/src/test_db.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl FileLoader for TestDB {
7373
fn file_text(&self, file_id: FileId) -> Arc<String> {
7474
FileLoaderDelegate(self).file_text(file_id)
7575
}
76-
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
76+
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
7777
FileLoaderDelegate(self).resolve_path(path)
7878
}
7979
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {

crates/hir-def/src/type_ref.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct TraitRef {
8686

8787
impl TraitRef {
8888
/// Converts an `ast::PathType` to a `hir::TraitRef`.
89-
pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Option<Self> {
89+
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Option<Self> {
9090
// FIXME: Use `Path::from_src`
9191
match node {
9292
ast::Type::PathType(path) => {
@@ -159,7 +159,7 @@ pub enum TraitBoundModifier {
159159

160160
impl TypeRef {
161161
/// Converts an `ast::TypeRef` to a `hir::TypeRef`.
162-
pub fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
162+
pub fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Self {
163163
match node {
164164
ast::Type::ParenType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()),
165165
ast::Type::TupleType(inner) => {
@@ -245,7 +245,7 @@ impl TypeRef {
245245
}
246246
}
247247

248-
pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
248+
pub(crate) fn from_ast_opt(ctx: &LowerCtx<'_>, node: Option<ast::Type>) -> Self {
249249
match node {
250250
Some(node) => TypeRef::from_ast(ctx, node),
251251
None => TypeRef::Error,
@@ -320,7 +320,7 @@ impl TypeRef {
320320
}
321321

322322
pub(crate) fn type_bounds_from_ast(
323-
lower_ctx: &LowerCtx,
323+
lower_ctx: &LowerCtx<'_>,
324324
type_bounds_opt: Option<ast::TypeBoundList>,
325325
) -> Vec<Interned<TypeBound>> {
326326
if let Some(type_bounds) = type_bounds_opt {
@@ -331,7 +331,7 @@ pub(crate) fn type_bounds_from_ast(
331331
}
332332

333333
impl TypeBound {
334-
pub(crate) fn from_ast(ctx: &LowerCtx, node: ast::TypeBound) -> Self {
334+
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::TypeBound) -> Self {
335335
let lower_path_type = |path_type: ast::PathType| ctx.lower_path(path_type.path()?);
336336

337337
match node.kind() {

crates/hir-expand/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! tree originates not from the text of some `FileId`, but from some macro
55
//! expansion.
66
7+
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
8+
79
pub mod db;
810
pub mod ast_id_map;
911
pub mod name;

crates/hir-expand/src/mod_path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl ModPath {
102102
}
103103
}
104104

105-
pub fn escaped(&self) -> EscapedModPath {
105+
pub fn escaped(&self) -> EscapedModPath<'_> {
106106
EscapedModPath(self)
107107
}
108108

crates/hir-expand/src/name.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum Repr {
2121
}
2222

2323
impl fmt::Display for Name {
24-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2525
match &self.0 {
2626
Repr::Text(text) => fmt::Display::fmt(&text, f),
2727
Repr::TupleField(idx) => fmt::Display::fmt(&idx, f),
@@ -35,7 +35,7 @@ fn is_raw_identifier(name: &str) -> bool {
3535
}
3636

3737
impl<'a> fmt::Display for EscapedName<'a> {
38-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
38+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3939
match &self.0 .0 {
4040
Repr::Text(text) => {
4141
if is_raw_identifier(text) {
@@ -142,7 +142,7 @@ impl Name {
142142
}
143143
}
144144

145-
pub fn escaped(&self) -> EscapedName {
145+
pub fn escaped(&self) -> EscapedName<'_> {
146146
EscapedName(self)
147147
}
148148
}

crates/hir-ty/src/autoderef.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ impl Iterator for Autoderef<'_, '_> {
7070
}
7171
}
7272

73-
pub(crate) fn autoderef_step(table: &mut InferenceTable, ty: Ty) -> Option<(AutoderefKind, Ty)> {
73+
pub(crate) fn autoderef_step(
74+
table: &mut InferenceTable<'_>,
75+
ty: Ty,
76+
) -> Option<(AutoderefKind, Ty)> {
7477
if let Some(derefed) = builtin_deref(&ty) {
7578
Some((AutoderefKind::Builtin, table.resolve_ty_shallow(derefed)))
7679
} else {
@@ -94,7 +97,7 @@ pub fn autoderef<'a>(
9497
v.into_iter()
9598
}
9699

97-
pub(crate) fn deref(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
100+
pub(crate) fn deref(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
98101
let _p = profile::span("deref");
99102
autoderef_step(table, ty).map(|(_, ty)| ty)
100103
}
@@ -107,7 +110,7 @@ fn builtin_deref(ty: &Ty) -> Option<&Ty> {
107110
}
108111
}
109112

110-
fn deref_by_trait(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
113+
fn deref_by_trait(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
111114
let _p = profile::span("deref_by_trait");
112115
if table.resolve_ty_shallow(&ty).inference_var(Interner).is_some() {
113116
// don't try to deref unknown variables

crates/hir-ty/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<D> TyBuilder<D> {
111111
this
112112
}
113113

114-
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable) -> Self {
114+
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
115115
self.fill(|x| match x {
116116
ParamKind::Type => GenericArgData::Ty(table.new_type_var()).intern(Interner),
117117
ParamKind::Const(ty) => {

crates/hir-ty/src/diagnostics/match_check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<'a> PatCtxt<'a> {
292292
}
293293

294294
impl HirDisplay for Pat {
295-
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
295+
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
296296
match &*self.kind {
297297
PatKind::Wild => write!(f, "_"),
298298
PatKind::Binding { name, subpattern } => {
@@ -394,11 +394,11 @@ impl HirDisplay for Pat {
394394

395395
struct WriteWith<F>(F)
396396
where
397-
F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>;
397+
F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>;
398398

399399
impl<F> HirDisplay for WriteWith<F>
400400
where
401-
F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>,
401+
F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>,
402402
{
403403
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
404404
(self.0)(f)

crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl IntRange {
144144
}
145145
}
146146

147-
fn to_pat(&self, _cx: &MatchCheckCtx, ty: Ty) -> Pat {
147+
fn to_pat(&self, _cx: &MatchCheckCtx<'_, '_>, ty: Ty) -> Pat {
148148
match ty.kind(Interner) {
149149
TyKind::Scalar(Scalar::Bool) => {
150150
let kind = match self.boundaries() {

0 commit comments

Comments
 (0)