about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2022-07-15Remove some more usages of guess_head_spanMichael Goulet-2/+1
2022-07-14Rollup merge of #98580 - PrestonFrom:issue_98466, r=estebankDylan DPC-0/+12
Emit warning when named arguments are used positionally in format Addresses Issue 98466 by emitting an error if a named argument is used like a position argument (i.e. the name is not used in the string to be formatted). Fixes rust-lang#98466
2022-07-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-1/+2
Rollup of 5 pull requests Successful merges: - #97720 (Always create elided lifetime parameters for functions) - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`) - #98705 (Implement `for<>` lifetime binder for closures) - #99126 (remove allow(rustc::potential_query_instability) in rustc_span) - #99139 (Give a better error when `x dist` fails for an optional tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-1/+2
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-3/+3
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13Emit warning when named arguments are used positionally in formatPreston From-0/+12
Addresses Issue 98466 by emitting a warning if a named argument is used like a position argument (i.e. the name is not used in the string to be formatted). Fixes rust-lang#98466
2022-07-13Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddybDylan DPC-3/+2
`UnsafeCell` blocks niches inside its nested type from being available outside fixes #87341 This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646 Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-12Lower closure binders to hir & properly check themMaybe Waffle-0/+1
2022-07-12Parse closure bindersMaybe Waffle-1/+1
This is first step in implementing RFC 3216. - Parse `for<'a>` before closures in ast - Error in lowering - Add `closure_lifetime_binder` feature
2022-07-07Auto merge of #95573 - cjgillot:lower-query, r=michaelwoeristerbors-2/+2
Make lowering a query Split from https://github.com/rust-lang/rust/pull/88186. This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query. In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so. Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by: - enclosing `Definitions` in a lock, so as to allow modification; - creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system. See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
2022-07-07Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, ↵Dylan DPC-1/+32
r=wesleywiser Finishing touches for `#[expect]` (RFC 2383) This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature. As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly. --- changelog: [`duplicate_mod`]: Fixed lint attribute interaction r? `@wesleywiser` cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549 And I guess that's it. Here have a magical unicorn :unicorn:
2022-07-07Comment updateOli Scherer-2/+1
2022-07-07`UnsafeCell` now has no niches, ever.Oli Scherer-1/+1
2022-07-06Make AST lowering a query.Camille GILLOT-2/+2
2022-07-06Add function to manually fulfill lint expectations (RFC 2383)xFrednet-1/+32
2022-07-06Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, ↵Guillaume Gomez-24/+13
r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of #97417. r? `@cjgillot`
2022-07-06fix miri-opt testsTakayuki Maeda-10/+6
2022-07-06replace `guess_head_span` with `def_span`Takayuki Maeda-14/+7
2022-07-06Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obkDylan DPC-15/+43
macros: `LintDiagnostic` derive - Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it. - Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning). - Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`). - Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery. ~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~ r? `@oli-obk`
2022-07-06Update TypeVisitor pathsAlan Egerton-5/+5
2022-07-05macros: add diagnostic derive for lintsDavid Wood-7/+15
`SessionDiagnostic` isn't suitable for use on lints as whether or not it creates an error or a warning is decided at compile-time by the macro, whereas lints decide this at runtime based on the location of the lint being reported (as it will depend on the user's `allow`/`deny` attributes, etc). Re-using most of the machinery for `SessionDiagnostic`, this macro introduces a `LintDiagnostic` derive which implements a `DecorateLint` trait, taking a `LintDiagnosticBuilder` and adding to the lint according to the diagnostic struct.
2022-07-05errors: introduce `DecorateLint`David Wood-2/+22
Add a new trait to be generated by diagnostic derives which uses a `LintDiagnosticBuilder`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05lint: `LintDiagnosticBuilder` into `rustc_errors`David Wood-7/+7
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errorsDylan DPC-587/+507
lints: mostly translatable diagnostics As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway). r? ``@compiler-errors``
2022-06-30fix grammar in useless doc comment lintAndy Russell-2/+2
2022-06-30lint: port asm labels diagnosticsDavid Wood-3/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port deref nullptr diagnosticsDavid Wood-2/+2
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port clashing extern diagnosticsDavid Wood-14/+10
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: add todo for invalid value diagnosticsDavid Wood-0/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port incomplete features diagnosticsDavid Wood-14/+5
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port explicit outlives diagnosticsDavid Wood-6/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port keyword idents diagnosticsDavid Wood-2/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port test items diagnosticsDavid Wood-1/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port `...` range pattern diagnosticsDavid Wood-6/+12
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port trivial bounds diagnosticsDavid Wood-6/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port type alias bounds diagnosticsDavid Wood-10/+5
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port unreachable `pub` diagnosticDavid Wood-3/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port unstable feature diagnosticsDavid Wood-1/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port mutable transmutes diagnosticDavid Wood-3/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port no-mangle diagnosticsDavid Wood-5/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port unused doc comment diagnosticsDavid Wood-7/+5
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port deprecated attr diagnosticsDavid Wood-24/+27
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port anonymous parameter diagnosticsDavid Wood-12/+8
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port missing debug impl diagnosticsDavid Wood-6/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port missing copy impl diagnosticsDavid Wood-5/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port missing documentation diagnosticsDavid Wood-1/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port unsafe diagnosticsDavid Wood-36/+32
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port non-shorthand pattern diagnosticsDavid Wood-10/+10
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port box pointers diagnosticsDavid Wood-1/+1
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port while true diagnosticsDavid Wood-4/+3
Signed-off-by: David Wood <david.wood@huawei.com>