about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
AgeCommit message (Collapse)AuthorLines
2020-11-26Remove ForeignMod struct.Camille GILLOT-10/+4
2020-11-26Store ForeignItem in a side table.Camille GILLOT-5/+95
2020-11-19resolve: Introduce a separate `NonMacroAttrKind` for legacy derive helpersVadim Petrochenkov-2/+9
2020-11-16improve error message for const ty param mismatchBastian Kauschke-0/+8
2020-11-12Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkovMara Bos-0/+5
Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review. Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes. r? ``@petrochenkov``
2020-11-11Implement destructuring assignment for structs and slicesFabian Zaiser-0/+5
Co-authored-by: varkor <github@varkor.com>
2020-11-10Changed unwrap_or to unwrap_or_else in some places.Nicholas-Baron-1/+1
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
2020-11-09Rollup merge of #78748 - fanzier:tuple-assignment, r=petrochenkovDylan DPC-0/+6
Implement destructuring assignment for tuples This is the first step towards implementing destructuring assignment (RFC: https://github.com/rust-lang/rfcs/pull/2909, tracking issue: #71126). This PR is the first part of #71156, which was split up to allow for easier review. Quick summary: This change allows destructuring the LHS of an assignment if it's a (possibly nested) tuple. It is implemented via a desugaring (AST -> HIR lowering) as follows: ```rust (a,b) = (1,2) ``` ... becomes ... ```rust { let (lhs0,lhs1) = (1,2); a = lhs0; b = lhs1; } ``` Thanks to `@varkor` who helped with the implementation, particularly around default binding modes. r? `@petrochenkov`
2020-11-07Fix handling of item names for HIRJoshua Nelson-0/+3
- Handle variants, fields, macros in `Node::ident()` - Handle the crate root in `opt_item_name` - Factor out `item_name_from_def_id` to reduce duplication - Look at HIR before the DefId for `opt_item_name` This gives accurate spans, which are not available from serialized metadata. - Don't panic on the crate root in `opt_item_name` - Add comments
2020-11-07Implement destructuring assignment for tuplesFabian Zaiser-0/+6
Co-authored-by: varkor <github@varkor.com>
2020-10-30Fix even more clippy warningsJoshua Nelson-40/+12
2020-10-29Rollup merge of #78224 - lcnr:repeat-expr, r=varkorYuki Okushi-1/+3
min_const_generics: allow ty param in repeat expr implements https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/repeat.20expressions Even with `min_const_generics` active, now keeps resulting in future compat warnings instead of hard errors. Const parameters, for example `[0; N + 1]`, still result in hard errors during resolve. ```rust #![allow(dead_code)] fn foo<T>() { [0; std::mem::size_of::<*mut T>()]; } struct Foo<T>(T); impl<T> Foo<T> { const ASSOC: usize = 4; fn test() { [0; Self::ASSOC]; } } ``` r? @varkor cc @petrochenkov
2020-10-25Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkovYuki Okushi-3/+3
Split out statement attributes changes from #78306 This is the same as PR https://github.com/rust-lang/rust/pull/78306, but `unused_doc_comments` is modified to explicitly ignore statement items (which preserves the current behavior). This shouldn't have any user-visible effects, so it can be landed without lang team discussion. --------- When the 'early' and 'late' visitors visit an attribute target, they activate any lint attributes (e.g. `#[allow]`) that apply to it. This can affect warnings emitted on sibiling attributes. For example, the following code does not produce an `unused_attributes` for `#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed the warning. ```rust trait Foo { #[allow(unused_attributes)] #[inline] fn first(); #[inline] #[allow(unused_attributes)] fn second(); } ``` However, we do not do this for statements - instead, the lint attributes only become active when we visit the struct nested inside `StmtKind` (e.g. `Item`). Currently, this is difficult to observe due to another issue - the `HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`. As a result, the `unused_doc_comments` lint will never see attributes on item statements. This commit makes two interrelated fixes to the handling of inert (non-proc-macro) attributes on statements: * The `HasAttr` impl for `StmtKind` now returns attributes for `StmtKind::Item`, treating it just like every other `StmtKind` variant. The only place relying on the old behavior was macro which has been updated to explicitly ignore attributes on item statements. This allows the `unused_doc_comments` lint to fire for item statements. * The `early` and `late` lint visitors now activate lint attributes when invoking the callback for `Stmt`. This ensures that a lint attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to sibiling attributes on an item statement. For now, the `unused_doc_comments` lint is explicitly disabled on item statements, which preserves the current behavior. The exact locatiosn where this lint should fire are being discussed in PR #78306
2020-10-25Auto merge of #77546 - lcnr:impl-trait-closure, r=eddybbors-0/+2
fix def collector for impl trait fixes #77329 We now consistently make `impl Trait` a hir owner, requiring some special casing for synthetic generic params. r? `@eddyb`
2020-10-24Fix inconsistencies in handling of inert attributes on statementsAaron Hill-3/+3
When the 'early' and 'late' visitors visit an attribute target, they activate any lint attributes (e.g. `#[allow]`) that apply to it. This can affect warnings emitted on sibiling attributes. For example, the following code does not produce an `unused_attributes` for `#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed the warning. ```rust trait Foo { #[allow(unused_attributes)] #[inline] fn first(); #[inline] #[allow(unused_attributes)] fn second(); } ``` However, we do not do this for statements - instead, the lint attributes only become active when we visit the struct nested inside `StmtKind` (e.g. `Item`). Currently, this is difficult to observe due to another issue - the `HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`. As a result, the `unused_doc_comments` lint will never see attributes on item statements. This commit makes two interrelated fixes to the handling of inert (non-proc-macro) attributes on statements: * The `HasAttr` impl for `StmtKind` now returns attributes for `StmtKind::Item`, treating it just like every other `StmtKind` variant. The only place relying on the old behavior was macro which has been updated to explicitly ignore attributes on item statements. This allows the `unused_doc_comments` lint to fire for item statements. * The `early` and `late` lint visitors now activate lint attributes when invoking the callback for `Stmt`. This ensures that a lint attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to sibiling attributes on an item statement. For now, the `unused_doc_comments` lint is explicitly disabled on item statements, which preserves the current behavior. The exact locatiosn where this lint should fire are being discussed in PR #78306
2020-10-23add tests for self with const paramsBastian Kauschke-1/+3
2020-10-22Fix const core::panic!(non_literal_str).Mara Bos-0/+1
2020-10-19Calculate visibilities once in resolveVadim Petrochenkov-9/+0
Then use them through a query based on resolver outputs
2020-10-16Lower inline const down to MIRSantiago Pastorino-0/+5
2020-10-15ensure arguments are included in count mismatch spanAndy Russell-0/+28
2020-10-14Remove unused code from rustc_hirest31-86/+0
2020-10-13Replace absolute paths with relative onesest31-1/+1
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-10-07implement nitsBastian Kauschke-1/+1
2020-10-07split SyntheticTyParamKindBastian Kauschke-0/+2
2020-10-05Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebankDylan DPC-3/+1
Replace some once(x).chain(once(y)) with [x, y] IntoIter Now that we have by-value array iterators that are [already used](https://github.com/rust-lang/rust/blob/25c8c53dd994acb3f4f7c02fe6bb46076393f8b0/compiler/rustc_hir/src/def.rs#L305-L307)... For example, ```diff - once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it) + IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it) ```
2020-10-03Replace some once(x).chain(once(y)) with [x, y] IntoIterScott McMurray-3/+1
Now that we have by-value array iterators...
2020-10-03Prevent #[doc(alias = "...")] at crate levelGuillaume Gomez-2/+2
2020-09-27Auto merge of #76955 - jyn514:refactor-diagnostics, r=eucliobors-0/+24
Refactor and fix intra-doc link diagnostics, and fix links to primitives Closes https://github.com/rust-lang/rust/issues/76925, closes https://github.com/rust-lang/rust/issues/76693, closes https://github.com/rust-lang/rust/issues/76692. Originally I only meant to fix #76925. But the hack with `has_primitive` was so bad it was easier to fix the primitive issues than to try and work around it. Note that this still has one bug: `std::primitive::i32::MAX` does not resolve. However, this fixes the ICE so I'm fine with fixing the link in a later PR. This is part of a series of refactors to make #76467 possible. This is best reviewed commit-by-commit; it has detailed commit messages. r? `@euclio`
2020-09-26Rollup merge of #77211 - est31:remove_unused_allow, r=oli-obkRalf Jung-3/+0
Remove unused #[allow(...)] statements from compiler/
2020-09-26Remove unused #[allow(...)] statements from compiler/est31-3/+0
2020-09-25Move `is_raw_guess` check in `ty::print::pretty`marmeladema-4/+1
2020-09-25Address review commentmarmeladema-4/+5
2020-09-25Rename `DefPathData::get_name()` to `DefPathData::name()`marmeladema-1/+1
2020-09-25Fix pretty-printing of `DisambiguatedDefPathData`marmeladema-9/+19
2020-09-25Implement `Display` for `DisambiguatedDefPathData` and `DefPathData`marmeladema-39/+26
2020-09-25Move from {{closure}}#0 syntax to {closure#0} for (def) path componentsmarmeladema-20/+37
2020-09-23Fix intra-doc links for primitivesJoshua Nelson-0/+24
- Add `PrimTy::name` and `PrimTy::name_str` - Use those new functions to distinguish between the name in scope and the canonical name - Fix diagnostics for primitive types - Add tests for primitives
2020-09-13review, improve note spanBastian Kauschke-4/+6
2020-09-13allow concrete self types in constsBastian Kauschke-1/+8
2020-09-05[WIP] give better errors for broken intra doc linksJoshua Nelson-0/+10
2020-09-04add track_caller to `local_def_id_to_hir_id`Bastian Kauschke-0/+1
2020-09-01hir: replace `lazy_static` by `SyncLazy` from stdmarmeladema-17/+14
2020-08-30mv compiler to compiler/mark-0/+5990