summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late.rs
AgeCommit message (Collapse)AuthorLines
2022-12-06Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillotYuki Okushi-1/+1
Fix dupe word typos
2022-12-05Rollup merge of #105230 - cjgillot:issue-104312, r=petrochenkovMatthias Krüger-1/+1
Skip recording resolution for duplicated generic params. Turns out the fix was simpler than I thought. Fixes https://github.com/rust-lang/rust/issues/104312
2022-12-05fix dupe word typosRageking8-1/+1
2022-12-04Rollup merge of #101975 - chenyukang:fix-101749, r=compiler-errorsMatthias Krüger-8/+20
Suggest to use . instead of :: when accessing a method of an object Fixes #101749 Fixes #101542
2022-12-03Skip recording resolution for duplicated generic params.Camille GILLOT-1/+1
2022-12-03fix #101749, use . instead of :: when accessing a method of an objectyukang-8/+20
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-0/+1
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-24Record in HIR whether lifetime elision was succesful.Camille GILLOT-0/+1
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-1/+1
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-1/+1
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-1/+3
2022-11-18Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgrbors-1/+8
Rollup of 8 pull requests Successful merges: - #101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1) - #103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting)) - #103405 (Detect incorrect chaining of if and if let conditions and recover) - #103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets) - #104006 (Add variant_name function to `LangItem`) - #104494 (Migrate GUI test to use functions) - #104516 (rustdoc: clean up sidebar width CSS) - #104550 (fix a typo) Failed merges: - #104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-28/+31
patterns.
2022-11-13migrating rustc_resolve to SessionDiagnostic. work in progress. startRajput, Rajat-1/+8
implement binding_shadows migrate till self-in-generic-param-default use braces in fluent message as suggested by @compiler-errors. to fix lock file issue reported by CI migrate 'unreachable label' error run formatter name the variables correctly in fluent file SessionDiagnostic -> Diagnostic test "pattern/pat-tuple-field-count-cross.rs" passed test "resolve/bad-env-capture2.rs" passed test "enum/enum-in-scope.rs" and other depended on "resolve_binding_shadows_something_unacceptable" should be passed now. fix crash errors while running test-suite. there might be more. then_some(..) suits better here. all tests passed convert TraitImpl and InvalidAsm. TraitImpl is buggy yet. will fix after receiving help from Zulip migrate "Ralative-2018" migrate "ancestor only" migrate "expected found" migrate "Indeterminate" migrate "module only" revert to the older implementation for now. since this is failing at the moment. follow the convension for fluent variable order the diag attribute as suggested in review comment fix merge error. migrate trait-impl-duplicate make the changes compatible with "Flatten diagnostic slug modules #103345" fix merge remove commented code merge issues fix review comments fix tests
2022-11-10add 'is_assign_rhs' to avoid weird suggesting 'let'yukang-4/+10
2022-11-01Rollup merge of #103706 - zbyrn:issue-101637-fix, r=estebankDylan DPC-17/+37
Fix E0433 No Typo Suggestions Fixes #48676 Fixes #87791 Fixes #96625 Fixes #95462 Fixes #101637 Follows up PR #72923 Several open issues refer to the problem that E0433 does not suggest typos like other errors normally do. This fix augments the implementation of PR #72923. **Background** When the path of a function call, e.g. `Struct::foo()`, involves names that cannot be resolved, there are two errors that could be emitted by the compiler: - If `Struct` is not found, it is ``E0433: failed to resolve: use of undeclared type `Struct` ``. - If `foo` is not found in `Struct`, it is ``E0599: no function or associated item named `foo` found for struct `Struct` in the current scope`` When a name is used as a type, `e.g. fn foo() -> Struct`, and the name cannot be resolved, it is ``E0412: cannot find type `Struct` in this scope``. Before #72923, `E0433` does not implement any suggestions, and the PR introduces suggestions for missing `use`s. When a resolution error occurs in the path of a function call, it tries to smart resolve just the type part of the path, e.g. `module::Struct` of a call to `module::Struct::foo()`. However, along with the suggestions, the smart-resolve function will report `E0412` since it only knows that it is a type that we cannot resolve instead of being a part of the path. So, the original implementation swap out `E0412` errors returned by the smart-resolve function with the real `E0433` error, but keeps the "missing `use`" suggestions to be reported to the programmer. **Issue** The current implementation only reports if there are "missing `use`" suggestions returned by the smart-resolve function; otherwise, it would fall back the normal reporting, which does not emit suggestions. But the smart-resolve function could also produce typo suggestions, which are omitted currently. Also, it seems like that not all info has been swapped out when there are missing suggestions. The error message underlining the name in the snippet still says ``not found in this scope``, which is a `E0412` messages, if there are `use` suggestions, but says the normal `use of undeclared type` otherwise. **Fixes** This fix swaps out all fields in `Diagnostic` returned by the smart-resolve function except for `suggestions` with the current error, and merges the `suggestions` of the returned error and that of the current error together. If there are `use` suggestions, the error is saved to `use_injection` to be reported at the end; otherwise, the error is emitted immediately as `Resolver::report_error` does. Some tests are updated to use the correct underlining error messages, and one additional test for typo suggestion is added to the test suite. r? rust-lang/diagnostics
2022-10-29Auto merge of #103450 - cjgillot:elision-nodedup, r=Mark-Simulacrumbors-34/+69
Do not consider repeated lifetime params for elision. Fixes https://github.com/rust-lang/rust/issues/103330
2022-10-27Only ban duplication across parameters.Camille GILLOT-31/+66
2022-10-27Remove redundant bracesByron Zhong-4/+3
2022-10-27Fix E0433 diagnostics ignoring typo suggestions and outputing wrong messageByron Zhong-16/+37
2022-10-23Do not consider repeated lifetime params for elision.Camille GILLOT-5/+5
2022-10-20Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obkMatthias Krüger-3/+3
Fix `SelfVisitor::is_self_ty` ICE Fixes #103202
2022-10-20fix rust-lang#101880: suggest let for assignment, and some code refactoryukang-0/+8
2022-10-20check if impl_self is `Some`Takayuki Maeda-1/+1
2022-10-19Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726Dylan DPC-6/+11
Consider patterns in fn params in an `Elided(Infer)` lifetime rib. Fixes https://github.com/rust-lang/rust/issues/103210
2022-10-19fix `SelfVisitor::is_self_ty` ICETakayuki Maeda-3/+3
2022-10-18Consider patterns in fn params in an `Elided(Infer)` lifetime rib.Camille GILLOT-6/+11
2022-10-15Rollup merge of #102884 - petrochenkov:liferib, r=cjgillotDylan DPC-65/+77
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-13resolve: Regroup lifetime rib kinds to account for their purposeVadim Petrochenkov-16/+23
2022-10-13resolve: Remove redundant item lifetime ribsVadim Petrochenkov-37/+28
and cleanup lifetime rib walking loops
2022-10-13resolve: Add some asserts for unexpected lifetime rib combinationsVadim Petrochenkov-12/+26
2022-10-12fix #102946Takayuki Maeda-1/+1
2022-10-11Rollup merge of #102889 - petrochenkov:partres, r=cjgillotMatthias Krüger-13/+15
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
2022-10-11Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkovMatthias Krüger-3/+30
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-11Report duplicate definitions in trait impls during resolution.Camille GILLOT-3/+30
2022-10-11rustc_hir: Less error-prone methods for accessing `PartialRes` resolutionVadim Petrochenkov-13/+15
2022-10-10Move lifetime resolution module to rustc_hir_analysis.Camille GILLOT-1/+0
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-5/+5
2022-10-05Delay function resolution error until typeckMichael Goulet-0/+2
2022-09-29Shrink `hir::def::Res`.Nicholas Nethercote-23/+24
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29Change the "dummy self type".Nicholas Nethercote-2/+2
Because this is the only occurrence of a `Res::SelfTy` with `None` and `None` fields, and the next commit will rely on those not being present.
2022-09-24Only record extra lifetime params for async trait fn with no bodyMichael Goulet-38/+40
2022-09-24Resolve async fn signature even without body (in trait)Michael Goulet-3/+2
2022-09-12Remove `path_span` argument to the `visit_path_segment` methods.Nicholas Nethercote-5/+5
The `visit_path_segment` method of both the AST and HIR visitors has a `path_span` argument that isn't necessary. This commit removes it. There are two very small and inconsequential functional changes. - One call to `NodeCollector::insert` now is passed a path segment identifier span instead of a full path span. This span is only used in a panic message printed in the case of an internal compiler bug. - Likewise, one call to `LifetimeCollectVisitor::record_elided_anchor` now uses a path segment identifier span instead of a full path span. This span is used to make some `'_` lifetimes.
2022-09-09Make async fn in traits workMichael Goulet-1/+1
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-7/+7
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-5/+2
by module
2022-09-01Directly use the `instrument` macro instead of its full pathOli Scherer-9/+9
2022-08-23Remove FnItemRibKind.Camille GILLOT-16/+9
2022-08-23Improve local generic parameter suggestions.Camille GILLOT-9/+9