Commit graph

73 commits

Author SHA1 Message Date
bors 0d033dee3e Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`
2020-10-30 22:53:55 +00:00
Joshua Nelson bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
LeSeulArtichaut 9433eb83fe Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut 4fe735b320 TypeVisitor: use ControlFlow in rustc_{infer,lint,trait_selection} 2020-10-30 12:27:34 +01:00
Jonas Schievink 31cfe63fb9
Rollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebank
Prefer new associated numeric consts in float error messages

Fix https://github.com/rust-lang/rust/issues/78382
2020-10-29 17:05:21 +01:00
Jonas Schievink 9867e54bea
Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor
Dogfood {exclusive,half-open} ranges in compiler (nfc)

In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-29 17:05:11 +01:00
Jubilee Young 0e88db7db4 Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.
2020-10-28 20:09:20 -07:00
Rustin-Liu 650e3cb176 Prefer new associated numeric consts in float error messages 2020-10-27 14:14:08 +08:00
Nathan Whitaker 6ba127d3f0 Fix doctest 2020-10-26 18:19:49 -04:00
Nathan Whitaker 576eb2a30c Write docs for lint / fix review nit 2020-10-26 18:19:48 -04:00
Nathan Whitaker 1bcd2452fe Address review comments 2020-10-26 18:19:48 -04:00
Nathan Whitaker 737bfeffd2 Change to warn by default / fix typo 2020-10-26 18:19:48 -04:00
Nathan Whitaker 5643a0662a Tweak diagnostic 2020-10-26 18:19:47 -04:00
Nathan Whitaker 8b65df06ce Address review comments 2020-10-26 18:19:47 -04:00
Nathan Whitaker 8cf1b0e1ad Uplift temporary-cstring-as-ptr into rustc 2020-10-26 18:19:40 -04:00
Aaron Hill ac384ac2db
Fix inconsistencies in handling of inert attributes on statements
When the 'early' and 'late' visitors visit an attribute target, they
activate any lint attributes (e.g. `#[allow]`) that apply to it.
This can affect warnings emitted on sibiling attributes. For example,
the following code does not produce an `unused_attributes` for
`#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed
the warning.

```rust
trait Foo {
    #[allow(unused_attributes)] #[inline] fn first();
    #[inline] #[allow(unused_attributes)] fn second();
}
```

However, we do not do this for statements - instead, the lint attributes
only become active when we visit the struct nested inside `StmtKind`
(e.g. `Item`).

Currently, this is difficult to observe due to another issue - the
`HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`.
As a result, the `unused_doc_comments` lint will never see attributes on
item statements.

This commit makes two interrelated fixes to the handling of inert
(non-proc-macro) attributes on statements:

* The `HasAttr` impl for `StmtKind` now returns attributes for
  `StmtKind::Item`, treating it just like every other `StmtKind`
  variant. The only place relying on the old behavior was macro
  which has been updated to explicitly ignore attributes on item
  statements. This allows the `unused_doc_comments` lint to fire for
  item statements.
* The `early` and `late` lint visitors now activate lint attributes when
  invoking the callback for `Stmt`. This ensures that a lint
  attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to
  sibiling attributes on an item statement.

For now, the `unused_doc_comments` lint is explicitly disabled on item
statements, which preserves the current behavior. The exact locatiosn
where this lint should fire are being discussed in PR #78306
2020-10-24 11:55:48 -04:00
Yuki Okushi 59ae7957b0
Rollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwco
Fix two small issues in compiler/rustc_lint/src/types.rs

Two small improvements of `compiler/rustc_lint/src/types.rs`
2020-10-22 09:45:38 +09:00
est31 00d23cf220 Make {u,}int_range functions a bit nicer
.into() guarantees safety of the conversion.
Furthermore, the minimum value of all uints is known to be 0.
2020-10-20 19:36:44 +02:00
est31 c647735f40 rustc_lint: remove unused to_string
In this instance, we can just pass a &str slice
and save an allocation.
2020-10-20 19:30:09 +02:00
Yuki Okushi 378ca5e640
Rollup merge of #77931 - aticu:fix_60336, r=petrochenkov
Fix false positive for `unused_parens` lint

Fixes #60336
2020-10-20 12:11:06 +09:00
bors 834821e3b6 Auto merge of #78066 - bugadani:wat, r=jonas-schievink
Clean up small, surprising bits of code

This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18 13:50:31 +00:00
Dániel Buga 2e99439900 Replace unnecessary map_or_else with map_or 2020-10-18 11:01:09 +02:00
bors 6af9846fcc Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk
Implement const expressions and patterns (RFC 2920)

cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`
2020-10-17 14:44:51 +00:00
Santiago Pastorino 547e5eb498
Do not check unused braces on inline consts 2020-10-16 17:14:37 -03:00
Santiago Pastorino 03defb627c
Add check_generic_arg early pass 2020-10-16 17:14:36 -03:00
Yuki Okushi f7150be674 Suggest minimal subset features in incomplete_features lint 2020-10-17 02:01:08 +09:00
est31 4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
est31 215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
aticu 39867f3c9f Fixed false positive for unused_parens lint 2020-10-14 01:16:40 +02:00
bors 8ae3b50976 Auto merge of #77119 - GuillaumeGomez:unclosed-html-tag-lint, r=jyn514
Unclosed html tag lint

