about summary refs log tree commit diff
path: root/src/test/ui/lint
AgeCommit message (Collapse)AuthorLines
2020-09-03specialization_graph: avoid trimmed paths for OverlapErrorDan Aloni-6/+6
2020-09-02pretty: trim paths of unique symbolsDan Aloni-59/+59
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-08-30Point to no_mangle/export_name attribute when lintingWim Looman-16/+16
2020-08-30Add note about why no_mangle and export_name are unsafeWim Looman-0/+11
2020-08-30Scope no_mangle and export_name warnings to the declarations nameWim Looman-16/+16
2020-08-30Add checking for export_name to unsafe_code lintWim Looman-19/+61
2020-08-30Add checking for no_mangle to unsafe_code lintWim Looman-20/+60
2020-08-30Rollup merge of #75885 - ↵Dylan DPC-14/+89
jumbatm:issue75739-clashing-extern-declarations-transparent-nonzero, r=lcnr Fix another clashing_extern_declarations false positive. Fixes #75739. Fix another clashing_extern_declarations false positive, this time for transparent newtype with a non-zero member. r? @lcnr
2020-08-27Fix ICE on unwrap of unknown layout.jumbatm-0/+23
2020-08-25Also handle transparent single-variant enumsjumbatm-14/+33
2020-08-25Fix clashing_extern_declarations false positive.jumbatm-2/+58
Fixes a false positive for transparent newtype with a non-zero member.
2020-08-19Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r=lcnrYuki Okushi-0/+119
Fix clashing_extern_declarations stack overflow for recursive types. Fixes #75512. Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
2020-08-18Promote missing_fragment_specifier to hard errorAleksey Kladov-22/+4
It has been deny_by_default since 2017 (and warned for some time before that), so it seems reasonable to promote it. The specific technical motivation to do this now is to remove a field from `ParseSess` -- it is a global state, and global state makes extracting libraries annoying. Closes #40107
2020-08-18Actually introduce a cycle in Reffy test.jumbatm-4/+6
2020-08-18Add test demonstrating the issue.jumbatm-0/+117
2020-08-11Rollup merge of #75359 - lcnr:unused-delims-trim, r=oli-obkYuki Okushi-5/+5
unused_delims: trim expr improves rustfix output.
2020-08-10unused_delims: trim exprBastian Kauschke-5/+5
2020-08-10Fix symbol ordering for confusable idents detection.Nicholas Nethercote-2/+13
Confusable idents detection uses a type `BTreeMap<Symbol, Span>`. This is highly dubious given that `Symbol` doesn't guarantee a meaningful order. (In practice, it currently gives an order that mostly matches source code order.) As a result, changes in `Symbol` representation make the `lint-confusable-idents.rs` test fail, because this error message: > identifier pair considered confusable between `s` and `s` is changed to this: > identifier pair considered confusable between `s` and `s` and the corresponding span pointers get swapped erroneously, leading to an incorrect "previous identifier" label. This commit sorts the relevant symbols by span before doing the checking, which ensures that the ident that appears first in the code will be mentioned first in the message. The commit also extends the test slightly to be more thorough.
2020-08-03Do not trigger `unused_braces` for `while let`Yuki Okushi-24/+17
2020-08-02Rollup merge of #75059 - shengsheng:typos, r=Dylan-DPCManish Goregaokar-2/+2
fix typos Fix common misspellings with https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-08-02Rollup merge of #75031 - JohnTitor:unused-parens-braces-yield, r=lcnrManish Goregaokar-0/+95
Do not trigger `unused_{braces,parens}` lints with `yield` Fixes #74883 r? @lcnr
2020-08-03Recover strictness for `yield`Yuki Okushi-7/+59
2020-08-02fix typosliuzhenyu-2/+2
2020-08-02Auto merge of #74785 - euclio:deprecation-kinds, r=petrochenkovbors-404/+404
report kind of deprecated item in message This is important for fields, which are incorrectly referred to as "items".
2020-08-02Do not trigger `unused_{braces,parens}` lints with `yield`Yuki Okushi-0/+43
2020-07-30Fix missed same-sized member clash in ClashingExternDeclarations.jumbatm-7/+41
2020-07-30Address code review comments.jumbatm-6/+23
- Make `is_repr_nullable_ptr` freestanding again to avoid usage of ImproperCTypesVisitor in ClashingExternDeclarations (and don't accidentally revert the ParamEnv::reveal_all() fix from a week earlier) - Revise match condition for 1 Adt, 1 primitive - Generalise check for non-null type so that it would also work for ranges which exclude any single value (all bits set, for example) - Make is_repr_nullable_ptr return the representable type instead of just a boolean, to avoid adding an additional, independent "source of truth" about the FFI-compatibility of Option-like enums. Also, rename to `repr_nullable_ptr`.
2020-07-30Apply suggested wording changes from code review.jumbatm-4/+4
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-1/+61
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-30Add additional clashing_extern_decl cases.jumbatm-62/+124
2020-07-26report kind of deprecated item in messageAndy Russell-404/+404
This is important for fields, which are incorrectly referred to as "items".
2020-07-20wf: check foreign fn decls for well-formednessDavid Wood-32/+33
This commit extends current well-formedness checking to apply to foreign function declarations, re-using the existing machinery for regular functions. In doing this, later parts of the compiler (such as the `improper_ctypes` lint) can rely on being operations not failing as a result of invalid code which would normally be caught earlier. Signed-off-by: David Wood <david@davidtw.co>
2020-07-17Rollup merge of #74448 - davidtwco:improper-ctypes-definitions-boxes, ↵Manish Goregaokar-63/+46
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-17improper_ctypes_definitions: allow `Box`David Wood-63/+46
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-36/+73
2020-07-14lint: use `transparent_newtype_field` to avoid ICEDavid Wood-0/+14
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-06Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebankManish Goregaokar-118/+477
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-118/+477
2020-07-01Rollup merge of #73839 - crlf0710:snapshot_the_reality, r=ManishearthManish Goregaokar-16/+189
Split and expand nonstandard-style lints unicode unit test. RFC 2457 requested that the `nonstandard_style` series of linted be adjusted to cover the non_ascii_identifier case. However when i read the code of those implementations, it seems they're already supporting non_ascii_identifiers. But the exact rules is a little different than what's proposed in RFC 2457. So I splitted and expanded the existing test case to try to exercise every branch in the code. I think it'll also be easier to examine the cases in these unit tests to see whether it's ok to just leave them as is, or some adjustments are needed. r? @Manishearth
2020-06-28Split and expand nonstandard-style lints unicode unit test.Charles Lew-16/+189
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-43/+70
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-147/+148
propagation
2020-06-25Rollup merge of #72770 - crlf0710:mixed_script_confusable, r=ManishearthManish Goregaokar-22/+89
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-26Implement mixed script confusable lint.Charles Lew-0/+69
2020-06-24improper_ctypes: allow pointers to sized typesDavid Wood-84/+24
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-0/+433
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-22/+20
2020-06-21Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisabors-6/+290
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-0/+108
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-20Update existing test cases.jumbatm-24/+25
- Allow ClashingExternDecl for lint-dead-code-3 - Update test case for #5791 - Update test case for #1866 - Update extern-abi-from-macro test case