about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-11-28Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.Nicholas Nethercote-1/+1
We already use a mix of `Literal` and `Lit`. The latter is better because it is shorter without causing any ambiguity.
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-4/+4
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-0/+6
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-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-4/+4
2022-11-27make simple check of prinf function.Vincenzo Palazzo-0/+8
With this commit we start to make some simple check when the name resolution fails, and we generate some helper message in case the name is a C name like in the case of the `printf` and suggest the correct rust method. Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-11-26Auto merge of #104730 - petrochenkov:modchild5, r=cjgillotbors-2/+4
rustc_metadata: Switch module children decoding to an iterator Previously https://github.com/rust-lang/rust/pull/103578, https://github.com/rust-lang/rust/pull/103524 and previous PRs simplified it as much as possible. A couple of cleanup commits is also added. r? `@cjgillot`
2022-11-25fix the crossing function issueyukang-1/+3
2022-11-25Auto merge of #104602 - petrochenkov:effvisperf5, r=oli-obkbors-45/+71
privacy: Fix more (potential) issues with effective visibilities Continuation of https://github.com/rust-lang/rust/pull/103965. See individual commits for more detailed description of the changes. The shortcuts removed in https://github.com/rust-lang/rust/pull/104602/commits/4eb63f618e601efee657d24cd4e8833fb03fac4c and https://github.com/rust-lang/rust/pull/104602/commits/c7c7d1672739e38c8d39ae861b284486aefd5b48 could actually be correct (or correct after some tweaks), but they used global reasoning like "we can skip this update because if the code compiles then some other update should do the same thing eventually". I have some expertise in this area, but I still have doubt whether such global reasoning was correct or not, especially in presence of all possible exotic cases with imports. After this PR all table changes should be "locally correct" after every update, even if it may be overcautious. If similar optimizations are introduced again they will need detailed comments explaining why it's legal to do what they do and providing proofs. Fixes https://github.com/rust-lang/rust/issues/104249. Fixes https://github.com/rust-lang/rust/issues/104539.
2022-11-25fix #104700, account for item-local in inner scope for E0425yukang-1/+21
2022-11-24Rollup merge of #104747 - petrochenkov:ctorfields, r=cjgillotMatthias Krüger-20/+15
resolve: Don't use constructor def ids in the map for field names Also do some minor cleanup to insertion of those field names. Addresses a FIXME left in https://github.com/rust-lang/rust/pull/103578.
2022-11-24Record in HIR whether lifetime elision was succesful.Camille GILLOT-0/+6
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-24effective visibility: Stop recalculating current private visibilityVadim Petrochenkov-2/+16
It becomes relatively expensive if done often and shows up during perf profiling.
2022-11-24effective visibility: Always add table entries for nodes used as parentsVadim Petrochenkov-7/+14
Previously if the parent was not in the table, and there was nothing to inherit from, the child's private visibility was used, but that's not correct - the parent may have a larger visibility so we should set it to at least the parent's private visibility. That parent's private visibility is also inserted into the table for caching, so it's not recalculated later if used again.
2022-11-24effective visibility: Fix private visibility calculation for modulesVadim Petrochenkov-4/+6
Optimizations removed in the previous commit required this function to behave incorrectly, but now those optimizations are gone so we can fix the bug. Fixes https://github.com/rust-lang/rust/issues/104249
2022-11-24effective visibility: Remove questionable optimizationsVadim Petrochenkov-30/+20
First, they require eagerly calculating private visibility (current normal module), which is somewhat expensive. Private visibilities are also lost once calculated, instead of being cached in the table. Second, I cannot prove that the optimizations are correct. Maybe they can be partially reinstated in the future in cases when it's cheap and provably correct to do them. They will also probably be merged into `fn update` in that case. Partially fixes https://github.com/rust-lang/rust/issues/104249 Fixes https://github.com/rust-lang/rust/issues/104539
2022-11-24effective visibility: Satisfy borrow checker to use resolver lazily from a ↵Vadim Petrochenkov-13/+26
closure
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-1/+3
2022-11-23resolve: Don't use constructor def ids in the map for field namesVadim Petrochenkov-20/+15
Also do some minor cleanup to insertion of those field names
2022-11-22rustc_metadata: Switch module children decoding to an iteratorVadim Petrochenkov-2/+4
2022-11-22Auto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPCbors-7/+2
Rollup of 6 pull requests Successful merges: - #104295 (Check generics parity before collecting return-position `impl Trait`s in trait) - #104464 (Reduce exceptions overallocation on non Windows x86_64) - #104615 (Create def_id for async fns during lowering) - #104669 (Only declare bindings for if-let guards once per arm) - #104701 (Remove a lifetime resolution hack from `compare_predicate_entailment`) - #104710 (disable strict-provenance-violating doctests in Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-22Rollup merge of #104615 - spastorino:create-async-def-id-in-lowering, ↵Dylan DPC-7/+2
r=compiler-errors Create def_id for async fns during lowering r? `@compiler-errors`
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-33/+22
2022-11-19Create def_id for async fns during loweringSantiago Pastorino-7/+2
2022-11-18Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgrbors-363/+665
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-18Rollup merge of #101162 - rajputrajat:master, r=davidtwcoMatthias Krüger-363/+665
Migrate rustc_resolve to use SessionDiagnostic, part # 1 crate a somewhat on larger size, so plz allow some time to get it finished.
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-3/+6
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-40/+41
patterns.
2022-11-14Rollup merge of #104364 - petrochenkov:docice2, r=GuillaumeGomezMatthias Krüger-0/+5
rustdoc: Resolve doc links in external traits having local impls For external impls it was done in https://github.com/rust-lang/rust/pull/103192 right away, but the local impl case was forgotten. Fixes https://github.com/rust-lang/rust/issues/104145.
2022-11-14Rollup merge of #104349 - rustaceanclub:master, r=oli-obkMatthias Krüger-1/+1
fix some typos in comments
2022-11-13Rollup merge of #104315 - SparkyPotato:fix-104276, r=cjgillotMatthias Krüger-1/+3
Improve spans with `use crate::{self}` Fixes #104276. The error becomes: ``` error: crate root imports need to be explicitly named: `use crate as name;` --> src/lib.rs.rs:1:13 | 1 | use crate::{self}; | ^^^^ warning: unused import: `self` --> src/lib.rs:1:13 | 1 | use crate::{self}; | ^^^^ | = note: `#[warn(unused_imports)]` on by default ```
2022-11-13rustdoc: Resolve doc links in external traits having local implsVadim Petrochenkov-0/+5
2022-11-13migrating rustc_resolve to SessionDiagnostic. work in progress. startRajput, Rajat-363/+665
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-13move span to `self` instead of `crate`SparkyPotato-1/+3
2022-11-13fix some typos in commentscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-12Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebankDylan DPC-12/+16
Unhide unknown spans r? ```@estebank```
2022-11-12Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obkDylan DPC-1/+1
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2022-11-11Rollup merge of #103531 - chenyukang:yukang/fix-103474, r=estebankManish Goregaokar-12/+12
Suggest calling the instance method of the same name when method not found Fixes #103474
2022-11-11Print all labels, even if they have no span. Fall back to main item's span.Oli Scherer-12/+16
2022-11-10Rollup merge of #104186 - chenyukang:yukang/fix-104086-let-binding-issue, ↵Manish Goregaokar-18/+17
r=oli-obk Tighten the 'introduce new binding' suggestion Fixes #104086
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-3/+3
2022-11-09DiagnosticBuilder -> DiagnosticMichael Goulet-5/+5
2022-11-10add 'is_assign_rhs' to avoid weird suggesting 'let'yukang-25/+17
2022-11-09fix tests and code cleanupyukang-5/+1
2022-11-09Fix #104086, Tighten the 'introduce new binding' suggestionyukang-7/+18
2022-11-08Auto merge of #103965 - petrochenkov:effvisperf3, r=oli-obkbors-94/+147
resolve: More detailed effective visibility tracking for imports Per-`DefId` tracking is not enough, due to glob imports in particular, which have a single `DefId` for the whole glob import item. We need to track this stuff per every introduced name (`NameBinding`). Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there. Later commits add some debug-only invariant checking and optimiaztions to mitigate regressions in https://github.com/rust-lang/rust/pull/103965#issuecomment-1304256445. This is a bugfix and continuation of https://github.com/rust-lang/rust/pull/102026.
2022-11-05Rollup merge of #103927 - ↵Matthias Krüger-2/+13
fee1-dead-contrib:E0425-no-typo-when-pattern-matching, r=cjgillot Do not make typo suggestions when suggesting pattern matching Fixes #103909.
2022-11-05Do not make typo suggestions when suggesting pattern matchingDeadbeef-2/+13
Fixes #103909.
2022-11-05resolve: Fill effective visibilities for import def ids in a separate passVadim Petrochenkov-32/+33
This should result in less update calls than doing it repeatedly during the fix point iteration.