Commit Graph

1620 Commits

Author SHA1 Message Date
bors a5406feb1c Auto merge of #103158 - Bryanskiy:resolve_perf, r=petrochenkov
Perf improvements for effective visibility calculating

related to https://github.com/rust-lang/rust/pull/102026
r? `@petrochenkov`
2022-10-26 02:30:18 +00:00
yukang 32a2f0dddb suggest calling the method of the same name when method not found 2022-10-26 00:45:29 +08:00
Bryanskiy a9447bb9d0 Perf improvements for effective visibility calculating 2022-10-25 15:15:18 +03:00
Vadim Petrochenkov 919673ea03 rustc_middle: Rearrange resolver outputs structures slightly 2022-10-25 15:42:29 +04:00
Yuki Okushi e47d222a94 Rollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiser
Change terminology for assoc method suggestions when they are not called

Fixes #103325

```@rustbot``` label +A-diagnostics
2022-10-25 08:01:27 +09:00
Aaron Hill 7d82cadd97 Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error 2022-10-24 13:40:07 -05:00
Michael Howell 3df030d441 Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebank
Add diagnostic for calling a function with the same name with unresolved Macro

Fixes #103112
2022-10-23 14:48:15 -07:00
Camille GILLOT 47704bbcc0 Do not consider repeated lifetime params for elision. 2022-10-23 19:36:19 +00:00
Dylan DPC 0b3e018137 Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obk
resolve: Revert "Set effective visibilities for imports more precisely"

In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components.

Fixes https://github.com/rust-lang/rust/issues/102352
r? `@oli-obk`
2022-10-23 15:20:18 +05:30
Dylan DPC 518d5ebc81 Rollup merge of #101908 - chenyukang:fix-101880, r=estebank
Suggest let for assignment, and some code refactor

Fixes #101880
2022-10-23 15:20:16 +05:30
clubby789 717bf35366 Different suggestions for when associated functions are referred to 2022-10-21 14:38:44 +01:00
Dylan DPC 41a1cfdbaf Rollup merge of #103111 - cjgillot:shadow-label, r=estebank
Account for hygiene in typo suggestions, and use them to point to shadowed names

Fixes https://github.com/rust-lang/rust/issues/97459

r? `@estebank`
2022-10-21 17:29:59 +05:30
Matthias Krüger 7ee4b218a8 Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obk
Fix `SelfVisitor::is_self_ty` ICE

Fixes #103202
2022-10-20 22:42:38 +02:00
yukang eb68e27e4c fix rust-lang#101880: suggest let for assignment, and some code refactor 2022-10-20 22:54:02 +08:00
bors 53728ff751 Auto merge of #103185 - chenyukang:yukang/fix-span-next-point, r=davidtwco
Fix the bug of next_point in source_map

There is a bug in `next_point`, the new span won't move to next position when be called in the first time.

For this reason, our current code is working like this:
1. When we really want to move to the next position, we called two times of `next_point`
2. Some code which use `next_point` actually done the same thing with `shrink_to_hi`

This fix make sure when `next_point` is called, span will move with the width at least 1, and also work correctly in the scenario of multiple bytes.

Ref: https://github.com/rust-lang/rust/pull/103140#discussion_r997710998

r? `@davidtwco`
2022-10-20 10:40:09 +00:00
Takayuki Maeda 9a9e2fe15f check if impl_self is Some 2022-10-20 14:10:52 +09:00
yukang f90bf50d47 fix span for suggestion 2022-10-20 11:55:30 +08:00
yukang 1225c3f6b8 fix #103112, add diagnostic for calling a function with the same name when a Macro is not found 2022-10-20 11:55:30 +08:00
Vadim Petrochenkov ba4834c092 resolve: Revert "Set effective visibilities for imports more precisely" 2022-10-19 18:42:47 +04:00
Dylan DPC 32159e3fa4 Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726
Consider patterns in fn params in an `Elided(Infer)` lifetime rib.

Fixes https://github.com/rust-lang/rust/issues/103210
2022-10-19 14:05:54 +05:30
Takayuki Maeda 0b2716415f fix SelfVisitor::is_self_ty ICE 2022-10-19 11:17:46 +09:00
Camille GILLOT 9c3bf4de55 Consider patterns in fn params in an Elided(Infer) lifetime rib. 2022-10-18 21:25:38 +00:00
yukang 0af255a5aa Fix the bug of next_point in span 2022-10-18 02:59:38 +08:00
bors 1536ab1b38 Auto merge of #103096 - petrochenkov:indresdoc, r=cjgillot
resolve: Shadow erroneous glob imports with erroneous single imports

If such shadowing doesn't happen we end up in a weird state that may cause ICEs.
(In non-erroneous cases single imports always shadow glob imports too.)

