about summary refs log tree commit diff
path: root/src/test/ui/lint
AgeCommit message (Collapse)AuthorLines
2019-09-27Add test for redundant_semicolon lint interaction with proc macro attrsNathan-0/+52
2019-09-25Rollup merge of #64508 - Centril:or-pat-hir, r=matthewjasperMazdak Farrokhzad-10/+13
or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR Following up on work in https://github.com/rust-lang/rust/pull/64111, https://github.com/rust-lang/rust/pull/63693, and https://github.com/rust-lang/rust/pull/61708, in this PR: - We change `hair::Arm.patterns: Vec<Pattern<'_>>` into `hir::Arm.pattern: Pattern<'_>`. - `fn hair::Arm::top_pats_hack` is introduced as a temporary crutch in MIR building to avoid more changes. - We change `hir::Arm.pats: HirVec<P<Pat>>` into `hir::Arm.pat: P<Pat>`. - The hacks in `rustc::hir::lowering` are removed since the representation hack is no longer necessary. - In some places, `fn hir::Arm::top_pats_hack` is introduced to leave some things as future work. - Misc changes: HIR pretty printing is adjusted to behave uniformly wrt. top/inner levels, rvalue promotion is adjusted, regionck, and dead_code is also. - Type checking is adjusted to uniformly handle or-patterns at top/inner levels. To make things compile, `p_0 | ... | p_n` is redefined as a "reference pattern" in [`fn is_non_ref_pat`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html#method.is_non_ref_pat) for now. This is done so that reference types are not eagerly stripped from the `expected: Ty<'tcx>`. - Liveness is adjusted wrt. the `unused_variables` and `unused_assignments` lints to handle top/inner levels uniformly and the handling of `fn` parameters, `let` locals, and `match` arms are unified in this respect. This is not tested for now as exhaustiveness checks are reachable and will ICE. - In `check_match`, checking `@` and by-move bindings is adjusted. However, exhaustiveness checking is not adjusted the moment and is handled by @dlrobertson in https://github.com/rust-lang/rust/pull/63688. - AST borrowck (`construct.rs`) is not adjusted as AST borrowck will be removed soon. r? @matthewjasper cc @dlrobertson @varkor @oli-obk
2019-09-22Auto merge of #64669 - estebank:unreachable, r=Centrilbors-6/+12
Use span label instead of note in unreachable lint Fix #64636.
2019-09-21review commentsEsteban Küber-2/+2
2019-09-21Do not trigger unreachable lint in async body and Use span labelsEsteban Küber-6/+12
2019-09-21Rollup merge of #64010 - c410-f3r:stabilize-attrs-fn, r=CentrilMazdak Farrokhzad-2/+2
Stabilize `param_attrs` in Rust 1.39.0 # Stabilization proposal I propose that we stabilize `#![feature(param_attrs)]`. Tracking issue: #60406 Version: 1.39 (2019-09-26 => beta, 2019-11-07 => stable). ## What is stabilized It is now possible to add outer attributes like `#[cfg(..)]` on formal parameters of functions, closures, and function pointer types. For example: ```rust fn len( #[cfg(windows)] slice: &[u16], #[cfg(not(windows))] slice: &[u8], ) -> usize { slice.len() } ``` ## What isn't stabilized * Documentation comments like `/// Doc` on parameters. * Code expansion of a user-defined `#[proc_macro_attribute]` macro used on parameters. * Built-in attributes other than `cfg`, `cfg_attr`, `allow`, `warn`, `deny`, and `forbid`. Currently, only the lints `unused_variables` and `unused_mut` have effect and may be controlled on parameters. ## Motivation The chief motivations for stabilizing `param_attrs` include: * Finer conditional compilation with `#[cfg(..)]` and linting control of variables. * Richer macro DSLs created by users. * External tools and compiler internals can take advantage of the additional information that the parameters provide. For more examples, see the [RFC][rfc motivation]. ## Reference guide In the grammar of function and function pointer, the grammar of variadic tails (`...`) and parameters are changed respectively from: ```rust FnParam = { pat:Pat ":" }? ty:Type; VaradicTail = "..."; ``` into: ```rust FnParam = OuterAttr* { pat:Pat ":" }? ty:Type; VaradicTail = OuterAttr* "..."; ``` The grammar of a closure parameter is changed from: ```rust ClosureParam = pat:Pat { ":" ty:Type }?; ``` into: ```rust ClosureParam = OuterAttr* pat:Pat { ":" ty:Type }?; ``` More generally, where there's a list of formal (value) parameters separated or terminated by `,` and delimited by `(` and `)`. Each parameter in that list may optionally be prefixed by `OuterAttr+`. Note that in all cases, `OuterAttr*` applies to the whole parameter and not just the pattern. This distinction matters in pretty printing and in turn for macros. ## History * On 2018-10-15, @Robbepop proposes [RFC 2565][rfc], "Attributes in formal function parameter position". * On 2019-04-30, [RFC 2565][rfc] is merged and the tracking issue is made. * On 2019-06-12, a partial implementation was completed. The implementation was done in [#60669][60669] by @c410-f3r and the PR was reviewed by @petrochenkov and @Centril. * On 2019-07-29, [#61238][61238] was fixed in [#61856][61856]. The issue fixed was that lint attributes on function args had no effect. The PR was written by @c410-f3r and reviewed by @matthewjasper, @petrochenkov, and @oli-obk. * On 2019-08-02, a bug [#63210][63210] was filed wherein the attributes on formal parameters would not be passed to macros. The issue was about forgetting to call the relevant method in `fn print_arg` in the pretty printer. In [#63212][63212], written by @Centril on 2019-08-02 and reviewed by @davidtwco, the issue aforementioned was fixed. * This PR stabilizes `param_attrs`. ## Tests * [On Rust 2018, attributes aren't permitted on function parameters without a pattern in trait definitions.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.rs) * [All attributes that should be allowed. This includes `cfg`, `cfg_attr`, and lints check attributes.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-allowed.rs) * [Built-in attributes, which should be forbidden, e.g., `#[test]`, are.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs) * [`cfg` and `cfg_attr` are properly evaluated.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) * [`unused_mut`](https://github.com/rust-lang/rust/blob/46f405ec4d7c6bf16fc2eaafe7541019f1da2996/src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs) and [`unused_variables`](https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/lint-unused-variables.rs) are correctly applied to parameter patterns. * [Pretty printing takes formal parameter attributes into account.](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs) ## Possible future work * Custom attributes inside function parameters aren't currently supported but it is something being worked on internally. * Since documentation comments are syntactic sugar for `#[doc(...)]`, it is possible to allow literal `/// Foo` comments on function parameters. [rfc motivation]: https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md#motivation [rfc]: https://github.com/rust-lang/rfcs/pull/2565 [60669]: https://github.com/rust-lang/rust/pull/60669 [61856]: https://github.com/rust-lang/rust/pull/61856 [63210]: https://github.com/rust-lang/rust/issues/63210 [61238]: https://github.com/rust-lang/rust/issues/61238 [63212]: https://github.com/rust-lang/rust/pull/63212 This report is a collaborative work with @Centril.
2019-09-18Point at original span when emitting unreachable lintAaron Hill-0/+5
Fixes #64590 When we emit an 'unreachable' lint, we now add a note pointing at the expression that actually causes the code to be unreachable (e.g. `return`, `break`, `panic`). This is especially useful when macros are involved, since a diverging expression might be hidden inside of a macro invocation.
2019-09-17Rollup merge of #64429 - afnanenayet:afnan/fix-failure-note-json-level, ↵Tyler Mandry-1/+1
r=Mark-Simulacrum Fix failure note `to_str` implementation Serialize the level to something a little more useful for a failure note struct. This fixes #60425.
2019-09-16Fix failure note `to_str` implementationAfnan Enayet-1/+1
* Serialize the level to something a little more useful for a failure note struct * Update tests accordingly
2019-09-16or-patterns: #47390: we rely on names to exercise `IndexMap`.Mazdak Farrokhzad-10/+13
2019-09-14Don't mark expression with attributes as not needing parenthesesMark Rousskov-19/+23
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-12Auto merge of #64359 - varkor:opaque-ty-in-extern, r=estebankbors-87/+162
Forbid opaque types in `extern "C"` blocks Fixes #64338.
2019-09-11Stabilize `param_attrs` in Rust 1.39.0Caio-2/+2
2019-09-10Refactor "not FFI-safe" diagnosticvarkor-88/+133
2019-09-10Surround `PhantomData` in backticksvarkor-6/+6
2019-09-10Forbid opaque types in extern blocksvarkor-0/+30
2019-09-08Update test stderr with results of enabling unused lintsMark Rousskov-1/+1
2019-09-05or-patterns: fix fallout from #664128.Mazdak Farrokhzad-34/+19
2019-09-03unused_parens: fix for or-patterns + &(mut x)Mazdak Farrokhzad-47/+192
2019-08-31Auto merge of #63991 - Centril:unique-improper-ctype, r=rkruppebors-13/+23
`improper_ctypes`: guard against accidental change to `Unique<T>` r? @eddyb
2019-08-31improper_ctypes: guard against accidental change to Unique<T>.Mazdak Farrokhzad-13/+23
2019-08-30Auto merge of #63402 - estebank:strip-margin, r=oli-obkbors-18/+18
Strip code to the left and right in diagnostics for long lines Fix #62999.
2019-08-26review commentEsteban Küber-2/+2
2019-08-21Add more tests covering more casesEsteban Küber-0/+106
2019-08-21Do not complain about unused code when used in `impl` `Self` typeEsteban Küber-0/+35
2019-08-21Introduce `term-size` dependency and consider term width when trimmingEsteban Küber-20/+20
2019-08-21Strip code to the left and right in diagnostics for long linesEsteban Küber-2/+2
2019-08-20Remove async_await gates from tests.Mazdak Farrokhzad-2/+2
2019-08-17test in a way that works even with muslRalf Jung-65/+58
2019-08-17invalid_value: also detect transmute-from-0 (seen in the wild)Ralf Jung-39/+78
2019-08-17invalid_value: warn for types with custom valid rangeRalf Jung-28/+84
2019-08-17warn about uninit bools and charsRalf Jung-1/+30
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-1/+1
2019-08-12more informative error message from invalid_value lintRalf Jung-55/+183
2019-08-11warn for more casesRalf Jung-11/+166
2019-08-11add basic lint testing for misuse of mem::zeroed and mem::uninitializedRalf Jung-0/+72
2019-08-09Allow deprecated try macro in test cratesLzu Tao-2/+3
2019-08-09Deprecate `try!` macroBO41-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com> Co-Authored-By: Oliver Middleton <olliemail27@gmail.com>
2019-08-07Rollup merge of #63163 - bravomikekilo:master, r=cramertjMazdak Farrokhzad-14/+833
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-06Add rustfix test and fix test name.bravomikekilo-127/+220
2019-08-03fix tidy problembravomikekilo-1/+1
2019-08-03add new test and add conditional whitespacebravomikekilo-1/+727
2019-07-31add a pair of whitespace after remove parenthesesbravomikekilo-1/+1
2019-07-30Auto merge of #62766 - alexcrichton:stabilize-pipelined-compilation, r=oli-obkbors-27/+27
rustc: Stabilize options for pipelined compilation This commit stabilizes options in the compiler necessary for Cargo to enable "pipelined compilation" by default. The concept of pipelined compilation, how it's implemented, and what it means for rustc are documented in #60988. This PR is coupled with a PR against Cargo (rust-lang/cargo#7143) which updates Cargo's support for pipelined compliation to rustc, and also enables support by default in Cargo. (note that the Cargo PR cannot land until this one against rustc lands). The technical changes performed here were to stabilize the functionality proposed in #60419 and #60987, the underlying pieces to enable pipelined compilation support in Cargo. The issues have had some discussion during stabilization, but the newly stabilized surface area here is: * A new `--json` flag was added to the compiler. * The `--json` flag can be passed multiple times. * The value of the `--json` flag is a comma-separated list of directives. * The `--json` flag cannot be combined with `--color` * The `--json` flag must be combined with `--error-format=json` * The acceptable list of directives to `--json` are: * `diagnostic-short` - the `rendered` field of diagnostics will have a "short" rendering matching `--error-format=short` * `diagnostic-rendered-ansi` - the `rendered` field of diagnostics will be colorized with ansi color codes embedded in the string field * `artifacts` - JSON blobs will be emitted for artifacts being emitted by the compiler The unstable `-Z emit-artifact-notifications` and `--json-rendered` flags have also been removed during this commit as well. Closes #60419 Closes #60987 Closes #60988
2019-07-28Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centrilbors-27/+269
Rollup of 8 pull requests Successful merges: - #61856 (Lint attributes on function arguments) - #62360 (Document that ManuallyDrop::drop should not called more than once) - #62392 (Update minifier-rs version) - #62871 (Explicit error message for async recursion.) - #62995 (Avoid ICE when suggestion span is at Eof) - #63053 (SystemTime docs: recommend Instant for elapsed time) - #63081 (tidy: Cleanup the directory whitelist) - #63088 (Remove anonymous_parameters from unrelated test) Failed merges: r? @ghost
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-106/+105
rustbuild Remove some random unnecessary lint `allow`s
2019-07-27Lint attributes on function argumentsCaio-27/+269
2019-07-26rustc: Stabilize options for pipelined compilationAlex Crichton-27/+27
This commit stabilizes options in the compiler necessary for Cargo to enable "pipelined compilation" by default. The concept of pipelined compilation, how it's implemented, and what it means for rustc are documented in #60988. This PR is coupled with a PR against Cargo (rust-lang/cargo#7143) which updates Cargo's support for pipelined compliation to rustc, and also enables support by default in Cargo. (note that the Cargo PR cannot land until this one against rustc lands). The technical changes performed here were to stabilize the functionality proposed in #60419 and #60987, the underlying pieces to enable pipelined compilation support in Cargo. The issues have had some discussion during stabilization, but the newly stabilized surface area here is: * A new `--json` flag was added to the compiler. * The `--json` flag can be passed multiple times. * The value of the `--json` flag is a comma-separated list of directives. * The `--json` flag cannot be combined with `--color` * The `--json` flag must be combined with `--error-format=json` * The acceptable list of directives to `--json` are: * `diagnostic-short` - the `rendered` field of diagnostics will have a "short" rendering matching `--error-format=short` * `diagnostic-rendered-ansi` - the `rendered` field of diagnostics will be colorized with ansi color codes embedded in the string field * `artifacts` - JSON blobs will be emitted for artifacts being emitted by the compiler The unstable `-Z emit-artifact-notifications` and `--json-rendered` flags have also been removed during this commit as well. Closes #60419 Closes #60987 Closes #60988
2019-07-21normalize use of backticks in compiler messages for librustc_lintSamy Kacimi-13/+13
2019-07-17normalize use of backticks in compiler messages for librustc/lintSamy Kacimi-32/+32
https://github.com/rust-lang/rust/issues/60532