Skip to content

Enable (and fix) extra lint groups required for in-tree build #12826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Change {
}

impl fmt::Debug for Change {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = fmt.debug_struct("Change");
if let Some(roots) = &self.roots {
d.field("roots", roots);
Expand Down
4 changes: 2 additions & 2 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl CrateName {
}

impl fmt::Display for CrateName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
Expand Down Expand Up @@ -187,7 +187,7 @@ impl From<CrateName> for CrateDisplayName {
}

impl fmt::Display for CrateDisplayName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.crate_name.fmt(f)
}
}
Expand Down
7 changes: 5 additions & 2 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//! base_db defines basic database traits. The concrete DB is defined by ide.

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

mod input;
mod change;
pub mod fixture;
Expand Down Expand Up @@ -54,7 +57,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
pub trait FileLoader {
/// Text of the file.
fn file_text(&self, file_id: FileId) -> Arc<String>;
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>;
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
}

Expand Down Expand Up @@ -113,7 +116,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
fn file_text(&self, file_id: FileId) -> Arc<String> {
SourceDatabaseExt::file_text(self.0, file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
// FIXME: this *somehow* should be platform agnostic...
let source_root = self.0.file_source_root(path.anchor);
let source_root = self.0.source_root(source_root);
Expand Down
2 changes: 1 addition & 1 deletion crates/cfg/src/cfg_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl CfgExpr {
}
}

fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
fn next_cfg_expr(it: &mut SliceIter<'_, tt::TokenTree>) -> Option<CfgExpr> {
let name = match it.next() {
None => return None,
Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) => ident.text.clone(),
Expand Down
2 changes: 2 additions & 0 deletions crates/cfg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

mod cfg_expr;
mod dnf;
#[cfg(test)]
Expand Down
2 changes: 2 additions & 0 deletions crates/flycheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//! another compatible command (f.x. clippy) in a background thread and provide
//! LSP diagnostics based on the output of the command.

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

use std::{
fmt, io,
process::{ChildStderr, ChildStdout, Command, Stdio},
Expand Down
10 changes: 5 additions & 5 deletions crates/hir-def/src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl GenericParams {
}
}

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

pub(crate) fn fill_bounds(
&mut self,
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
node: &dyn ast::HasTypeBounds,
target: Either<TypeRef, LifetimeRef>,
) {
Expand All @@ -217,7 +217,7 @@ impl GenericParams {
}
}

fn fill_params(&mut self, lower_ctx: &LowerCtx, params: ast::GenericParamList) {
fn fill_params(&mut self, lower_ctx: &LowerCtx<'_>, params: ast::GenericParamList) {
for type_or_const_param in params.type_or_const_params() {
match type_or_const_param {
ast::TypeOrConstParam::Type(type_param) => {
Expand Down Expand Up @@ -259,7 +259,7 @@ impl GenericParams {
}
}

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

fn add_where_predicate_from_bound(
&mut self,
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
bound: ast::TypeBound,
hrtb_lifetimes: Option<&Box<[Name]>>,
target: Either<TypeRef, LifetimeRef>,
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! Note that `hir_def` is a work in progress, so not all of the above is
//! actually true.

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

#[allow(unused)]
macro_rules! eprintln {
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ impl ModCollector<'_, '_> {
let module = self.def_collector.def_map.module_id(self.module_id);
let def_map = &mut self.def_collector.def_map;
let update_def =
|def_collector: &mut DefCollector, id, name: &Name, vis, has_constructor| {
|def_collector: &mut DefCollector<'_>, id, name: &Name, vis, has_constructor| {
def_collector.def_map.modules[self.module_id].scope.declare(id);
def_collector.update(
self.module_id,
Expand Down
7 changes: 5 additions & 2 deletions crates/hir-def/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub enum GenericArg {
impl Path {
/// Converts an `ast::Path` to `Path`. Works with use trees.
/// It correctly handles `$crate` based path from macro call.
pub fn from_src(path: ast::Path, ctx: &LowerCtx) -> Option<Path> {
pub fn from_src(path: ast::Path, ctx: &LowerCtx<'_>) -> Option<Path> {
lower::lower_path(path, ctx)
}

Expand Down Expand Up @@ -188,7 +188,10 @@ impl<'a> PathSegments<'a> {
}

impl GenericArgs {
pub(crate) fn from_ast(lower_ctx: &LowerCtx, node: ast::GenericArgList) -> Option<GenericArgs> {
pub(crate) fn from_ast(
lower_ctx: &LowerCtx<'_>,
node: ast::GenericArgList,
) -> Option<GenericArgs> {
lower::lower_generic_args(lower_ctx, node)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/hir-def/src/path/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{

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

pub(super) fn lower_generic_args(
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
node: ast::GenericArgList,
) -> Option<GenericArgs> {
let mut args = Vec::new();
Expand Down Expand Up @@ -196,7 +196,7 @@ pub(super) fn lower_generic_args(
/// Collect `GenericArgs` from the parts of a fn-like path, i.e. `Fn(X, Y)
/// -> Z` (which desugars to `Fn<(X, Y), Output=Z>`).
fn lower_generic_args_from_fn_path(
ctx: &LowerCtx,
ctx: &LowerCtx<'_>,
params: Option<ast::ParamList>,
ret_type: Option<ast::RetType>,
) -> Option<GenericArgs> {
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl FileLoader for TestDB {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
Expand Down
10 changes: 5 additions & 5 deletions crates/hir-def/src/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub struct TraitRef {

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

impl TypeRef {
/// Converts an `ast::TypeRef` to a `hir::TypeRef`.
pub fn from_ast(ctx: &LowerCtx, node: ast::Type) -> Self {
pub fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Self {
match node {
ast::Type::ParenType(inner) => TypeRef::from_ast_opt(ctx, inner.ty()),
ast::Type::TupleType(inner) => {
Expand Down Expand Up @@ -245,7 +245,7 @@ impl TypeRef {
}
}

pub(crate) fn from_ast_opt(ctx: &LowerCtx, node: Option<ast::Type>) -> Self {
pub(crate) fn from_ast_opt(ctx: &LowerCtx<'_>, node: Option<ast::Type>) -> Self {
match node {
Some(node) => TypeRef::from_ast(ctx, node),
None => TypeRef::Error,
Expand Down Expand Up @@ -320,7 +320,7 @@ impl TypeRef {
}

pub(crate) fn type_bounds_from_ast(
lower_ctx: &LowerCtx,
lower_ctx: &LowerCtx<'_>,
type_bounds_opt: Option<ast::TypeBoundList>,
) -> Vec<Interned<TypeBound>> {
if let Some(type_bounds) = type_bounds_opt {
Expand All @@ -331,7 +331,7 @@ pub(crate) fn type_bounds_from_ast(
}

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

match node.kind() {
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! tree originates not from the text of some `FileId`, but from some macro
//! expansion.

#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

pub mod db;
pub mod ast_id_map;
pub mod name;
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/src/mod_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl ModPath {
}
}

pub fn escaped(&self) -> EscapedModPath {
pub fn escaped(&self) -> EscapedModPath<'_> {
EscapedModPath(self)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/hir-expand/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum Repr {
}

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

impl<'a> fmt::Display for EscapedName<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 .0 {
Repr::Text(text) => {
if is_raw_identifier(text) {
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Name {
}
}

pub fn escaped(&self) -> EscapedName {
pub fn escaped(&self) -> EscapedName<'_> {
EscapedName(self)
}
}
Expand Down
9 changes: 6 additions & 3 deletions crates/hir-ty/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ impl Iterator for Autoderef<'_, '_> {
}
}

pub(crate) fn autoderef_step(table: &mut InferenceTable, ty: Ty) -> Option<(AutoderefKind, Ty)> {
pub(crate) fn autoderef_step(
table: &mut InferenceTable<'_>,
ty: Ty,
) -> Option<(AutoderefKind, Ty)> {
if let Some(derefed) = builtin_deref(&ty) {
Some((AutoderefKind::Builtin, table.resolve_ty_shallow(derefed)))
} else {
Expand All @@ -94,7 +97,7 @@ pub fn autoderef<'a>(
v.into_iter()
}

pub(crate) fn deref(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
pub(crate) fn deref(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref");
autoderef_step(table, ty).map(|(_, ty)| ty)
}
Expand All @@ -107,7 +110,7 @@ fn builtin_deref(ty: &Ty) -> Option<&Ty> {
}
}

fn deref_by_trait(table: &mut InferenceTable, ty: Ty) -> Option<Ty> {
fn deref_by_trait(table: &mut InferenceTable<'_>, ty: Ty) -> Option<Ty> {
let _p = profile::span("deref_by_trait");
if table.resolve_ty_shallow(&ty).inference_var(Interner).is_some() {
// don't try to deref unknown variables
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<D> TyBuilder<D> {
this
}

pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable) -> Self {
pub(crate) fn fill_with_inference_vars(self, table: &mut InferenceTable<'_>) -> Self {
self.fill(|x| match x {
ParamKind::Type => GenericArgData::Ty(table.new_type_var()).intern(Interner),
ParamKind::Const(ty) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-ty/src/diagnostics/match_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl<'a> PatCtxt<'a> {
}

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

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

impl<F> HirDisplay for WriteWith<F>
where
F: Fn(&mut HirFormatter) -> Result<(), HirDisplayError>,
F: Fn(&mut HirFormatter<'_>) -> Result<(), HirDisplayError>,
{
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
(self.0)(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl IntRange {
}
}

fn to_pat(&self, _cx: &MatchCheckCtx, ty: Ty) -> Pat {
fn to_pat(&self, _cx: &MatchCheckCtx<'_, '_>, ty: Ty) -> Pat {
match ty.kind(Interner) {
TyKind::Scalar(Scalar::Bool) => {
let kind = match self.boundaries() {
Expand Down
Loading