summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2021-04-28Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakisbors-1/+1
Stabilize `:pat_param` and remove `:pat2021` Blocked on #83384 cc `@rust-lang/lang` #79278 If I understand `@nikomatsakis` in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873, another FCP is not needed. r? `@nikomatsakis`
2021-04-19fix few typosklensy-1/+1
2021-04-18Auto merge of #83799 - crlf0710:stablize_non_ascii_idents, r=Manishearthbors-28/+9
Stablize `non-ascii-idents` This is the stablization PR for RFC 2457. Currently this is waiting on fcp in [tracking issue](https://github.com/rust-lang/rust/issues/55467). r? `@Manishearth`
2021-04-18Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkovbors-43/+38
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-43/+38
`#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes
2021-04-15rename pat2015 to pat_parammark-1/+1
2021-04-15Run buffered lints attached to anon constsAaron Hill-0/+1
Fixes #84195
2021-04-14Auto merge of #83948 - ABouttefeux:lint-nullprt-deref, r=RalfJungbors-0/+88
add lint deref_nullptr detecting when a null ptr is dereferenced fixes #83856 changelog: add lint that detect code like ```rust unsafe { &*core::ptr::null::<i32>() }; unsafe { addr_of!(std::ptr::null::<i32>()) }; let x: i32 = unsafe {*core::ptr::null()}; let x: i32 = unsafe {*core::ptr::null_mut()}; unsafe {*(0 as *const i32)}; unsafe {*(core::ptr::null() as *const i32)}; ``` ``` warning: Dereferencing a null pointer causes undefined behavior --> src\main.rs:5:26 | 5 | let x: i32 = unsafe {*core::ptr::null()}; | ^^^^^^^^^^^^^^^^^^ | | | a null pointer is dereferenced | this code causes undefined behavior when executed | = note: `#[warn(deref_nullptr)]` on by default ``` Limitation: It does not detect code like ```rust const ZERO: usize = 0; unsafe {*(ZERO as *const i32)}; ``` or code where `0` is not directly a literal
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-4/+7
warn-by-default on 2015
2021-04-09changes based on reviewAliénore Bouttefeux-6/+4
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-1/+1
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Rollup merge of #81764 - jyn514:lint-links, r=GuillaumeGomezDylan DPC-3/+4
Stabilize `rustdoc::bare_urls` lint Closes https://github.com/rust-lang/rust/issues/77501. Closes https://github.com/rust-lang/rust/issues/83598.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-08fix lint docAliénore Bouttefeux-18/+7
2021-04-07change documentation of lintAliénore Bouttefeux-5/+14
2021-04-08Stablize `non_ascii_idents` feature.Charles Lew-28/+9
2021-04-07add testAliénore Bouttefeux-0/+2
2021-04-06add lint deref_nullptrAliénore Bouttefeux-0/+90
2021-04-05Fix bug where rustc_lint would not apply renamed tool lintsJoshua Nelson-3/+4
2021-04-04Trigger `unused_doc_comments` on macros at onceYuki Okushi-1/+1
2021-04-01add OR_PATTERNS_BACK_COMPAT linthi-rustin-0/+3
test: add more cases test: add comments refine msg
2021-03-31Add tcx lifetime to BinderJack Huey-1/+1
2021-03-30Remove hir::CrateItem.Camille GILLOT-1/+1
2021-03-27Remove (lots of) dead codeJoshua Nelson-5/+4
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-27Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-seDylan DPC-6/+6
Add function core::iter::zip This makes it a little easier to `zip` iterators: ```rust for (x, y) in zip(xs, ys) {} // vs. for (x, y) in xs.into_iter().zip(ys) {} ``` You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and `iter()`, respectively. This can also support arbitrary nesting, where it's easier to see the item layout than with arbitrary `zip` chains: ```rust for ((x, y), z) in zip(zip(xs, ys), zs) {} for (x, (y, z)) in zip(xs, zip(ys, zs)) {} // vs. for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {} for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {} ``` It may also format more nicely, especially when the first iterator is a longer chain of methods -- for example: ```rust iter::zip( trait_ref.substs.types().skip(1), impl_trait_ref.substs.types().skip(1), ) // vs. trait_ref .substs .types() .skip(1) .zip(impl_trait_ref.substs.types().skip(1)) ``` This replaces the tuple-pair `IntoIterator` in #78204. There is prior art for the utility of this in [`itertools::zip`]. [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27make unaligned_refereces future-incompat lint warn-by-default, and remove ↵Ralf Jung-0/+1
the safe_packed_borrows lint that it replaces
2021-03-26Use iter::zip in compiler/Josh Stone-6/+6
2021-03-19stabilize or_patternsmark-1/+1
2021-03-18Rollup merge of #83216 - jyn514:register-tool, r=petrochenkovDylan DPC-10/+38
Allow registering tool lints with `register_tool` Previously, there was no way to add a custom tool prefix, even if the tool itself had registered a lint: ```rust #![feature(register_tool)] #![register_tool(xyz)] #![warn(xyz::my_lint)] ``` ``` $ rustc unknown-lint.rs --crate-type lib error[E0710]: an unknown tool name found in scoped lint: `xyz::my_lint` --> unknown-lint.rs:3:9 | 3 | #![warn(xyz::my_lint)] | ^^^ ``` This allows opting-in to lints from other tools using `register_tool`. cc https://github.com/rust-lang/rust/issues/66079#issuecomment-788589193, ``@chorman0773`` r? ``@petrochenkov``
2021-03-17Auto merge of #83188 - petrochenkov:field, r=lcnrbors-12/+12
ast/hir: Rename field-related structures I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent. - `StructField` -> `FieldDef` ("field definition") - `Field` -> `ExprField` ("expression field", not "field expression") - `FieldPat` -> `PatField` ("pattern field", not "field pattern") Various visiting and other methods working with the fields are renamed correspondingly too. The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-16Allow registering tool lints with `register_tool`Joshua Nelson-10/+38
Previously, there was no way to add a custom tool prefix, even if the tool itself had registered a lint: ``` #![feature(register_tool)] #![register_tool(xyz)] #![warn(xyz::my_lint)] ``` ``` $ rustc unknown-lint.rs --crate-type lib error[E0710]: an unknown tool name found in scoped lint: `xyz::my_lint` --> unknown-lint.rs:3:9 | 3 | #![warn(xyz::my_lint)] | ^^^ ``` This allows opting-in to lints from other tools using `register_tool`.
2021-03-16Don't warn about old rustdoc lint names (temporarily)Joshua Nelson-1/+35
Right now, rustdoc users have an unpleasant situation: they can either use the new tool lint names (`rustdoc::non_autolinks`) or they can use the old names (`non_autolinks`). If they use the tool lints, they get a hard error on stable compilers, because rustc rejects all tool names it doesn't recognize. If they use the old name, they get a warning to rename the lint to the new name. The only way to compile without warnings is to add `#[allow(renamed_removed_lints)]`, which defeats the whole point of the change: we *want* people to switch to the new name. To avoid people silencing the lint and never migrating to the tool lint, this avoids warning about the old name, while still allowing you to use the new name. Once the new `rustdoc` tool name makes it to the stable channel, we can change these lints to warn again. This adds the new lint functions `register_alias` and `register_ignored` - I didn't see an existing way to do this.
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-12/+12
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-14Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`Aaron Hill-0/+3
Now that future-incompat-report support has landed in nightly Cargo, we can start to make progress towards removing the various proc-macro back-compat hacks that have accumulated in the compiler. This PR introduces a new lint `proc_macro_back_compat`, which results in a future-incompat-report entry being generated. All proc-macro back-compat warnings will be grouped under this lint. Note that this lint will never actually become a hard error - instead, we will remove the special cases for various macros, which will cause older versions of those crates to emit some other error. I've added code to fire this lint for the `time-macros-impl` case. This is the easiest case out of all of our current back-compat hacks - the crate was renamed to `time-macros`, so seeing a filename with `time-macros-impl` guarantees that an older version of the parent `time` crate is in use. When Cargo's future-incompat-report feature gets stabilized, affected users will start to see future-incompat warnings when they build their crates.
2021-03-14Rollup merge of #82798 - jyn514:rustdoc-group, r=Manishearth,GuillaumeGomezYuki Okushi-0/+1
Rename `rustdoc` to `rustdoc::all` When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like ``` warning: unknown lint: `rustdoc` ``` The lint group still worked when rustdoc ran, since rustdoc added the group itself. This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints. Follow-up to #80527. r? ``@Manishearth``
2021-03-09Track HirId when visiting attributes.Camille GILLOT-4/+7
2021-03-09Remove hir::Item::attrs.Camille GILLOT-5/+8
2021-03-09Remove hir::Crate::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::MacroDef::attrs.Camille GILLOT-1/+2
2021-03-09Visit attributes in one go.Camille GILLOT-0/+2
2021-03-09Do not store attrs in FnKind.Camille GILLOT-2/+3
2021-03-09Access attrs directly from HirId in rustc_lint::builtin.Camille GILLOT-38/+10
2021-03-09Access attrs directly from HirId in rustc_lint::levels.Camille GILLOT-11/+12
2021-03-09Access attrs directly from HirId in rustc_lint::late.Camille GILLOT-14/+13
2021-03-09Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkovMara Bos-1/+1
or-patterns: disallow in `let` bindings ~~Blocked on https://github.com/rust-lang/rust/pull/81869~~ Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription. r? ``@petrochenkov``
2021-03-08Rollup merge of #82854 - estebank:issue-82827, r=oli-obkMara Bos-3/+28
Account for `if (let pat = expr) {}` Fix #82827.
2021-03-07Account for `if (let pat = expr) {}`Esteban Küber-3/+28
Partially address #82827.
2021-03-06Handle negative literals in cast overflow warningYuki Okushi-6/+21
2021-03-05Rename `rustdoc` to `rustdoc::all`Joshua Nelson-0/+1
When rustdoc lints were changed to be tool lints, the `rustdoc` group was removed, leading to spurious warnings like ``` warning: unknown lint: `rustdoc` ``` The lint group still worked when rustdoc ran, since rustdoc added the group itself. This renames the group to `rustdoc::all` for consistency with `clippy::all` and the rest of the rustdoc lints.
2021-03-05use pat<no_top_alt> for patterns in let bindingsmark-1/+1