summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2021-05-03Revert PR 81473 to resolve (on beta) issues 81626 and 81658.Felix S. Klock II-21/+0
Revert "Add missing brace" This reverts commit 85ad773049536d7fed9a94ae0ac74f97135c8655. Revert "Simplify base_expr" This reverts commit 899aae465eb4ef295dc1eeb2603f744568e0768c. Revert "Warn write-only fields" This reverts commit d3c69a4c0dd98af2611b7553d1a65afef6a6ccb0.
2021-03-19Auto merge of #82951 - sexxi-goose:wr-mir-replace-methods2, r=nikomatsakisbors-55/+54
Replace closures_captures and upvar_capture with closure_min_captures Removed all uses of closures_captures and upvar_capture and refactored code to work with closure_min_captures. This also involved removing functions that were no longer needed like the bridge. Closes https://github.com/rust-lang/project-rfc-2229/issues/18 r? `@nikomatsakis`
2021-03-19Rollup merge of #82846 - GuillaumeGomez:doc-alias-list, r=jyn514Dylan DPC-30/+83
rustdoc: allow list syntax for #[doc(alias)] attributes Fixes https://github.com/rust-lang/rust/issues/81205. It now allows to have: ```rust #[doc(alias = "x")] // and: #[doc(alias("y", "z"))] ``` cc ``@jplatte`` r? ``@jyn514``
2021-03-18Replace closures_captures and upvar_capture with closure_min_capturesJennifer Wills-55/+54
make changes to liveness to use closure_min_captures use different span borrow check uses new structures rename to CapturedPlace stop using upvar_capture in regionck remove the bridge cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs remove line from livenes test make our unused var checking more consistent update tests adding more warnings to the tests move is_ancestor_or_same_capture to rustc_middle/ty update names to reflect the closures add FIXME check that all captures are immutable borrows before returning add surrounding if statement like the original move var out of the loop and rename Co-authored-by: Logan Mosier <logmosier@gmail.com> Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-18/+18
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-15Rollup merge of #83098 - camelid:more-doc-attr-check, r=davidtwcoDylan DPC-46/+64
Find more invalid doc attributes - Lint on `#[doc(123)]`, `#[doc("hello")]`, etc. - Lint every attribute; e.g., will now report two warnings for `#[doc(foo, bar)]` - Add hyphen to "crate level" - Display paths like `#[doc(foo::bar)]` correctly instead of as an empty string
2021-03-14Use pretty-printer instead of `span_to_snippet`Camelid-7/+4
2021-03-14Tweak diagnosticsCamelid-6/+9
- Tweak lint message - Display multi-segment paths correctly
2021-03-13Add hyphen to "crate level"Camelid-2/+2
"crate level attribute" -> "crate-level attribute"
2021-03-13Report error for each invalid nested attributeCamelid-6/+9
2021-03-13Lint non-meta doc attributesCamelid-0/+10
E.g., `#[doc(123)]`.
2021-03-13Refactor `check_doc_attrs` bodyCamelid-36/+41
This change makes it easier to follow the control flow. I also moved the end-of-line comments attached to some symbols to before the symbol listing. This allows rustfmt to format the code; otherwise no formatting occurs (see rust-lang/rustfmt#4750).
2021-03-11Improve code by removing similar function calls and using loops instead for ↵Guillaume Gomez-59/+33
collecting iterators
2021-03-11Validate rustc_layout_scalar_valid_range_{start,end} attributesTomasz Miąsko-1/+36
2021-03-10Allow doc alias attributes to use both list and valueGuillaume Gomez-7/+86
2021-03-09Track HirId when visiting attributes.Camille GILLOT-3/+3
2021-03-09Remove hir::Item::attrs.Camille GILLOT-7/+10
2021-03-09Remove hir::ForeignItem::attrs.Camille GILLOT-1/+2
2021-03-09Remove hir::Crate::attrs.Camille GILLOT-2/+2
2021-03-09Do not store attrs in FnKind.Camille GILLOT-2/+3
2021-03-09Access attrs directly from HirId in rustc_passes::diagnostic_item.Camille GILLOT-6/+8
2021-03-09Access attrs directly from HirId in rustc_passes::lang_items.Camille GILLOT-14/+6
2021-03-09Access attrs directly from HirId in rustc_passes::dead.Camille GILLOT-23/+9
2021-03-09Access attrs directly from HirId in rustc_passes::stability.Camille GILLOT-12/+1
2021-03-09Access attrs directly from HirId in rustc_passes::check_attr.Camille GILLOT-50/+13
2021-03-07Rollup merge of #82651 - jyn514:rustdoc-warnings, r=GuillaumeGomezYuki Okushi-1/+2
Cleanup rustdoc warnings ## Clean up error reporting for deprecated passes Using `error!` here goes all the way back to the original commit, https://github.com/rust-lang/rust/pull/8540. I don't see any reason to use logging; rustdoc should use diagnostics wherever possible. See https://github.com/rust-lang/rust/pull/81932#issuecomment-785291244 for further context. - Use spans for deprecated attributes - Use a proper diagnostic for unknown passes, instead of error logging - Add tests for unknown passes - Improve some wording in diagnostics ## Report that `doc(plugins)` doesn't work using diagnostics instead of `eprintln!` This also adds a test for the output. This was added in https://github.com/rust-lang/rust/pull/52194. I don't see any particular reason not to use diagnostics here, I think it was just missed in https://github.com/rust-lang/rust/pull/50541.
2021-03-05Rollup merge of #82708 - GuillaumeGomez:doc-test-attr-check, r=ManishearthGuillaume Gomez-7/+19
Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint Part of #82672. This PR does multiple things: * Create a new `INVALID_DOC_ATTRIBUTE` lint which is also "future incompatible", allowing us to use it as a warning for the moment until it turns (eventually) into a hard error. * Use this link when `#![doc(test(...))]` isn't used at the crate level. * Make #82702 use this new lint as well. r? ``@jyn514``
2021-03-05Make invalid_doc_attribute lint pluralGuillaume Gomez-3/+3
2021-03-05Auto merge of #71481 - estebank:inherit-stability, r=nikomatsakisbors-25/+53
Inherit `#[stable(..)]` annotations in enum variants and fields from its item Lint changes for #65515. The stdlib will have to be updated once this lands in beta and that version is promoted in master.
2021-03-04Also use INVALID_DOC_ATTRIBUTE for "unknown doc attribute" warningsGuillaume Gomez-6/+1
2021-03-04Add extra check for #[doc(test(...)] attributeGuillaume Gomez-1/+18
2021-03-03Change error about unknown doc attributes to a warningJoshua Nelson-9/+16
This prevents breakage across the ecosystem, since the error was just introduced recently without first having a warning period.
2021-03-02Report that `doc(plugins)` doesn't work using diagnostics instead of `println!`Joshua Nelson-1/+2
This also adds a test for the output and fixes `rustc_attr` to properly know that `plugins` is a valid attribute.
2021-03-02Rollup merge of #82662 - GuillaumeGomez:doc-attr-check, r=jyn514Guillaume Gomez-0/+35
Warn about unknown doc attributes Fixes #82652. For the text error, I decided to go for "invalid" instead of "unknown". What do you think? r? `@jyn514`
2021-03-01Validate meta items used in \#\[doc(...)\]Guillaume Gomez-0/+35
2021-02-28Use identifier's span in unused lintGiacomo Stevanato-43/+66
2021-02-26Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnrGuillaume Gomez-5/+10
Properly account for non-shorthand pattern field in unused variable lint Fix #82488
2021-02-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-0/+101
Add #[rustc_legacy_const_generics] This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead. This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`. ```rust #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } fn main() { assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]); assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]); } ``` r? `@oli-obk`
2021-02-25Improve checking for attributeAmanieu d'Antras-47/+56
2021-02-24Properly account for non-shorthand pattern field in unused variable lintEsteban Küber-5/+10
Fix #82488
2021-02-25Address review commentsAmanieu d'Antras-0/+17
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-0/+75
2021-02-23Rollup merge of #82297 - tmiasko:write-only, r=oli-obkDylan DPC-11/+17
Consider auto derefs before warning about write only fields Changes from #81473 extended the dead code lint with an ability to detect fields that are written to but never read from. The implementation skips over fields on the left hand side of an assignment, without marking them as live. A field access might involve an automatic dereference and de-facto read the field. Conservatively mark expressions with deref adjustments as live to avoid generating false positive warnings. Closes #81626.
2021-02-23Rollup merge of #82258 - tmiasko:foreign-hir-stats, r=davidtwcoDylan DPC-0/+5
Implement -Z hir-stats for nested foreign items An attempt to compute HIR stats for crates with nested foreign items results in an ICE. ```rust fn main() { extern "C" { fn f(); } } ``` ``` thread 'rustc' panicked at 'visit_nested_xxx must be manually implemented in this visitor' ``` Provide required implementation of visitor method.
2021-02-21remove redundant wrapping of return types of allow_internal_unstable() and ↵Matthias Krüger-1/+1
rustc_allow_const_fn_unstable()
2021-02-19Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011Dylan DPC-10/+0
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2021-02-19Consider auto derefs before warning about write only fieldsTomasz Miąsko-11/+17
Changes from 81473 extended the dead code lint with an ability to detect fields that are written to but never read from. The implementation skips over fields on the left hand side of an assignment, without marking them as live. A field access might involve an automatic dereference and de-facto read the field. Conservatively mark expressions with deref adjustments as live to avoid generating false positive warnings.
2021-02-18Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkorDylan DPC-6/+6
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout. I've tried not to change anything that looked similar to `rustc --print`, where people might use automation, and/or any "bulk" prints, such as dumping an entire Graphviz (`dot`) graph on stdout. The reason I want `-Ztime-passes` to be on stderr like debug logging is I can get a complete (and correctly interleaved) view just by looking at stderr, which is merely a convenience when running `rustc`/Cargo directly, but even more important when it's nested in a build script, as Cargo will split the build script output into stdout (named `output`) and `stderr`.
2021-02-18Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.Eduard-Mihai Burtescu-6/+6
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-10/+0
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.