Part of #67799.

I think `@ollie27` will be interested (`@Manishearth` too since they opened the issue ;) ).

r? `@jyn514`
2020-10-07 09:56:51 +00:00
Matthew Jasper f958e6c246 Separate bounds and predicates for associated/opaque types 2020-10-06 11:19:29 +01:00
Felix S. Klock II afa2a67545 Prevent forbid from being ignored if overriden at the same level.
That is, this changes `#[forbid(foo)] #[allow(foo)]` from allowing foo to
forbidding foo.
2020-10-04 13:14:01 -04:00
Guillaume Gomez e6027a42e1 Add unclosed_html_tags lint 2020-10-03 14:16:23 +02:00
Michael Howell cd159fd7f9 Uplift drop-bounds lint from clippy 2020-10-01 12:06:33 -07:00
Joshua Nelson 03d8be0896 Separate private_intra_doc_links and broken_intra_doc_links into separate lints
This is not ideal because it means `deny(broken_intra_doc_links)` will
no longer `deny(private_intra_doc_links)`. However, it can't be fixed
with a new lint group, because `broken` is already in the `rustdoc` lint
group; there would need to be a way to nest groups somehow.

This also removes the early `return` so that the link will be generated
even though it gives a warning.
2020-09-27 09:58:29 -04:00
Ralf Jung 9e02642fb3
Rollup merge of #77211 - est31:remove_unused_allow, r=oli-obk
Remove unused #[allow(...)] statements from compiler/
2020-09-26 12:58:34 +02:00
est31 12187b7f86 Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
marmeladema bb8e1764bb Simplify some match statements on `DefPathDataName' 2020-09-25 22:46:15 +01:00
marmeladema 657ecdb75e Rename DefPathData::get_name() to DefPathData::name() 2020-09-25 22:46:15 +01:00
marmeladema f1878d19fa Move from {{closure}}#0 syntax to {closure#0} for (def) path components 2020-09-25 22:46:14 +01:00
Jonas Schievink 6f3da3d53f
Rollup merge of #77121 - duckymirror:html-root-url, r=jyn514
Updated html_root_url for compiler crates

Closes #77103

r? @jyn514
2020-09-25 02:29:45 +02:00
Erik Hofmayer 138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
Dylan DPC bcdbe79f0c
Rollup merge of #76994 - yuk1ty:fix-small-typo, r=estebank
fix small typo in docs and comments

Fixed `the the` to `the`, as far as I found.
2020-09-23 14:54:07 +02:00
ecstatic-morse 0863f9a965
Rollup merge of #77032 - lcnr:visit-all-the-item-likes, r=davidtwco
lint missing docs for extern items

fixes #76991
2020-09-21 20:41:01 -07:00
ecstatic-morse 50d4aebc7a
Rollup merge of #76914 - lcnr:path-no-more, r=ecstatic-morse
extend `Ty` and `TyCtxt` lints to self types

blocked on #76891

r? @ecstatic-morse cc @Aaron1011
2020-09-21 20:40:57 -07:00
Bastian Kauschke d452744100 lint missing docs for extern items 2020-09-22 00:02:46 +02:00
Bastian Kauschke 8fc782afc2 add test 2020-09-21 20:36:05 +02:00
yuk1ty 16047d46a1 fix typo in docs and comments 2020-09-21 12:14:28 +09:00
Ralf Jung 7ff17c13bc
Rollup merge of #76910 - lcnr:foreign-item-like, r=oli-obk
transmute: use diagnostic item

closes #66075, we now have no remaining uses of `match_def_path`  in the compiler while some uses still remain in `clippy`.

cc @RalfJung
2020-09-20 15:52:04 +02:00