From 23d25a3094ec89fca610cd2e0d3434e36a4f11ab Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 20 Jul 2022 14:59:42 +0200 Subject: [PATCH] Enable extra warnings required by rust-lang/rust --- crates/base-db/src/lib.rs | 3 +++ crates/cfg/src/lib.rs | 2 ++ crates/flycheck/src/lib.rs | 2 ++ crates/hir-def/src/lib.rs | 2 ++ crates/hir-expand/src/lib.rs | 2 ++ crates/hir-ty/src/lib.rs | 2 ++ crates/hir/src/lib.rs | 1 + crates/ide-assists/src/lib.rs | 3 +++ crates/ide-completion/src/lib.rs | 2 ++ crates/ide-db/src/lib.rs | 2 ++ crates/ide-diagnostics/src/lib.rs | 2 ++ crates/ide-ssr/src/lib.rs | 2 ++ crates/ide/src/lib.rs | 1 + crates/limit/src/lib.rs | 2 ++ crates/mbe/src/lib.rs | 2 ++ crates/parser/src/lib.rs | 2 ++ crates/paths/src/lib.rs | 3 +++ crates/proc-macro-api/src/lib.rs | 2 ++ crates/proc-macro-srv/src/lib.rs | 2 ++ crates/proc-macro-test/imp/src/lib.rs | 2 ++ crates/proc-macro-test/src/lib.rs | 2 ++ crates/profile/src/lib.rs | 2 ++ crates/project-model/src/lib.rs | 2 ++ crates/rust-analyzer/src/bin/main.rs | 3 +++ crates/rust-analyzer/src/lib.rs | 2 ++ crates/rust-analyzer/tests/slow-tests/main.rs | 2 ++ crates/sourcegen/src/lib.rs | 2 ++ crates/stdx/src/lib.rs | 3 +++ crates/syntax/src/lib.rs | 2 ++ crates/test-utils/src/lib.rs | 2 ++ crates/text-edit/src/lib.rs | 2 ++ crates/toolchain/src/lib.rs | 3 +++ crates/tt/src/lib.rs | 3 +++ crates/vfs-notify/src/lib.rs | 3 +++ crates/vfs/src/lib.rs | 3 +++ lib/la-arena/src/lib.rs | 1 + lib/lsp-server/src/lib.rs | 3 +++ xtask/src/main.rs | 3 +++ 38 files changed, 84 insertions(+) diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs index f5622ecf60..f55b82e8ab 100644 --- a/crates/base-db/src/lib.rs +++ b/crates/base-db/src/lib.rs @@ -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; diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index 837b8d4c92..d78ef4fb11 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -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)] diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index f683fe61fe..4e8bc881ae 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -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}, diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs index 4431d1b3c8..0dd0a5861e 100644 --- a/crates/hir-def/src/lib.rs +++ b/crates/hir-def/src/lib.rs @@ -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)*) }; diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs index 8fcfad2009..252293090b 100644 --- a/crates/hir-expand/src/lib.rs +++ b/crates/hir-expand/src/lib.rs @@ -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; diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs index 5abbee8971..125b3d7de8 100644 --- a/crates/hir-ty/src/lib.rs +++ b/crates/hir-ty/src/lib.rs @@ -1,6 +1,8 @@ //! The type system. We currently use this to infer types for completion, hover //! information and various assists. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + #[allow(unused)] macro_rules! eprintln { ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 7e262b4e4c..327493ccac 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -17,6 +17,7 @@ //! from the ide with completions, hovers, etc. It is a (soft, internal) boundary: //! . +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] #![recursion_limit = "512"] mod semantics; diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs index 7b9134efb4..1a844d9613 100644 --- a/crates/ide-assists/src/lib.rs +++ b/crates/ide-assists/src/lib.rs @@ -57,6 +57,9 @@ //! //! See also this post: //! + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + #[allow(unused)] macro_rules! eprintln { ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; diff --git a/crates/ide-completion/src/lib.rs b/crates/ide-completion/src/lib.rs index b806d955d9..ae1a440d06 100644 --- a/crates/ide-completion/src/lib.rs +++ b/crates/ide-completion/src/lib.rs @@ -1,5 +1,7 @@ //! `completions` crate provides utilities for generating completions of user input. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod completions; mod config; mod context; diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs index 165b98d72e..e2630d686b 100644 --- a/crates/ide-db/src/lib.rs +++ b/crates/ide-db/src/lib.rs @@ -2,6 +2,8 @@ //! //! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod apply_change; pub mod active_parameter; diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index eeddd36fb5..daf9b16886 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -23,6 +23,8 @@ //! There are also a couple of ad-hoc diagnostics implemented directly here, we //! don't yet have a great pattern for how to do them properly. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod handlers { pub(crate) mod break_outside_of_loop; pub(crate) mod inactive_code; diff --git a/crates/ide-ssr/src/lib.rs b/crates/ide-ssr/src/lib.rs index 7b4e53ed24..a5e24daa9f 100644 --- a/crates/ide-ssr/src/lib.rs +++ b/crates/ide-ssr/src/lib.rs @@ -3,6 +3,8 @@ //! Allows searching the AST for code that matches one or more patterns and then replacing that code //! based on a template. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + // Feature: Structural Search and Replace // // Search and replace with named wildcards that will match any expression, type, path, pattern or item. diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 88dd103f39..dd108fa799 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -9,6 +9,7 @@ // For proving that RootDatabase is RefUnwindSafe. #![recursion_limit = "128"] +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] #[allow(unused)] macro_rules! eprintln { diff --git a/crates/limit/src/lib.rs b/crates/limit/src/lib.rs index 12228e105c..3c1da80edb 100644 --- a/crates/limit/src/lib.rs +++ b/crates/limit/src/lib.rs @@ -1,5 +1,7 @@ //! limit defines a struct to enforce limits. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::sync::atomic::AtomicUsize; /// Represents a struct used to enforce a numerical limit. diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index 6402ceadaa..4f09049fdf 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs @@ -6,6 +6,8 @@ //! The tes for this functionality live in another crate: //! `hir_def::macro_expansion_tests::mbe`. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod parser; mod expander; mod syntax_bridge; diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index cff4ca4ba2..203f59407a 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -16,6 +16,8 @@ //! Tests for this crate live in the `syntax` crate. //! //! [`Parser`]: crate::parser::Parser + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] #![allow(rustdoc::private_intra_doc_links)] mod lexed_str; diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index b4beb40e74..025093f4a9 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -1,5 +1,8 @@ //! Thin wrappers around `std::path`, distinguishing between absolute and //! relative paths. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::{ borrow::Borrow, ffi::OsStr, diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index 4a30168ca5..dbf2fb37e7 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -5,6 +5,8 @@ //! is used to provide basic infrastructure for communication between two //! processes: Client (RA itself), Server (the external program) +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + pub mod msg; mod process; mod version; diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs index 52693547e5..ca7765082f 100644 --- a/crates/proc-macro-srv/src/lib.rs +++ b/crates/proc-macro-srv/src/lib.rs @@ -9,6 +9,8 @@ //! RA than `proc-macro2` token stream. //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` //! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)… + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] #![allow(unreachable_pub)] mod dylib; diff --git a/crates/proc-macro-test/imp/src/lib.rs b/crates/proc-macro-test/imp/src/lib.rs index 980187a902..f74d04729b 100644 --- a/crates/proc-macro-test/imp/src/lib.rs +++ b/crates/proc-macro-test/imp/src/lib.rs @@ -1,5 +1,7 @@ //! Exports a few trivial procedural macros for testing. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use proc_macro::{Group, Ident, Punct, TokenStream, TokenTree}; #[proc_macro] diff --git a/crates/proc-macro-test/src/lib.rs b/crates/proc-macro-test/src/lib.rs index 2edf23a634..6d57bc81e0 100644 --- a/crates/proc-macro-test/src/lib.rs +++ b/crates/proc-macro-test/src/lib.rs @@ -1,4 +1,6 @@ //! Exports a few trivial procedural macros for testing. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + pub static PROC_MACRO_TEST_LOCATION: &str = include_str!(concat!(env!("OUT_DIR"), "/proc_macro_test_location.txt")); diff --git a/crates/profile/src/lib.rs b/crates/profile/src/lib.rs index bf9048e935..00f7952e80 100644 --- a/crates/profile/src/lib.rs +++ b/crates/profile/src/lib.rs @@ -1,5 +1,7 @@ //! A collection of tools for profiling rust-analyzer. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod stop_watch; mod memory_usage; #[cfg(feature = "cpu_profiler")] diff --git a/crates/project-model/src/lib.rs b/crates/project-model/src/lib.rs index 1caf6b59bc..e3f83084ac 100644 --- a/crates/project-model/src/lib.rs +++ b/crates/project-model/src/lib.rs @@ -15,6 +15,8 @@ //! procedural macros). //! * Lowering of concrete model to a [`base_db::CrateGraph`] +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod manifest_path; mod cargo_workspace; mod cfg_flag; diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 45a3a23554..e9de23cb39 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -1,6 +1,9 @@ //! Driver for rust-analyzer. //! //! Based on cli flags, either spawns an LSP server, or runs a batch analysis + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod logger; mod rustc_wrapper; diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index e04df7dea4..4b1e0cd5ae 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -9,6 +9,8 @@ //! The `cli` submodule implements some batch-processing analysis, primarily as //! a debugging aid. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + pub mod cli; #[allow(unused)] diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index 884224960f..eef76343dc 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -8,6 +8,8 @@ //! specific JSON shapes here -- there's little value in such tests, as we can't //! be sure without a real client anyway. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod sourcegen; mod tidy; mod testdir; diff --git a/crates/sourcegen/src/lib.rs b/crates/sourcegen/src/lib.rs index 2972fc45f8..ce0224ec74 100644 --- a/crates/sourcegen/src/lib.rs +++ b/crates/sourcegen/src/lib.rs @@ -6,6 +6,8 @@ //! //! This crate contains utilities to make this kind of source-gen easy. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::{ fmt, fs, mem, path::{Path, PathBuf}, diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 66fa25ec23..b4d45206c4 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -1,4 +1,7 @@ //! Missing batteries for standard libraries. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::process::Command; use std::{cmp::Ordering, ops, time::Instant}; use std::{io as sio, iter}; diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index e0309756b8..7fa354c0c4 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -19,6 +19,8 @@ //! [RFC]: //! [Swift]: +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + #[allow(unused)] macro_rules! eprintln { ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; diff --git a/crates/test-utils/src/lib.rs b/crates/test-utils/src/lib.rs index 4438a12093..160cf60f9f 100644 --- a/crates/test-utils/src/lib.rs +++ b/crates/test-utils/src/lib.rs @@ -6,6 +6,8 @@ //! * Extracting markup (mainly, `$0` markers) out of fixture strings. //! * marks (see the eponymous module). +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + pub mod bench_fixture; mod fixture; mod assert_linear; diff --git a/crates/text-edit/src/lib.rs b/crates/text-edit/src/lib.rs index 922d24bc75..9bb4271b65 100644 --- a/crates/text-edit/src/lib.rs +++ b/crates/text-edit/src/lib.rs @@ -4,6 +4,8 @@ //! so `TextEdit` is the ultimate representation of the work done by //! rust-analyzer. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use itertools::Itertools; use std::cmp::max; pub use text_size::{TextRange, TextSize}; diff --git a/crates/toolchain/src/lib.rs b/crates/toolchain/src/lib.rs index 3b6886f5b5..b05da76916 100644 --- a/crates/toolchain/src/lib.rs +++ b/crates/toolchain/src/lib.rs @@ -1,4 +1,7 @@ //! Discovery of `cargo` & `rustc` executables. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::{env, iter, path::PathBuf}; pub fn cargo() -> PathBuf { diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs index 0316b15038..845ebfa4da 100644 --- a/crates/tt/src/lib.rs +++ b/crates/tt/src/lib.rs @@ -1,6 +1,9 @@ //! `tt` crate defines a `TokenTree` data structure: this is the interface (both //! input and output) of macros. It closely mirrors `proc_macro` crate's //! `TokenTree`. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::fmt; use stdx::impl_from; diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index b5783cef21..4d33a9afb9 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -6,6 +6,9 @@ //! //! Hopefully, one day a reliable file watching/walking crate appears on //! crates.io, and we can reduce this to trivial glue code. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + use std::fs; use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs index e075d752b7..10fae41d08 100644 --- a/crates/vfs/src/lib.rs +++ b/crates/vfs/src/lib.rs @@ -37,6 +37,9 @@ //! [`FileSet`]: file_set::FileSet //! [`Handle`]: loader::Handle //! [`Entries`]: loader::Entry + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod anchored_path; pub mod file_set; pub mod loader; diff --git a/lib/la-arena/src/lib.rs b/lib/la-arena/src/lib.rs index 9fe6d60623..ce6eebd31e 100644 --- a/lib/la-arena/src/lib.rs +++ b/lib/la-arena/src/lib.rs @@ -1,5 +1,6 @@ //! Yet another index-based arena. +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] #![warn(missing_docs)] use std::{ diff --git a/lib/lsp-server/src/lib.rs b/lib/lsp-server/src/lib.rs index 1aaf327da0..d567077d4a 100644 --- a/lib/lsp-server/src/lib.rs +++ b/lib/lsp-server/src/lib.rs @@ -3,6 +3,9 @@ //! control the message dispatch loop yourself. //! //! Run with `RUST_LOG=lsp_server=debug` to see all the messages. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod msg; mod stdio; mod error; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index df726dc23c..335ac324a5 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7,6 +7,9 @@ //! //! This binary is integrated into the `cargo` command line by using an alias in //! `.cargo/config`. + +#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)] + mod flags; mod install;