Commit Graph

1206 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
0592d13757
Rollup merge of #64472 - Mark-Simulacrum:unused-parens-attr, r=varkor
Don't mark expression with attributes as not needing parentheses

This is not perfectly correct as `#[attr] (5)` will still not lint, but it does seem good enough, in particular as the parentheses in that case are not unambiguously incorrect; I might personally prefer to see them for clarity.

Fixes https://github.com/rust-lang/rust/issues/43279.
2019-09-15 19:36:01 +02:00
bors
117cdf35d4 Auto merge of #64469 - matthewjasper:increase-hygiene-use, r=petrochenkov
Cleanup handling of hygiene for built-in macros

This makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms.

* `ExtCtxt::ident_of` now takes a `Span` and is preferred to `Ident::{from_str, from_str_and_span}`
* Remove `Span::with_legacy_ctxt`
    * `assert` now uses call-site hygiene because it needs to resolve `panic` unhygienically.
    * `concat_idents` now uses call-site hygiene because it wouldn't be very useful with def-site hygiene.
    * everything else is moved to def-site hygiene

r? @petrochenkov
2019-09-15 08:17:57 +00:00
Matthew Jasper
e8d2f62924 Prefer Symbol to Ident when there's no sensible Span 2019-09-15 09:15:37 +01:00
Mark Rousskov
a0e48b6d25 Warn on no_start, crate_id attribute use
These attributes are now deprecated; they don't have any use anymore.
2019-09-14 19:43:39 -04:00
Mark Rousskov
1d33f06de8 Don't mark expression with attributes as not needing parentheses
This is not perfectly correct as `#[attr] (5)` will still not lint, but
it does seem good enough, in particular as the parentheses in that case
are not unambiguously incorrect.
2019-09-14 18:43:48 -04:00
bors
eb48d6bdee Auto merge of #64359 - varkor:opaque-ty-in-extern, r=estebank
Forbid opaque types in `extern "C"` blocks

Fixes #64338.
2019-09-12 12:40:31 +00:00
varkor
9d712177a3 Refactor "not FFI-safe" diagnostic 2019-09-10 22:29:31 +01:00
varkor
79368db1ce Surround PhantomData in backticks 2019-09-10 19:52:35 +01:00
varkor
df7e496f85 Forbid opaque types in extern blocks 2019-09-10 18:16:35 +01:00
varkor
740dd4bf05 Add unexpected type to extern type bug message 2019-09-10 15:11:05 +01:00
Mazdak Farrokhzad
4ea77975ab
Rollup merge of #64066 - petrochenkov:softstab, r=matthewjasper
Support "soft" feature-gating using a lint

Use it for feature-gating `#[bench]`.

Closes https://github.com/rust-lang/rust/issues/63798.
2019-09-08 00:07:31 +02:00
Vadim Petrochenkov
74d8679eff Turn soft_unstable into a future-compatibility lint 2019-09-07 22:23:53 +03:00
Mazdak Farrokhzad
89a69fd76d
Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=petrochenkov
Migrate internal diagnostic registration to macro_rules

Review is best done commit-by-commit.

Fixes #64132.
2019-09-07 20:01:44 +02:00
Mark Rousskov
41b39fce98 Remove rustc_diagnostic_macros feature 2019-09-05 12:35:18 -04:00
Mark Rousskov
b437240cee Replace diagnostic plugins with macro_rules 2019-09-05 12:35:15 -04:00
Mazdak Farrokhzad
16ba5029a1 or-patterns: fix fallout from #664128. 2019-09-05 09:17:19 +02:00
Mazdak Farrokhzad
3fccbac4d3 or-patterns: adjust librustc_lint. 2019-09-05 08:33:09 +02:00
Mazdak Farrokhzad
e85b181638 unused_parens: fix for or-patterns + &(mut x) 2019-09-03 15:33:30 +02:00
Oliver Scherer
26e9990198 Add a "diagnostic item" scheme
This allows lints and other diagnostics to refer to items
by a unique ID instead of relying on whacky path
resolution schemes that may break when items are
relocated.
2019-08-30 01:00:55 +02:00
Caio
6a3d517314 Modifies how Arg, Arm, Field, FieldPattern and Variant are visited
Part of the necessary work to accomplish #63468.
2019-08-24 13:54:40 -03:00
Simon Sapin
d0bbc6062d Deprecate using rustc_plugin without the rustc_driver dylib.
CC https://github.com/rust-lang/rust/pull/59800
7198687bb2

