Commit Graph

2366 Commits

Author SHA1 Message Date
bors
9b4154193e Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco
use sort_unstable to sort primitive types

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
2020-09-14 21:43:17 +00:00
bors
b5f55b7e15 Auto merge of #76549 - ehuss:lints-comments, r=wesleywiser
Auto-generate lint documentation.

This adds a tool which will generate the lint documentation in the rustc book automatically. This is motivated by keeping the documentation up-to-date, and consistently formatted. It also ensures the examples are correct and that they actually generate the expected lint. The lint groups table is also auto-generated. See https://github.com/rust-lang/compiler-team/issues/349 for the original proposal.

An outline of how this works:
- The `declare_lint!` macro now accepts a doc comment where the documentation is written. This is inspired by how clippy works.
- A new tool `src/tools/lint-docs` scrapes the documentation and adds it to the rustc book during the build.
    - It runs each example and verifies its output and embeds the output in the book.
    - It does a few formatting checks.
    - It verifies that every lint is documented.
- Groups are collected from `rustc -W help`.

I updated the documentation for all the missing lints. I have also added an "Explanation" section to each lint providing a reason for the lint and suggestions on how to resolve it.

This can lead towards a future enhancement of possibly showing these docs via the `--explain` flag to make them easily accessible and discoverable.
2020-09-14 05:54:44 +00:00
Eric Huss
45c1e0ae07 Auto-generate lint documentation. 2020-09-13 08:48:03 -07:00
Matthias Krüger
b4935e0726 use sort_unstable to sort primitive types
It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
2020-09-10 00:03:58 +02:00
Bram van den Heuvel
7dad29d686 Remove def_id field from ParamEnv 2020-09-09 10:14:31 +02:00
LeSeulArtichaut
3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
Dan Aloni
e7d7615105 rustc_lint: avoid trimmed paths for ty_find_init_error 2020-09-03 14:36:58 +03:00
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
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-09-02 22:26:37 +03:00
Wim Looman
fc8a3ad66c Update for moved function from #74932 2020-08-30 21:51:30 +02:00
Wim Looman
7636de33cf Point to no_mangle/export_name attribute when linting 2020-08-30 20:16:23 +02:00
Wim Looman
9ed3661427 Add note about why no_mangle and export_name are unsafe 2020-08-30 20:16:23 +02:00
Wim Looman
79b0ab5195 Scope no_mangle and export_name warnings to the declarations name 2020-08-30 20:16:23 +02:00
Wim Looman
66b2f9acfc Add checking for export_name to unsafe_code lint 2020-08-30 20:16:22 +02:00
Wim Looman
06a0269c11 Add checking for no_mangle to unsafe_code lint 2020-08-30 20:16:22 +02:00
David Wood
0f2bd56b29
lint/ty: move fns to avoid abstraction violation
This commit moves `transparent_newtype_field` and `is_zst` to
`LateContext` where they are used, rather than being on the `VariantDef`
and `TyS` types.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-30 18:57:46 +01:00
mark
9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00