summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late
AgeCommit message (Collapse)AuthorLines
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-12/+8
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-1/+1
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Rollup merge of #90652 - matthiaskrgr:unnnec_filter_map, r=jyn514Guillaume Gomez-20/+8
use filter(|x| matches!(..)) instead of filter_map(|x| match x ... => Some(xy))
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-15/+11
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-15/+11
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-3/+1
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07Give inline const separate DefKindGary Guo-1/+1
2021-11-06Replace some uses of vec.drain(..) with vec.into_iter()The8472-5/+5
IntoIter should optimize better than Drain
2021-11-06use filter(|x| matches!(..)) instead of filter_map(|x| match x ... => Some(xy))Matthias Krüger-20/+8
2021-10-26Adds hint if a trait fails to resolve and a newly added one in Edition 2021 ↵Jakob Degen-0/+1
is suggested
2021-10-21Revert "Auto merge of #89100 - petrochenkov:localbind, r=cjgillot"Mark Rousskov-2/+1
This reverts commit 6162529a01473bbb2427fa27354cbafc3c514eee.
2021-10-20Auto merge of #89100 - petrochenkov:localbind, r=cjgillotbors-1/+2
resolve: Use `NameBinding` for local variables and generic parameters `NameBinding` is a structure used for representing any name introduction (an item, or import, or even a built-in). Except that local variables and generic parameters weren't represented as `NameBinding`s, for this reason they requires separate paths in name resolution code in several places. This PR introduces `NameBinding`s for local variables as well and simplifies all the code working with them leaving only the `NameBinding` paths.
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-3/+1
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-18resolve: Use `NameBinding` for local variables and generic parametersVadim Petrochenkov-1/+2
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-10-16Update the syn crate and adopt let_else in three more placesest31-3/+1
The syn crate has gained support for let_else syntax in version 1.0.76, see https://github.com/dtolnay/syn/pull/1057 . In the three instances that use let_else, we've sent code through an attr macro, which would create compile errors when there was no let_else support in syn. To avoid this, we ran `cargo +nightly update -p syn` for updating the syn crate.
2021-10-02resolve: Avoid comparing modules by optional def-idVadim Petrochenkov-1/+1
It makes all block modules identical during comparison
2021-09-30Rollup merge of #89248 - hkmatsumoto:suggest-similarly-named-assoc-items, ↵Manish Goregaokar-2/+36
r=estebank Suggest similarly named associated items in trait impls Fix #85942 Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types, and constants.
2021-09-29Suggest similarly named assoc items in trait implsHirochika Matsumoto-2/+36
Previously, the compiler didn't suggest similarly named associated items unlike we do in many situations. This patch adds such diagnostics for associated functions, types and constants.
2021-09-28More tracing instrumentationOli Scherer-0/+3
2021-09-27suggest path for tuple structTakayuki Maeda-1/+7
2021-09-21Rollup merge of #89078 - camsteffen:map-ref, r=cjgillotthe8472-2/+1
Cleanup: Remove needless reference in ParentHirIterator It forces an intermediate binding of `Map` which is a Copy type.
2021-09-19Rollup merge of #88966 - tmiasko:block-label-shadowing, r=petrochenkovYuki Okushi-1/+5
Check for shadowing issues involving block labels
2021-09-18Remove needless hir Map refCameron Steffen-2/+1
2021-09-18Auto merge of #88650 - sapessi:issue-77175-fix, r=estebankbors-1/+22
Skip single use lifetime lint for generated opaque types Fix: #77175 The opaque type generated by the desugaring process of an async function uses the lifetimes defined by the originating function. The DefId for the lifetimes in the opaque type are different from the ones in the originating async function - as they should be, as far as I understand, and could therefore be considered a single use lifetimes, this causes the single_use_lifetimes lint to fail compilation if explicitly denied. This fix skips the lint for lifetimes used only once in generated opaque types for an async function that are declared in the parent async function definition. More info in the comments on the original issue: 1 and 2
2021-09-15Check for shadowing issues involving block labelsTomasz Miąsko-1/+5
2021-09-13Auto merge of #87915 - estebank:fancy-spans, r=oli-obkbors-11/+6
Use smaller spans for some structured suggestions Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts
2021-09-10Keep a parent LocalDefId in SpanData.Camille GILLOT-0/+1
2021-09-04Skip single use lifetime lint for generated opaque typesStefano Buliani-1/+22
As reported in issue #77175, the opaque type generated by the desugaring process of an async function uses the lifetimes defined by the originating function. The definition ID for the lifetimes in the opaque method is different from the one in the originating async function and it could therefore be considered a single use of the lifetimne, this causes the single_use_lifetimes lint to fail compilation if explicitly denied. This fix skips the lint for lifetimes used only once in generated opaque types for an async function that are declared in the parent async function definition.
2021-09-03Detect bare blocks with type ascription that were meant to be a `struct` literalEsteban Kuber-0/+10
Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-08-31some low hanging clippy::perf fixesMatthias Krüger-3/+5
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-3/+3
2021-08-29Rollup merge of #88411 - Aaron1011:remove-session-if-let, r=estebankGuillaume Gomez-1/+0
Remove `Session.if_let_suggestions` We can instead if either the LHS or RHS types contain `TyKind::Error`. In addition to covering the case where we would have previously updated `if_let_suggestions`, this might also prevent redundant errors in other cases as well.
2021-08-28Treat macros as HIR itemsinquisitivecrystal-0/+1
2021-08-27Remove `Session.if_let_suggestions`Aaron Hill-1/+0
We can instead if either the LHS or RHS types contain `TyKind::Error`. In addition to covering the case where we would have previously updated `if_let_suggestions`, this might also prevent redundant errors in other cases as well.
2021-08-24Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiserbors-3/+7
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor` Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-22Fix more “a”/“an” typosFrank Steffahn-1/+1
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-3/+7
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-18review comment: use newtype to deduplicate logicEsteban Kuber-32/+70
2021-08-18review comment: reduce duplicationEsteban Kuber-24/+27
2021-08-18Use more accurate spans when proposing adding lifetime to itemEsteban Kuber-7/+32
2021-08-13move Constness into TraitPredicateDeadbeef-1/+1
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-11/+6
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-06Add hint for unresolved associated trait items if the trait has a single itemJakub Beránek-7/+45
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-1/+1
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2021-07-27Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnrbors-0/+6
Add hir::GenericArg::Infer In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-26Actually infer args in visitorskadmin-1/+3
2021-07-25Auto merge of #86438 - FabianWolff:issue-83693, r=jackh726bors-3/+2
Fix the ICE described in #83693 This pull request fixes #83693 and fixes #84768.
2021-07-25clippy::useless_formatMatthias Krüger-1/+1
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-18/+11