Fix https://github.com/rust-lang/rust/issues/62717
2019-08-20 00:21:32 +02:00
Ralf Jung
72d9fe8b0e less & 2019-08-17 16:48:08 +02:00
Ralf Jung
f19087dd7c drift leftward 2019-08-17 13:50:04 +02:00
Ralf Jung
4821663a2b
Full stop
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-08-17 13:42:03 +02:00
Ralf Jung
a9efa738ab invalid_value: also detect transmute-from-0 (seen in the wild) 2019-08-17 11:57:01 +02:00
Ralf Jung
9ab1d5c73a multi-variant enums are tricky 2019-08-17 11:57:01 +02:00
Ralf Jung
0d242b3f90 invalid_value: warn for types with custom valid range 2019-08-17 11:56:58 +02:00
Ralf Jung
25d8a0a351 warn about uninit bools and chars 2019-08-17 11:56:57 +02:00
Ralf Jung
5f7716d11b invalid_value: factor finding dangerous inits into separate function 2019-08-17 11:56:54 +02:00
Vadim Petrochenkov
136db2235a hygiene: ExpnInfo -> ExpnData
For naming consistency with everything else in this area
2019-08-15 20:41:45 +03:00
Vadim Petrochenkov
73dee258c1 hygiene: Remove Options from functions returning ExpnInfo
The expansion info is not optional and should always exist
2019-08-15 20:39:27 +03:00
Vadim Petrochenkov
dfcbe75900 syntax_pos: Introduce a helper for checking whether a span comes from expansion 2019-08-15 20:38:12 +03:00
Vadim Petrochenkov
a6182711ef Remove Spanned from {ast,hir}::FieldPat 2019-08-15 12:31:50 +03:00
Vadim Petrochenkov
433b1e36e1 Remove Spanned from ast::Mac 2019-08-15 11:45:28 +03:00
Mazdak Farrokhzad
ad44d42750
Rollup merge of #63543 - c410-f3r:variant, r=c410-f3r
Merge Variant and Variant_

Extracted from #63468.
2019-08-14 22:56:29 +02:00
Mazdak Farrokhzad
7178cf5f97
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
Add lint for excess trailing semicolons

Closes #60876.
A caveat (not necessarily a negative, but something to consider) with this implementation is that excess semicolons after return/continue/break now also cause an 'unreachable statement' warning.

For the following example:
```
fn main() {
    extra_semis();
}
fn extra_semis() -> i32 {
    let mut sum = 0;;;
    for i in 0..10 {
        if i == 5 {
            continue;;
        } else if i == 9 {
            break;;
        } else {
            sum += i;;
        }
    }
    return sum;;
}
```
The output is:
```
warning: unnecessary trailing semicolons
 --> src/main.rs:5:21
  |
5 |     let mut sum = 0;;;
  |                     ^^ help: remove these semicolons
  |
  = note: `#[warn(redundant_semicolon)]` on by default

warning: unnecessary trailing semicolon
 --> src/main.rs:8:22
  |
8 |             continue;;
  |                      ^ help: remove this semicolon

warning: unnecessary trailing semicolon
  --> src/main.rs:10:19
   |
10 |             break;;
   |                   ^ help: remove this semicolon

warning: unnecessary trailing semicolon
  --> src/main.rs:12:22
   |
12 |             sum += i;;
   |                      ^ help: remove this semicolon

warning: unnecessary trailing semicolon
  --> src/main.rs:15:16
   |
15 |     return sum;;
   |                ^ help: remove this semicolon

warning: unreachable statement
 --> src/main.rs:8:22
  |
8 |             continue;;
  |                      ^
  |
  = note: `#[warn(unreachable_code)]` on by default

warning: unreachable statement
  --> src/main.rs:10:19
   |
10 |             break;;
   |                   ^

warning: unreachable statement
  --> src/main.rs:15:16
   |
15 |     return sum;;
   |                ^

```
2019-08-14 22:56:18 +02:00
Caio
6a42b0b28d Merge Variant and Variant_ 2019-08-14 14:47:01 -03:00
Nathan
2f6cb5f75e Add lint for excess trailing semicolons 2019-08-12 10:14:07 -04:00
Ralf Jung
0499923b18 more informative error message from invalid_value lint 2019-08-12 11:23:56 +02:00
Ralf Jung
5c77a17d18 note down some more future plans 2019-08-11 12:04:49 +02:00
Ralf Jung
8e6fbbec83 add tuple_fields convenience method and use it in a few places 2019-08-11 12:04:49 +02:00
Ralf Jung
ca1e94b131 warn for more cases 2019-08-11 12:04:49 +02:00
Ralf Jung
da6fbb1895 add basic lint testing for misuse of mem::zeroed and mem::uninitialized 2019-08-11 12:04:49 +02:00
Yuki Okushi
e2b3543eab Return early to avoid failing assertion 2019-08-08 13:38:23 +09:00
Mazdak Farrokhzad
fb79a74020
Rollup merge of #63163 - bravomikekilo:master, r=cramertj
add a pair of whitespace after remove parentheses

fix [issue-63156](https://github.com/rust-lang/rust/issues/63156).
add a pair of whitespace after remove parentheses.
2019-08-07 01:39:28 +02:00
Oliver Scherer
7710820d18 Fiddle param env through to try_eval_bits in most places 2019-08-05 17:48:05 +02:00
Oliver Scherer
9b87d22ea8 Don't abort on unevaluated constants without at least tryting to eval them 2019-08-05 17:48:04 +02:00
varkor
63659ca9f6 Rename ItemImplKind::Type to ItemImplKind::TyAlias 2019-08-04 20:16:41 +01:00
varkor
8aa45c65d8 Rename ItemKind::Ty to ItemKind::TyAlias 2019-08-04 20:13:37 +01:00
bravomikekilo
4c1d892960 fix tidy problem 2019-08-03 02:17:20 +08:00