Fixes https://github.com/rust-lang/rust/issues/100047
Fixes https://github.com/rust-lang/rust/issues/100241
2022-10-17 02:06:25 +00:00
bors b8b5caee04 Auto merge of #102026 - Bryanskiy:resolve_update, r=petrochenkov
Populate effective visibilities in 'rustc_resolve'

Next part of RFC https://github.com/rust-lang/rust/issues/48054.
previous: https://github.com/rust-lang/rust/pull/101713

`@rustbot` author
r? `@petrochenkov`
2022-10-16 20:34:38 +00:00
Bryanskiy 496ccd982c Populate effective visibilities in 'rustc_resolve' 2022-10-16 21:47:14 +03:00
Camille GILLOT 4bbb163b5d Point to shadowed name when it exists. 2022-10-16 09:03:21 +00:00
Camille GILLOT 6d947e6d48 Account for hygiene when suggesting typos. 2022-10-16 08:56:39 +00:00
Vadim Petrochenkov f767f2297d resolve: Shadow erroneous glob imports with erroneous single imports 2022-10-16 00:10:16 +04:00
Dylan DPC 39ff2a60d6 Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot
resolve: Some cleanup, asserts and tests for lifetime ribs

Follow up to https://github.com/rust-lang/rust/pull/98279 and friends.
r? ``@cjgillot``
2022-10-15 15:45:31 +05:30
Dylan DPC 77064b7f0a Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
More dupe word typos

I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14 16:19:15 +05:30
Rageking8 7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Dylan DPC 48f950c527 Rollup merge of #102956 - TaKO8Ki:fix-102946, r=fee1-dead
Use `full_res` instead of `expect_full_res`

Fixes #102946
Fixes #102978
2022-10-13 18:19:21 +05:30
Vadim Petrochenkov f634106591 resolve: Regroup lifetime rib kinds to account for their purpose 2022-10-13 13:32:24 +04:00
Vadim Petrochenkov e94ec30dc4 resolve: Remove redundant item lifetime ribs
and cleanup lifetime rib walking loops
2022-10-13 13:32:24 +04:00
Vadim Petrochenkov e8a6e60c5d resolve: Add some asserts for unexpected lifetime rib combinations 2022-10-13 13:32:24 +04:00
Takayuki Maeda b11dddd1c1 fix #102946 2022-10-12 19:03:46 +09:00
Dylan DPC 252ce10bb0 Rollup merge of #102913 - SparrowLii:import-candidate, r=compiler-errors
unify `IsPattern` and `IsImport` enum in `show_candidates`

Follow-up of #102876
A binding cannot appear in both pattern and import at the same time, so it makes sense to unify them
r? `@compiler-errors`
2022-10-12 11:11:26 +05:30
SparrowLii a7f58af9fe unify IsPattern and IsImport enum 2022-10-12 08:46:52 +08:00
Matthias Krüger cb67283392 Rollup merge of #102889 - petrochenkov:partres, r=cjgillot
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
2022-10-11 18:59:50 +02:00
Matthias Krüger 6d58ff7fe6 Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov
Check uniqueness of impl items by trait item when applicable.

When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items.  This means that a plain item and one generated by a macro 2.0 do not collide.

This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls.

This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice.

There should be no stable breakage, since macros 2.0 are still unstable.

r? ``@petrochenkov``
cc ``@RalfJung``

Fixes https://github.com/rust-lang/rust/issues/71614.
2022-10-11 18:59:45 +02:00
Yuki Okushi 98764c0c72 Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Move lifetime resolution module to rustc_hir_analysis.

Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`.  It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.
2022-10-11 18:37:55 +09:00
Camille GILLOT 152cd63226 Report duplicate definitions in trait impls during resolution. 2022-10-11 06:24:51 +00:00
Vadim Petrochenkov 1a8f177772 rustc_hir: Less error-prone methods for accessing PartialRes resolution 2022-10-11 09:04:52 +04:00
Matthias Krüger 0bd1cba98b Rollup merge of #102876 - SparrowLii:import-candidate, r=fee1-dead
suggest candidates for unresolved import

Currently we prompt suggestion of candidates(help notes of `use xxx::yyy`) for names which cannot be resolved, but we don't do that for import statements themselves that couldn't be resolved. It seems reasonable to add candidate help information for these statements as well.
Fixes #102711
2022-10-10 20:47:34 +02:00
Camille GILLOT a474ec50b7 Move lifetime resolution module to rustc_hir_analysis. 2022-10-10 17:40:52 +00:00
Dylan DPC 81b9d0b1d1 Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10 13:43:43 +05:30
SparrowLii 0571b0af65 suggest candidates for unresolved import 2022-10-10 11:14:32 +08:00
Michael Goulet d3bd6beb97 Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
Yuki Okushi 0db05f16c8 Rollup merge of #102323 - Stoozy:master, r=cjgillot
Trying to suggest additional lifetime parameter

``@cjgillot`` This is what I have so far for #100615
2022-10-10 10:23:04 +09:00