about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2020-11-03Expand `NtExpr` tokens only in key-value attributesVadim Petrochenkov-22/+0
2020-11-01Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkovbors-27/+55
Suggest calling associated `fn` inside `trait`s When calling a function that doesn't exist inside of a trait's associated `fn`, and another associated `fn` in that trait has that name, suggest calling it with the appropriate fully-qualified path. Expand the label to be more descriptive. Prompted by the following user experience: https://users.rust-lang.org/t/cannot-find-function/50663
2020-10-30Add back missing commentsJoshua Nelson-0/+1
2020-10-30Fix even more clippy warningsJoshua Nelson-169/+91
2020-10-29Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkovbors-4/+3
[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path This improves the performance of the `resolve_crate` function by 30% for a very large single file crate with auto-generated C bindings. cc `@rylev`
2020-10-29Rollup merge of #78224 - lcnr:repeat-expr, r=varkorYuki Okushi-18/+70
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-28[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot pathWesley Wiser-4/+3
This improves the performance of the `resolve_crate` function by 30% for a very large single file crate with auto-generated C bindings.
2020-10-26Suggest calling associated `fn` inside `trait`sEsteban Küber-27/+55
When calling a function that doesn't exist inside of a trait's associated `fn`, and another associated `fn` in that trait has that name, suggest calling it with the appropriate fully-qualified path. Expand the label to be more descriptive. Prompted by the following user experience: https://users.rust-lang.org/t/cannot-find-function/50663
2020-10-26resolve: private fields in tuple struct ctor diagDavid Wood-44/+61
This commit improves the diagnostic emitted when a tuple struct is being constructed which has private fields so that private fields are labelled and the message is improved. Signed-off-by: David Wood <david@davidtw.co>
2020-10-25Rollup merge of #77984 - Aaron1011:fix/macro-mod-weird-parent, r=petrochenkovYuki Okushi-7/+41
Compute proper module parent during resolution Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-25Auto merge of #77546 - lcnr:impl-trait-closure, r=eddybbors-4/+4
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-24Compute proper module parent during resolutionAaron Hill-7/+41
Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-24resolve: Relax macro resolution consistency check to account for any errorsVadim Petrochenkov-4/+4
2020-10-22min_const_generics: allow ty param in repeat exprBastian Kauschke-18/+70
2020-10-22Auto merge of #78134 - bugadani:arena-nodrop, r=lcnrbors-7/+5
Use `DroplessArena` where we know the type doesn't need drop This PR uses a single `DroplessArena` in resolve instead of three separate `TypedArena`s. `DroplessArena` checks that the type indeed doesn't need drop, so in case the types change, this will result in visible failures.
2020-10-20Resolve: Use dropless arena for types that don't need dropDániel Buga-7/+5
2020-10-19Calculate visibilities once in resolveVadim Petrochenkov-81/+131
Then use them through a query based on resolver outputs
2020-10-18Rollup merge of #78048 - blyxxyz:e0424-improve-self-placement, r=lcnrYuki Okushi-3/+5
Suggest correct place to add `self` parameter when inside closure It would incorrectly suggest adding it as a parameter to the closure instead of the containing function. [For example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1936bcd1e5f981573386e0cee985c3c0): ``` help: add a `self` receiver parameter to make the associated `fn` a method | 5 | let _ = || self&self; | ^^^^^ ``` `DiagnosticMetadata.current_function` is only used for these messages so tweaking its behavior should be ok.
2020-10-17Suggest correct place to add `self` parameter when inside closureJan Verbeek-3/+5
It would incorrectly suggest adding it as a parameter to the closure instead of the containing function.
2020-10-17resolve: Do not put nonexistent crate `meta` into preludeVadim Petrochenkov-3/+0
2020-10-17Rollup merge of #77855 - ↵Yuki Okushi-62/+88
davidtwco:pr-77341-follow-up-non-constructable-variants, r=estebank resolve: further improvements to "try using the enum's variant" diagnostic Follow-up on https://github.com/rust-lang/rust/pull/77341#issuecomment-702738281. This PR improves the diagnostic modified in #77341 to suggest not only those variants which do not have fields, but those with fields (by suggesting with placeholders). In addition, the wording of the tuple-variant-only case is improved slightly. I've not made further changes to the tuple-variant-only case (e.g. to only suggest variants with the correct number of fields) because I don't think I have enough information to do so reliably (e.g. in the case where there is an attempt to construct a tuple variant, I have no information on how many fields were provided; and in the case of pattern matching, I only have a slice of spans and would need to check for things like `..` in those spans, which doesn't seem worth it). r? @estebank
2020-10-17Rollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebankYuki Okushi-0/+11
Suggest imports of unresolved macros Closes https://github.com/rust-lang/rust/issues/75191.
2020-10-15resolve: improve "try using tuple struct" messageDavid Wood-11/+11
This commit improves the tuple struct case added in rust-lang/rust#77341 so that the context is mentioned in more of the message. Signed-off-by: David Wood <david@davidtw.co>
2020-10-15resolve: suggest variants with placeholdersDavid Wood-60/+86
This commit improves the diagnostic modified in rust-lang/rust#77341 to suggest not only those variants which do not have fields, but those with fields (by suggesting with placeholders). Signed-off-by: David Wood <david@davidtw.co>
2020-10-14Rollup merge of #77825 - ethanboxx:min_const_generics_diagnostic, r=lcnrYuki Okushi-15/+8
`min_const_generics` diagnostics improvements As disscussed in [zulip/project-const-generics/non-trivial anonymous constant](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/non-trivial.20anonymous.20constants). This is my first PR on the compiler. @lcnr is mentoring me on this PR. Related to #60551.
2020-10-12A little rewordingEthan Brierley-1/+1
Co-authored-by: varkor <github@varkor.com>
2020-10-12Remove a little jargon from errorEthan Brierley-1/+1
Co-authored-by: varkor <github@varkor.com>
2020-10-12Make error help clearerEthan Brierley-1/+1
Co-authored-by: varkor <github@varkor.com>
2020-10-11`min_const_generics` diagnostics improvementsEthan Brierley-15/+8
2 3
2020-10-09address review commentsEsteban Küber-8/+16
2020-10-09Add docstringEsteban Küber-0/+2
2020-10-09Given `<T as Trait>::A: Ty` suggest `T: Trait<A = Ty>`Esteban Küber-0/+129
Fix #75829
2020-10-09Suggest removing bounds even when potential typoEsteban Küber-15/+21
2020-10-09Tweak output and add test casesEsteban Küber-5/+51
2020-10-09Point out why a trait is expected on `Struct + 'lt`Esteban Küber-1/+17
2020-10-07Auto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, ↵bors-21/+124
r=estebank resolve: improve "try using the enum's variant" Fixes #73427. This PR improves the "try using the enum's variant" suggestion: - Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only emitted for variants that have no fields (since the suggestion can't know what value fields would have). - Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided. - A help message is added which mentions the variants which are no longer suggested. All of the diagnostic logic introduced by this PR is separated from the normal code path for a successful compilation. r? `@estebank`
2020-10-07fix def collector for impl traitBastian Kauschke-4/+4
2020-10-05Rollup merge of #77439 - varkor:min_const_generics-tests, r=lcnr,estebankDylan DPC-2/+2
Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics` Closes https://github.com/rust-lang/rust/issues/61410. Adds `min_const_generics` tests for: - https://github.com/rust-lang/rust/issues/73727 - https://github.com/rust-lang/rust/issues/72293 - https://github.com/rust-lang/rust/issues/67375 - https://github.com/rust-lang/rust/issues/75153 - https://github.com/rust-lang/rust/issues/71922 - https://github.com/rust-lang/rust/issues/69913 - https://github.com/rust-lang/rust/issues/67945 - https://github.com/rust-lang/rust/issues/69239 Adds `const_generics` tests for: - https://github.com/rust-lang/rust/issues/67375 - https://github.com/rust-lang/rust/issues/75153 - https://github.com/rust-lang/rust/issues/71922 - https://github.com/rust-lang/rust/issues/69913 - https://github.com/rust-lang/rust/issues/67945 - https://github.com/rust-lang/rust/issues/69239 (I only added separate `min_const_generics` and `const_generics` tests if they were handled differently by the two features.) We need to figure out how to deduplicate when `const_generics` is stabilised, but we can discuss that later. For now, we should be checking neither feature breaks, so require regression tests for both. I've given them identical names when I've added both, which should make it easier to spot them later. r? @lcnr
2020-10-03Replace "non trivial" with "non-trivial"varkor-2/+2
2020-10-03Rollup merge of #77421 - petrochenkov:globtravel, r=nagisaJonas Schievink-11/+2
Revert "resolve: Avoid "self-confirming" import resolutions in one more case" And remove the assert that https://github.com/rust-lang/rust/pull/70236 tried to avoid instead. Closes https://github.com/rust-lang/rust/issues/74556.
2020-10-02resolve: prohibit anon const non-static lifetimesDavid Wood-0/+33
This commit modifies name resolution to emit an error when non-static lifetimes are used in anonymous constants when the `min_const_generics` feature is enabled. Signed-off-by: David Wood <david@davidtw.co>
2020-10-02Revert "resolve: Avoid "self-confirming" import resolutions in one more case"Vadim Petrochenkov-11/+2
2020-09-30Improve wording for external crate resolution errorCamelid-1/+1
I think it reads better this way.
2020-09-30Don't suggest macros that out of scopeTemirkhan Myrzamadi-2/+9
2020-09-30Suggest imports of unresolved macrosTemirkhan Myrzamadi-0/+4
2020-09-29resolve: improve "try using the enum's variant"David Wood-21/+124
This commit improves the "try using the enum's variant" suggestion: - Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only emitted for variants that have no fields (since the suggestion can't know what value fields would have). - Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided. - A help message is added which mentions the variants which are no longer suggested. Signed-off-by: David Wood <david@davidtw.co>
2020-09-23/nightly/nightly-rustcErik Hofmayer-1/+1
2020-09-23Updated html_root_url for compiler cratesErik Hofmayer-1/+1
2020-09-21Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPCecstatic-morse-5/+2
use if let instead of single match arm expressions use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
2020-09-20Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnrRalf Jung-2/+2
use matches!() macro for simple if let conditions