about summary refs log tree commit diff
path: root/src/librustc_lint
AgeCommit message (Collapse)AuthorLines
2020-07-30Apply suggested wording changes from code review.jumbatm-2/+2
Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
2020-07-30Don't emit clashing decl lint for FFI-safe enums.jumbatm-24/+76
An example of an FFI-safe enum conversion is when converting Option<NonZeroUsize> to usize. Because the Some value must be non-zero, rustc can use 0 to represent the None variant, making this conversion is safe. Furthermore, it can be relied on (and removing this optimisation already would be a breaking change).
2020-07-29Register renamed lintManish Goregaokar-0/+1
2020-07-29Rename intra_doc_link_resolution_failure -> intra_doc_link_resolution_failuresManish Goregaokar-2/+2
2020-07-28Make closures and generators a must use typesTomasz Miąsko-0/+22
Warn about unused expressions with closure or generator type. This follows existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn` traits, which already indirectly apply to closures in some cases, e.g.,: ```rust fn f() -> impl FnOnce() { || {} } fn main() { // an existing warning: unused implementer of `std::ops::FnOnce` that must be used: f(); // a new warning: unused closure that must be used: || {}; } ```
2020-07-27fix rebaseBastian Kauschke-2/+0
2020-07-27introduce PredicateAtomBastian Kauschke-9/+8
2020-07-27this might be unqualified, but at least it's now quantifiedBastian Kauschke-4/+4
2020-07-27split ignore_qualifiersBastian Kauschke-18/+8
2020-07-27`PredicateKint` -> `PredicateKind`, the beginning of the endBastian Kauschke-20/+26
2020-07-27progressBastian Kauschke-6/+9
2020-07-26report kind of deprecated item in messageAndy Russell-1/+1
This is important for fields, which are incorrectly referred to as "items".
2020-07-17Rollup merge of #74448 - davidtwco:improper-ctypes-definitions-boxes, ↵Manish Goregaokar-1/+12
r=davidtwco improper_ctypes_definitions: allow `Box` Addresses https://github.com/rust-lang/rust/pull/72700#issuecomment-659449386. This PR stops linting against `Box` in `extern "C" fn`s for the `improper_ctypes_definitions` lint - boxes are documented to be FFI-safe. cc @alexcrichton @CryZe
2020-07-17Rollup merge of #74438 - RalfJung:uninit-lint, r=davidtwcoManish Goregaokar-5/+23
warn about uninitialized multi-variant enums Fixes https://github.com/rust-lang/rust/issues/73608
2020-07-17Auto merge of #72983 - Lezzz:rename-typeck, r=nikomatsakisbors-41/+41
Rename TypeckTables to TypeckResults. Originally suggested by @eddyb.
2020-07-17improper_ctypes_definitions: allow `Box`David Wood-1/+12
This commit stops linting against `Box` in `extern "C" fn`s for the `improper_ctypes_definitions` lint - boxes are documented to be FFI-safe. Signed-off-by: David Wood <david@davidtw.co>
2020-07-17warn about uninit multi-variant enumsRalf Jung-5/+23
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-41/+41
2020-07-16apply bootstrap cfgsMark Rousskov-1/+0
2020-07-15Auto merge of #74175 - nnethercote:more-static-symbols, r=oli-obkbors-2/+5
More static symbols These commits add some more static symbols and convert lots of places to use them. r? @oli-obk
2020-07-15Remove lots of `Symbol::as_str()` calls.Nicholas Nethercote-2/+5
In various ways, such as changing functions to take a `Symbol` instead of a `&str`.
2020-07-14lint: use `transparent_newtype_field` to avoid ICEDavid Wood-16/+16
This commit re-uses the `transparent_newtype_field` function instead of manually calling `is_zst` on normalized fields to determine which field in a transparent type is the non-zero-sized field, thus avoiding an ICE. Signed-off-by: David Wood <david@davidtw.co>
2020-07-10Avoid "whitelist"Tamir Duberstein-2/+2
Other terms are more inclusive and precise.
2020-07-09Rollup merge of #74070 - eddyb:forall-tcx-providers, r=nikomatsakisManish Goregaokar-2/+2
Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>. In order to work around normalization-under-HRTB (for `provide!` in `rustc_metadata`), we ended up with this: ```rust struct Providers<'tcx> { type_of: fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` But what I initially wanted to do, IIRC, was this: ```rust struct Providers { type_of: for<'tcx> fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>, // ... } ``` This PR moves to the latter, for the simple reason that only the latter allows keeping a `Providers` value, or a subset of its `fn` pointer fields, around in a `static` or `thread_local!`, which can be really useful for custom drivers that override queries. (@jyn514 and I came across a concrete usecase of that in `rustdoc`) The `provide!` macro in `rustc_metadata` is fixed by making the query key/value types available as type aliases under `ty::query::query_{keys,values}`, not just associated types (this is the first commit). r? @nikomatsakis
2020-07-09Auto merge of #74131 - ollie27:rustdoc_invalid_codeblock_attributes_name, ↵bors-2/+2
r=GuillaumeGomez rustdoc: Rename invalid_codeblock_attribute lint to be plural Lint names should be plural as per the lint naming conventions: https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints r? @GuillaumeGomez
2020-07-07rustdoc: Rename invalid_codeblock_attribute lint to be pluralOliver Middleton-2/+2
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-2/+2
2020-07-03Use 'tcx for references to AccessLevels wherever possible.Eduard-Mihai Burtescu-144/+134
2020-07-02rustc_lint: avoid using TypeckTables::empty for LateContext.Eduard-Mihai Burtescu-21/+34
2020-06-30change `skip_binder` to use T by valueBastian Kauschke-1/+1
2020-06-28Rollup merge of #73817 - jumbatm:rename-to-clashing-extern-declarations, ↵Manish Goregaokar-10/+10
r=petrochenkov Rename clashing_extern_decl to clashing_extern_declarations. Rename clashing_extern_decl to clashing_extern_declarations to bring in-line with lint naming conventions. Fixes #73802. r? @petrochenkov
2020-06-27Rollup merge of #73758 - davidtwco:issue-60855-remaining-reveal-all, ↵Manish Goregaokar-62/+66
r=matthewjasper improper_ctypes: fix remaining `Reveal:All` Fixes #60855. This PR replaces the remaining uses of `ParamEnv::reveal_all` with `LateContext`'s `param_env` (normally `Reveal::UserFacing`) in the improper ctypes lint.
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-10/+10
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-26improper_ctypes: fix remaining `Reveal:All`David Wood-62/+66
This commit replaces the remaining uses of `ParamEnv::reveal_all` with `LateContext`'s `param_env` (normally `Reveal::UserFacing`). Signed-off-by: David Wood <david@davidtw.co>
2020-06-26Auto merge of #73743 - eddyb:lint-on-demand-typeck-tables, r=Manishearthbors-35/+80
rustc_lint: only query `typeck_tables_of` when a lint needs it. This was prompted by @jyn514 running into a situation where `rustdoc` wants to run the `unused_doc` lint without triggering type-checking (as an alternative to the "everybody loops" approach - type-checking may error/ICE because of the `rustdoc` feature of allowing multi-platform docs where the actual bodies of functions may refer to APIs for different platforms). There was also this comment in the source: ```rust // FIXME: Make this lazy to avoid running the TypeckTables query? ``` The main effect of this is for lint authors, who now need to use `cx.tables()` to get `&TypeckTables`, as opposed to having them always available in `cx.tables`. r? @oli-obk or @Manishearth
2020-06-25Rollup merge of #72770 - crlf0710:mixed_script_confusable, r=ManishearthManish Goregaokar-130/+226
Implement mixed script confusable lint. This implements the mixed script confusable lint defined in RFC 2457. This is blocked on #72069 and https://github.com/unicode-rs/unicode-security/pull/13, and will need a Cargo.toml version bump after those are resolved. The lint message warning is sub-optimal for now. We'll need a mechanism to properly output `AugmentScriptSet` to screen, this is to be added in `unicode-security` crate. r? @Manishearth
2020-06-26rustc_lint: only query `typeck_tables_of` when a lint needs it.Eduard-Mihai Burtescu-35/+80
2020-06-26Implement mixed script confusable lint.Charles Lew-3/+126
2020-06-24improper_ctypes: only allow params in defns modeDavid Wood-2/+8
This commit adjusts the behaviour introduced in a previous commit so that generic parameters and projections are only allowed in the definitions mode - and are otherwise a bug. Generic parameters in declarations are prohibited earlier in the compiler, so if that branch were reached, it would be a bug. Signed-off-by: David Wood <david@davidtw.co>
2020-06-24improper_ctypes: allow pointers to sized typesDavid Wood-1/+10
This commit changes the improper ctypes lint (when operating on definitions) to consider raw pointers or references to sized types as FFI-safe. Signed-off-by: David Wood <david@davidtw.co>
2020-06-24lints: add `improper_ctypes_definitions`David Wood-27/+83
This commit adds a new lint - `improper_ctypes_definitions` - which functions identically to `improper_ctypes`, but on `extern "C" fn` definitions (as opposed to `improper_ctypes`'s `extern "C" {}` declarations). Signed-off-by: David Wood <david@davidtw.co>
2020-06-23Refactor non_ascii_idents lints, exclude ascii pair for confusable_idents lint.Charles Lew-131/+104
2020-06-21Make is_freeze and is_copy_modulo_regions take TyCtxtAtRalf Jung-1/+1
2020-06-21Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisabors-5/+228
Add a lint to catch clashing `extern` fn declarations. Closes #69390. Adds lint `clashing_extern_decl` to detect when, within a single crate, an extern function of the same name is declared with different types. Because two symbols of the same name cannot be resolved to two different functions at link time, and one function cannot possibly have two types, a clashing extern declaration is almost certainly a mistake. This lint does not run between crates because a project may have dependencies which both rely on the same extern function, but declare it in a different (but valid) way. For example, they may both declare an opaque type for one or more of the arguments (which would end up distinct types), or use types that are valid conversions in the language the extern fn is defined in. In these cases, we can't say that the clashing declaration is incorrect. r? @eddyb
2020-06-20lint: normalize projections using opaque typesDavid Wood-8/+19
This commit normalizes projections which contain opaque types (opaque types are otherwise linted against, which is would have previously made the test cases added in this commit fail). Signed-off-by: David Wood <david@davidtw.co>
2020-06-20Add ClashingExternDecl lint.jumbatm-5/+228
This lint checks that all declarations for extern fns of the same name are declared with the same types.
2020-06-19Rollup merge of #73300 - crlf0710:crate_level_only_check, r=petrochenkovManish Goregaokar-7/+51
Implement crate-level-only lints checking. This implements a crate_level_only flag on lints, and when it is true, it becomes an error when user tries to specify this flag upon nodes other than crate node. This also turns on this flag for all non_ascii_ident lints.
2020-06-19Rollup merge of #73257 - davidtwco:issue-73249-improper-ctypes-projection, ↵Manish Goregaokar-136/+104
r=lcnr,varkor ty: projections in `transparent_newtype_field` Fixes #73249. This PR modifies `transparent_newtype_field` so that it handles projections with generic parameters, where `normalize_erasing_regions` would ICE.
2020-06-19ty: simplify `transparent_newtype_field`David Wood-1/+1
This commit removes the normalization from `transparent_newtype_field` - turns out it wasn't necessary and that makes it a bunch simpler - particularly when handling projections. Signed-off-by: David Wood <david@davidtw.co>
2020-06-19lint: unify enum variant, union and struct logicDavid Wood-125/+82
This commit applies the changes introduced in #72890 to both enum variants and unions - where the logic prior to #72890 was duplicated. Signed-off-by: David Wood <david@davidtw.co>