409 Commits

Author SHA1 Message Date
mark
10ee0f68a6 Allow by default, fix tests 2018-07-23 21:55:51 -05:00
mark
2a7ae04a68 Extend ParseSess to support buffering lints 2018-07-23 21:54:43 -05:00
Zack M. Davis
41d5c0ce1f in which the elided-lifetimes-in-paths lint undergoes a revolution
The existing elided-lifetimes-in-paths lint (introduced in Nov. 2017's
accd997b5 / #46254) lacked stuctured suggestions and—much more
alarmingly—produced false positives on associated functions (like
`Ref::clone`) and on anonymous '_ lifetimes (!!—yes, the very
anonymous lifetimes that we meant to suggest "instead"). That this
went apparently unnoticed for so long maybe tells you something about
how many people actually bother to flip on allow-by-default lints.

After many hours of good old-fashioned American elbow grease—and a
little help from expert reviewers—it turns out that getting the right
answer is a lot easier if we fire the lint while lowering the Higher
Intermediate Representation.

The lint is promoted to the idioms-2018 group.

Also, in the matter of test filenames, "elided" only has one 'l' (see,
e.g., https://en.wiktionary.org/wiki/elide).

Resolves #52041.
2018-07-22 08:27:10 -07:00
Oliver Schneider
2f7edccb03 Don't invent new magic keywords 2018-07-21 12:36:18 +02:00
Oliver Schneider
b6e0547680 Allow individual lints to opt into being reported in external macros 2018-07-20 22:45:52 +02:00
Alex Crichton
0b969a9d68 rustc: Lint against #[macro_use] in 2018 idioms
This commit adds a lint to the compiler to warn against the `#[macro_use]`
directive as part of the `rust_2018_idioms` lint. This lint is turned off by
default and is only enabled when the `use_extern_macros` feature is also
enabled.

The lint here isn't fully fleshed out as it's just a simple warning rather than
suggestions of how to actually import the macro, but hopefully it's a good base
to start from!

cc #52043
2018-07-12 14:10:39 -07:00
Vadim Petrochenkov
fc74e35981 Remove fallback to parent modules from lexical resolution 2018-07-08 18:16:09 +03:00
bors
309fd8a6fb Auto merge of #49469 - Nokel81:allow-irrefutable-let-patterns, r=nikomatsakis
Implementation of RFC 2086 - Allow Irrefutable Let patterns

This is the set of changes for RFC2086. Tracking issue #44495. Rendered [here](https://github.com/rust-lang/rfcs/pull/2086)
2018-06-26 09:20:33 +00:00
leonardo.yvens
a602654a6e Make where clause object safety be a warn-by-default lint 2018-06-25 06:57:08 -03:00
Guillaume Gomez
d2a4e42959 Rename intra-doc lint 2018-06-13 23:30:34 +02:00
Guillaume Gomez
b000cf0726 Add lint for intra link resolution failure 2018-06-09 14:07:25 +02:00
Mark Rousskov
898bb78024
Rollup merge of #51401 - estebank:warn-repr, r=cramertj
Warn on `repr` without hints

Fix #51376.
2018-06-08 17:21:05 -06:00
Esteban Küber
3580de8c6d Turn warning into lint 2018-06-06 14:11:48 -07:00
Sebastian Malton
4fe40635ef Implementation of RFC 2086 - Allow Irrefutable Let patterns 2018-06-05 10:19:21 -04:00
Vadim Petrochenkov
11c283cdfc Prohibit duplicate macro_exports 2018-05-30 16:15:35 +03:00
Vadim Petrochenkov
e60eaf59df Fix naming conventions for new lints 2018-05-25 02:35:07 +03:00
F001
c3322556f5 Fix according to comments 2018-05-20 10:16:33 +08:00
F001
4bb39966a6 re-implement 2018-05-20 10:16:33 +08:00
bors
1b240dad06 Auto merge of #50763 - KyleStach1678:unused-loop-label, r=petrochenkov
Add lint checks for unused loop labels

Previously no warning was generated when a loop label was written out but never used (i.e. in a `break` or `continue` statement):
```rust
fn main() {
    'unused_label: loop {}
}
```
would compile without complaint.

This fix introduces `-W unused_loop_label`, which generates the following warning message for the above snippet:
```
warning: unused loop label
 --> main.rs:2:5
  |
2 |     'unused_label: loop {}
  |     ^^^^^^^^^^^^^
  |
  = note: #[warn(unused_loop_label)] on by default
```

Fixes: #50751.
2018-05-19 14:52:30 +00:00
bors
ef8ee64774 Auto merge of #50760 - petrochenkov:legimp, r=nikomatsakis
Turn deprecation lint `legacy_imports` into a hard error

Closes https://github.com/rust-lang/rust/issues/38260

The lint was introduced in Dec 2016, then made deny-by-default in Jun 2017 when crater run found 0 regressions caused by it.

This lint requires some not entirely trivial amount of import resolution logic that (surprisingly or not) interacts with `feature(use_extern_macros)` (https://github.com/rust-lang/rust/issues/35896), so it would be desirable to remove it before stabilizing `use_extern_macros`.
In particular, this PR fixes the failing example in https://github.com/rust-lang/rust/issues/50725 (but not the whole issue, `use std::panic::{self}` still can cause other undesirable errors when `use_extern_macros` is enabled).
2018-05-19 12:16:50 +00:00
Kyle Stachowicz
6da64a7666 Default unused_labels to allow, move to "unused" 2018-05-18 16:57:16 -07:00
Kyle Stachowicz
88f4063c83 Reimplement unused_labels lint as a compiler builtin in the resolver 2018-05-18 16:57:15 -07:00
bors
a722296b6e Auto merge of #50653 - oli-obk:bad_const, r=cramertj
Make the `const_err` lint `deny`-by-default

At best these things are runtime panics (debug mode) or overflows (release mode). More likely they are public constants that are unused in the crate declaring them.

This is not a breaking change, as dependencies won't break and root crates can `#![warn(const_err)]`, though I don't know why anyone would do that.
2018-05-18 17:17:35 +00:00
Alex Crichton
dff9ee1d74 rustc: Fix crate lint for single-item paths
This commit fixes recommending the `crate` prefix when migrating to 2018 for
paths that look like `use foo;` or `use {bar, baz}`

Closes #50660
2018-05-15 08:05:34 -07:00
Vadim Petrochenkov
d1b027421e Turn deprecation lint legacy_imports into a hard error 2018-05-15 02:25:04 +03:00
Oliver Schneider
1788af357a
Make the const_err lint deny-by-default 2018-05-12 16:21:02 +02:00
bors
4e5a155a93 Auto merge of #50440 - nikomatsakis:single-use-lifetimes, r=cramertj
Improve single-use and zero-use lifetime lints

The code now correctly identifies *when* to lint -- or more correctly, anyhow -- but it doesn't yet offer suggestions for how to fix.

(I just remembered when writing this I had meant to go back over some of these cases around e.g. impl Trait and double check that everything is right...)

cc #44752

r? @cramertj
2018-05-11 02:14:25 +00:00
bors
295d98069f Auto merge of #50390 - hdhoang:46205_deny_by_default, r=nikomatsakis
lint: deny incoherent_fundamental_impls by default

Warn the ecosystem of the pending intent-to-disallow in #49799.

There are 4 ICEs on my machine, look unrelated (having happened before in https://github.com/rust-lang/rust/issues/49146#issuecomment-384473523)

```rust
thread 'main' panicked at 'assertion failed: position <= slice.len()', libserialize/leb128.rs:97:1
```

```
    [run-pass] run-pass/allocator/xcrate-use2.rs
    [run-pass] run-pass/issue-12133-3.rs
    [run-pass] run-pass/issue-32518.rs
    [run-pass] run-pass/trait-default-method-xc-2.rs
```

r? @nikomatsakis
2018-05-08 04:56:01 +00:00
Manish Goregaokar
baa7b32d4b Mark lints with applicability 2018-05-04 14:31:26 -07:00
Niko Matsakis
0a9dcaf04f add warnings for unused lifetime parameters 2018-05-04 05:54:01 -04:00
Hoàng Đức Hiếu
2885b9e35a lint: deny incoherent_fundamental_impls by default
Warn the ecosystem of the pending intent-to-disallow in #49799.
2018-05-02 17:30:26 +07:00
Manish Goregaokar
f56c61face Add suggestion to lint 2018-04-20 15:59:00 -07:00
Manish Goregaokar
37d3bea3ec Add ABSOLUTE_PATH_STARTING_WITH_MODULE epoch lint for path breakage 2018-04-20 15:58:59 -07:00
kennytm
abf4d8babf
When picking a candidate, consider the unstable ones last.
If there is potential ambiguity after stabilizing those candidates, a
warning will be emitted.
2018-03-24 06:58:01 +08:00
Andrew Cann
59688e119e Make coerce_never lint an error
Remove the coerce_never lint and make the behaviour an error.
2018-03-14 12:44:51 +08:00
Andrew Cann
9b15ddb29e remove defaulting to unit
Types will no longer default to `()`, instead always defaulting to `!`.
This disables the associated warning and removes the flag from TyTuple
2018-03-14 12:44:51 +08:00
Manish Goregaokar
197f35c3e0 Make bare_trait_lint allow for now 2018-03-08 17:10:05 -08:00
Manish Goregaokar
4338bd178d Move epochs to libsyntax 2018-03-08 17:10:03 -08:00
Oliver Schneider
28572d2c1f
Nuke the entire ctfe from orbit, it's the only way to be sure 2018-03-08 08:08:14 +01:00
Manish Goregaokar
0cb367266b
Emit parentheses in suggestion for global paths 2018-02-27 19:24:16 -08:00
Manish Goregaokar
bd29696218 Add ability for hardwired lints to operate on the diagnostic builder 2018-02-23 08:24:49 -08:00
Manish Goregaokar
3eeabe7b7d Add hardwired lint for dyn trait 2018-02-23 08:24:07 -08:00
dpc
accd997b54 add ellided lifetime 2018-02-02 02:10:10 +05:30
Carol (Nichols || Goulding)
90fcd4476c
Reexport -> re-export in error messages 2018-01-15 13:36:52 -05:00
Michael Hewson
0783db9e0f Convert warning about *const _ to a future-compat lint 2017-12-22 07:05:09 -05:00
Niko Matsakis
e741dad629 adding lint for single use lifetime names 2017-12-20 00:07:10 +05:30
Ariel Ben-Yehuda
425c2c3606 convert errors to warnings 2017-12-06 00:43:47 +02:00
Ariel Ben-Yehuda
2614cc51dd convert the new conflicts to a soft error 2017-12-05 15:42:33 +02:00
Ariel Ben-Yehuda
5a00b7cb74 make coercions to ! in unreachable code a hard error
This was added to cover up a lazy extra semicolon in #35849, but does
not actually make sense. This is removed as a part of the stabilization
of `never_type`.
2017-11-30 15:18:25 +02:00
Ariel Ben-Yehuda
1a2d443f55 make accessing packed fields a future-compat warning 2017-11-26 16:12:42 +02:00