about summary refs log tree commit diff
path: root/compiler/rustc_passes
AgeCommit message (Collapse)AuthorLines
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.
2021-02-18Implement -Z hir-stats for nested foreign itemsTomasz Miąsko-0/+5
An attempt to compute HIR stats for crates with nested foreign items results in an ICE. ``` 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-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-1/+1
2021-02-15Use less HirId when referring to items.Camille GILLOT-8/+7
2021-02-15Only store a LocalDefId in hir::MacroDef.Camille GILLOT-5/+5
2021-02-15Index Modules using their LocalDefId.Camille GILLOT-6/+3
2021-02-15Only store a LocalDefId in hir::ForeignItem.Camille GILLOT-11/+15
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-19/+18
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-9/+15
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-43/+38
Items are guaranteed to be HIR owner.
2021-02-15Use ItemId as a strongly typed index.Camille GILLOT-2/+2
2021-02-14Rollup merge of #80920 - rylev:check_attr-refactor, r=davidtwcoDylan DPC-11/+17
Visit more targets when validating attributes This begins to address #80048, allowing for additional validation of attributes. There are more refactorings that can be done, though I think they should be tackled in additional PRs: * ICE when a builtin attribute is encountered that is not checked * Move some of the attr checking done `ast_validation` into `rustc_passes` * note that this requires a bit of additional refactoring, especially of extern items which currently parse attributes (and thus are a part of the AST) but do not possess attributes in their HIR representation. * Rename `Target` to `AttributeTarget` * Refactor attribute validation completely to go through `Visitor::visit_attribute`. * This would require at a minimum passing `Target` into this method which might be too big of a refactoring to be worth it. * It's also likely not possible to do all the validation this way as some validation requires knowing what other attributes a target has. r? `@davidtwco`
2021-02-10Tweak stability attribute diagnostic outputEsteban Küber-17/+19
2021-02-10Inherit `#[stable(..)]` annotations in enum variants and fields from its itemEsteban Küber-12/+38
2021-02-09Visit more targets when checking attrsRyan Levick-11/+17
2021-02-09Rename HIR UnOp variantsÖmer Sinan Ağacan-1/+1
This renames the variants in HIR UnOp from enum UnOp { UnDeref, UnNot, UnNeg, } to enum UnOp { Deref, Not, Neg, } Motivations: - This is more consistent with the rest of the code base where most enum variants don't have a prefix. - These variants are never used without the `UnOp` prefix so the extra `Un` prefix doesn't help with readability. E.g. we don't have any `UnDeref`s in the code, we only have `UnOp::UnDeref`. - MIR `UnOp` type variants don't have a prefix so this is more consistent with MIR types. - "un" prefix reads like "inverse" or "reverse", so as a beginner in rustc code base when I see "UnDeref" what comes to my mind is something like "&*" instead of just "*".
2021-02-02Bump rustfmt versionMark Rousskov-1/+2
Also switches on formatting of the mir build module
2021-02-01Fixed #[inline] to be warned in fields, arms, macro defsDanuel-45/+263
Add visitors for checking #[inline] Add visitors for checking #[inline] with struct field Fix test for #[inline] Add visitors for checking #[inline] with #[macro_export] macro Add visitors for checking #[inline] without #[macro_export] macro Add use alias with Visitor Fix lint error Reduce unnecessary variable Co-authored-by: LingMan <LingMan@users.noreply.github.com> Change error to warning Add warning for checking field, arm with #[allow_internal_unstable] Add name resolver Formatting Formatting Fix error fixture Add checking field, arm, macro def
2021-01-28Add missing braceOli Scherer-1/+1
2021-01-29Simplify base_exprSeo Sanghyeon-8/+4
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-01-28Warn write-only fieldsSeo Sanghyeon-0/+19
2021-01-28Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakisYuki Okushi-2/+2
Refractor a few more types to `rustc_type_ir` In the continuation of #79169, ~~blocked on that PR~~. This PR: - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance` - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler. ~~I will split up that commit to make this easier to review and to have a better commit history.~~ EDIT: done, I split the PR in commits of 200-ish lines each r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-25This should address issue 81294.Felix S. Klock II-1/+1
(No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.)
2021-01-24Rollup merge of #81310 - tmiasko:in-pattern, r=petrochenkovJonas Schievink-1/+1
Do not mark unit variants as used when in path pattern Record that we are processing a pattern so that code responsible for handling path resolution can correctly decide whether to mark it as used or not. Closes #76788.
2021-01-24Auto merge of #80919 - cjgillot:defkey-span, r=oli-obkbors-0/+1
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N Sample from #80347.
2021-01-23Allow to query the HIR crate node.Camille GILLOT-0/+1
2021-01-23Do not mark unit variants as used when in path patternTomasz Miąsko-1/+1
Record that we are processing a pattern so that code responsible for handling path resolution can correctly decide whether to mark it as used or not.
2021-01-21Do not suggest using a break label when one is already presentEsteban Küber-6/+11
2021-01-21Tweak error for invalid `break expr`Esteban Küber-20/+56
Point at loop head on invalid `break expr`. Suggest removing `expr` or using label if available.
2021-01-21Add loop head span to hirEsteban Küber-6/+5
2021-01-18Use ty::{IntTy,UintTy,FloatTy} in rustcLeSeulArtichaut-2/+2
2021-01-18Only inherit const stability for methods of `impl const Trait` blocksoli-10/+60
2021-01-14Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasperbors-4/+38
Reintroduce hir::ExprKind::If Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications. The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome. - [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051) - [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d) - [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5) - [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691) - [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95) - [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-8/+11
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-8/+11
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-10Fix small typoCamelid-1/+1
transmutting -> transmuting
2021-01-07Reintroduce hir::ExprKind::IfCaio-4/+38
2021-01-06Don't use to_string on SymbolGuillaume Gomez-1/+1
2021-01-04Add an error in case the doc alias is the same as the item it's aliasingGuillaume Gomez-1/+12
2021-01-02reduce borrowing and (de)referencing around match patterns ↵Matthias Krüger-1/+1
(clippy::match_ref_pats)
2021-01-01adjust const generics defaults FIXMEs to the new feature gateRémy Rakic-1/+1
2020-12-30Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkovMara Bos-1/+1
Rename kw::Invalid -> kw::Empty See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context. r? `@petrochenkov`
2020-12-30Rename kw::Invalid -> kw::EmptyJoshua Nelson-1/+1
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context.
2020-12-24use matches!() macro in more placesMatthias Krüger-23/+20
2020-12-19Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnrbors-0/+12
passes: prohibit invalid attrs on generic params Fixes #78957. This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity. r? `@lcnr`
2020-12-17Rollup merge of #79877 - bstrie:depinfut, r=oli-obkYuki Okushi-20/+24
Allow `since="TBD"` for rustc_deprecated Closes #78381. This PR only affects `#[rustc_deprecated]`, not `#[deprecated]`, so there is no effect on any stable language feature. Likewise this PR only implements `since="TBD"`, it does not actually tag any library functions with it, so there is no effect on any stable API. Overview of changes: * `rustc_middle/stability.rs`: * change `deprecation_in_effect` function to return `false` when `since="TBD"` * tidy up the compiler output when a deprecated item has `since="TBD"` * `rustc_passes/stability.rs`: * allow `since="TBD"` to pass the sanity check for stable_version < deprecated_version * refactor the "invalid stability version" and "invalid deprecation version" error into separate errors * rustdoc: make `since="TBD"` message on a deprecated item's page match the command-line deprecation output * tests: * test rustdoc output * test that the `deprecated_in_future` lint fires when `since="TBD"` * test the new "invalid deprecation version" error message
2020-12-17Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasperYuki Okushi-4/+12
Implement if-let match guards Implements rust-lang/rfcs#2294 (tracking issue: #51114). I probably should do a few more things before this can be merged: - [x] Add tests (added basic tests, more advanced tests could be done in the future?) - [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements) - [x] Fix clippy However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs. Thanks a lot `@matthewjasper` :heart: for helping me with lowering to MIR! Would you be interested in reviewing this? r? `@ghost` for now
2020-12-16Allow `since="TBD"` for rustc_deprecatedbstrie-20/+24
2020-12-09Rollup merge of #79844 - tmiasko:rwu-table-mod, r=lcnrTyler Mandry-146/+149
Move RWUTable to a separate module
2020-12-09Rollup merge of #79826 - LingMan:match_if, r=lcnrTyler Mandry-20/+10
Simplify visit_{foreign,trait}_item Using an `if` seems like a better semantic fit and saves a few lines. Noticed while looking at https://github.com/rust-lang/rust/pull/79752, but that's already merged. r? `@lcnr,` cc `@cjgillot` `@rustbot` modify labels +C-cleanup +T-compiler