about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-14/+25
position.
2021-06-09Auto merge of #86003 - pnkfelix:issue-84297-revert-81238, r=Mark-Simulacrumbors-2/+2
Make copy/copy_nonoverlapping fn's again Make copy/copy_nonoverlapping fn's again, rather than intrinsics. This a short-term change to address issue #84297. It effectively reverts PRs #81167 #81238 (and part of #82967), #83091, and parts of #79684.
2021-06-04Revert clippy's path to the copy intrinsics (part of reverting PR 81238).Felix S. Klock II-2/+2
2021-06-04Remove `doc(include)`Joshua Nelson-19/+3
2021-06-03Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyupflip1995-1305/+2367
2021-05-24remove cfg(bootstrap)Pietro Albini-2/+0
2021-05-20Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyupflip1995-668/+2329
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-3/+3
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-6/+6
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-90/+90
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-12Use () for inherent_impls.Camille GILLOT-2/+2
2021-05-12Use () for entry_fn.Camille GILLOT-2/+2
2021-05-12Use () for HIR queries.Camille GILLOT-2/+2
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-5/+4
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Implement span quoting for proc-macrosAaron Hill-4/+4
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-05-11Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obkbors-7/+6
remove const_fn feature gate Fixes https://github.com/rust-lang/rust/issues/84510 r? `@oli-obk`
2021-05-11fix clippy testRalf Jung-7/+6
2021-05-10Auto merge of #85053 - camsteffen:duplicate-lint, r=davidtwcobors-28/+4
Fix duplicate unknown lint errors Fixes rust-lang/rust-clippy#6602
2021-05-07Fix duplicate unknown lint errorsCameron Steffen-28/+4
2021-05-06Fix clippyScott McMurray-3/+3
2021-05-06Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyupflip1995-1057/+2323
2021-05-05Use local and remapped paths where appropriateAndy Wang-5/+4
2021-05-05Auto merge of #84200 - CDirkx:os, r=m-ou-sebors-1/+1
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038. `@rustbot` label: +T-libs-impl
2021-05-04Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakisbors-0/+8
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
2021-05-03Change `std::sys::unix::ext::fs::PermissionsExt::from_mode` to ↵Christiaan Dirkx-1/+1
`std::os::imp::unix::fs::PermissionsExt::from_mode` in Clippy
2021-05-02Add ErrorKind::OutOfMemoryKornel-2/+4
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-1/+1
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29Fix clippy errorRyan Levick-0/+8
2021-04-29Auto merge of #84189 - jyn514:clippy-dev, r=Mark-Simulacrumbors-10/+3
Implement `x.py test src/tools/clippy --bless` - Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
2021-04-28Rollup merge of #84484 - jyn514:check-tools, r=Mark-SimulacrumJack Huey-2/+2
Don't rebuild rustdoc and clippy after checking bootstrap This works by unconditionally passing -Z unstable-options to the compiler. This has no affect in practice since bootstrap doesn't use `deny(rustc::internal)`. Fixes https://github.com/rust-lang/rust/issues/82461. r? ```@Mark-Simulacrum```
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-1/+1
2021-04-27Switch `rustc::internal` from deny to warnJoshua Nelson-2/+2
These should still obey deny-warnings.
2021-04-27Implement `x.py test src/tools/clippy --bless`Joshua Nelson-10/+3
- Add clippy_dev to the rust workspace Before, it would give an error that it wasn't either included or excluded from the workspace: ``` error: current package believes it's in a workspace when it's not: current: /home/joshua/rustc/src/tools/clippy/clippy_dev/Cargo.toml workspace: /home/joshua/rustc/Cargo.toml this may be fixable by adding `src/tools/clippy/clippy_dev` to the `workspace.members` array of the manifest located at: /home/joshua/rustc/Cargo.toml Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. ``` - Change clippy's copy of compiletest not to special-case rust-lang/rust. Using OUT_DIR confused `clippy_dev` and it couldn't find the test outputs. This is one of the reasons why `cargo dev bless` used to silently do nothing (the others were that `CARGO_TARGET_DIR` and `PROFILE` weren't set appropriately). - Run clippy_dev on test failure I tested this by removing a couple lines from a stderr file, and they were correctly replaced. - Fix clippy_dev warnings
2021-04-27Merge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyupflip1995-326/+416
2021-04-25fix clippyRalf Jung-1/+1
2021-04-22Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyupflip1995-1551/+4649
2021-04-19fix suggestion for unsized function parameterslcnr-2/+2
2021-04-18Auto merge of #78880 - CDirkx:not_supported, r=joshtriplettbors-2/+4
Add `Unsupported` to `std::io::ErrorKind` I noticed a significant portion of the uses of `ErrorKind::Other` in std is for unsupported operations. The notion that a specific operation is not available on a target (and will thus never succeed) seems semantically distinct enough from just "an unspecified error occurred", which is why I am proposing to add the variant `Unsupported` to `std::io::ErrorKind`. **Implementation**: The following variant will be added to `std::io::ErrorKind`: ```rust /// This operation is unsupported on this platform. Unsupported ``` `std::io::ErrorKind::Unsupported` is an error returned when a given operation is not supported on a platform, and will thus never succeed; there is no way for the software to recover. It will be used instead of `Other` where appropriate, e.g. on wasm for file and network operations. `decode_error_kind` will be updated to decode operating system errors to `Unsupported`: - Unix and VxWorks: `libc::ENOSYS` - Windows: `c::ERROR_CALL_NOT_IMPLEMENTED` - WASI: `wasi::ERRNO_NOSYS` **Stability**: This changes the kind of error returned by some functions on some platforms, which I think is not covered by the stability guarantees of the std? User code could depend on this behavior, expecting `ErrorKind::Other`, however the docs already mention: > Errors that are `Other` now may move to a different or a new `ErrorKind` variant in the future. It is not recommended to match an error against `Other` and to expect any additional characteristics, e.g., a specific `Error::raw_os_error` return value. The most recent variant added to `ErrorKind` was `UnexpectedEof` in `1.6.0` (almost 5 years ago), but `ErrorKind` is marked as `#[non_exhaustive]` and the docs warn about exhaustively matching on it, so adding a new variant per se should not be a breaking change. The variant `Unsupported` itself could be marked as `#[unstable]`, however, because this PR also immediately uses this new variant and changes the errors returned by functions I'm inclined to agree with the others in this thread that the variant should be insta-stabilized.
2021-04-18Fix clippy test using `ErrorKind`Christiaan Dirkx-2/+4
2021-04-18Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkovbors-1/+1
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes Fixes #83477.
2021-04-17Do not ignore path segments in the middle in ↵hyd-dev-1/+1
`#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes
2021-04-16Remove #[main] attribute.Charles Lew-2/+2
2021-04-08Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyupflip1995-5900/+10307
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-3/+7
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-3/+7
2021-04-05Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisaDylan DPC-4/+4
Remove attribute `#[link_args]` Closes https://github.com/rust-lang/rust/issues/29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-4/+4
2021-04-02fix clippy errorRoxane-1/+1
2021-03-31Track bound varsJack Huey-5/+5
2021-03-30Remove hir::CrateItem.Camille GILLOT-6/+6