about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-16531/+0
2020-08-30Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkovbors-3/+7
Fix intra-doc links for cross-crate re-exports of default trait methods The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in `librustdoc/fold.rs` to avoid borrowing the `extern_traits` RefCell more than once at a time. However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!): 0. `x.py build --stage 1` builds the standard library and creates a sysroot 1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above) 2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros 3. `rustdoc` later tries to resolve some path in a doc link 4. suggestion logic fires and loads "extern prelude" crates by name 5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros `rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set. It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here. Fixes https://github.com/rust-lang/rust/issues/73829. r? @GuillaumeGomez
2020-08-30resolve: Don't speculatively load crates if this is a speculative resolutionJoshua Nelson-3/+7
This avoids a rare rustdoc bug where loading `core` twice caused a 'cannot find a built-in macro' error: 1. `x.py build --stage 1` builds the standard library and creates a sysroot 2. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above) 3. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros 4. `rustdoc` later tries to resolve some path in a doc link 5. suggestion logic fires and loads "extern prelude" crates by name 6. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros This fixes step 5. by not running suggestion logic if this is a speculative resolution. Additionally, it marks `resolve_ast_path` as a speculative resolution.
2020-08-30Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasperbors-0/+3
Account for async functions when suggesting new named lifetime Fix #75850.
2020-08-23Account for async functions when suggesting new named lifetimeEsteban Küber-0/+3
Fix #75850.
2020-08-23resolve: Add comments to `traits_in_scope`Joshua Nelson-0/+3
2020-08-22resolve: Add public entrypoint `traits_in_module`Joshua Nelson-0/+25
- Consider the implicit prelude as well
2020-08-22resolve: Split `ensure_traits` into a separate functionJoshua Nelson-16/+25
2020-08-22resolve: Move `get_traits_in_module_containing_item` to ResolverJoshua Nelson-81/+93
2020-08-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-12/+12
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-12/+12
2020-08-16resolve: support `GenericBound::LangItemTrait`David Wood-0/+28
This commit modifies name resolution to ensure that new scopes are introduced from lang-item generic bounds. Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-16hir: introduce `QPath::LangItem`David Wood-31/+0
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-08-15replaced log with tracingGurpreet Singh-10/+15
2020-08-14Rollup merge of #75448 - lcnr:rn-as_local_hir_id, r=davidtwcoTyler Mandry-7/+8
merge `as_local_hir_id` with `local_def_id_to_hir_id` `as_local_hir_id` was defined as just calling `local_def_id_to_hir_id` and I think that having two different ways to call the same method is somewhat confusing. Don't really care about which of these 2 methods we want to keep. Does this require an MCP, considering that these methods are fairly frequently used?
2020-08-14Rollup merge of #75509 - estebank:coming-merrily-from-java-land, r=lcnrTyler Mandry-4/+60
Tweak suggestion for `this` -> `self` * When referring to `this` in associated `fn`s always suggest `self`. * Point at ident for `fn` lacking `self` * Suggest adding `self` to assoc `fn`s when appropriate _Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14review comment: suggestion message wordingEsteban Küber-1/+2
2020-08-13Suggest adding `&self` when accessing `self` in static assoc `fn`Esteban Küber-15/+46
2020-08-13Tweak suggestion for `this` -> `self`Esteban Küber-3/+27
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-7/+8
2020-08-13Rollup merge of #75372 - estebank:lt-sugg-in-type, r=lcnrYuki Okushi-36/+172
Fix suggestion to use lifetime in type and in assoc const _Do not merge until #75363 has landed, as it has the test case for this._ * Account for associated types * Associated `const`s can't have generics (fix #74264) * Do not suggest duplicate lifetimes and suggest `for<'a>` more (fix #72404)
2020-08-11Suggest using `'static` in assoc consts and suggest when multiple lts are neededEsteban Küber-6/+60
2020-08-11review comment: simplify code by using slice patEsteban Küber-9/+10
2020-08-11When suggesting `for` lts, consider existing lifetime namesEsteban Küber-20/+84
Fix #72404.
2020-08-11Assoc `const`s don't have genericsEsteban Küber-3/+14
Fix #74264.
2020-08-11Fix suggestion to use lifetime in typeEsteban Küber-1/+7
2020-08-11Detect tuple variants used as struct pattern and suggest correct patternEsteban Küber-1/+10
2020-08-11Rollup merge of #75353 - estebank:tiny, r=jyn514Yuki Okushi-3/+3
Tiny cleanup, remove unnecessary `unwrap` Remove unnecessary `unwrap`.
2020-08-10Add missing primary labelEsteban Küber-1/+5
2020-08-10Point at item definition in foreign cratesEsteban Küber-4/+16
2020-08-10Do not suggest similarly named enclosing itemEsteban Küber-13/+34
2020-08-10Tweak ordering of suggestionsEsteban Küber-6/+10
Modify logic to make it easier to follow and recover labels that would otherwise be lost.
2020-08-09Small cleanupEsteban Küber-3/+3
Remove unnecessary `unwrap`.
2020-08-08Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkovbors-29/+24
Remove `librustc_ast` session globals By moving the data onto `Session`. r? @petrochenkov
2020-08-08Auto merge of #75276 - JohnTitor:rollup-rz4hs0w, r=JohnTitorbors-1/+1
Rollup of 7 pull requests Successful merges: - #75224 (Don't call a function in function-arguments-naked.rs) - #75237 (Display elided lifetime for non-reference type in doc) - #75250 (make MaybeUninit::as_(mut_)ptr const) - #75253 (clean up const-hacks in int endianess conversion functions) - #75259 (Add missing backtick) - #75267 (Small cleanup) - #75270 (fix a couple of clippy findings) Failed merges: r? @ghost
2020-08-08Rollup merge of #75267 - estebank:cleanup, r=Dylan-DPCYuki Okushi-1/+1
Small cleanup * Add docstring to `Parser` field * Remove unnecessary `unwrap` * Remove unnecessary borrow * Fix indentation of some `teach`text output
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-29/+24
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-08Auto merge of #74877 - lcnr:min_const_generics, r=oli-obkbors-16/+73
Implement the `min_const_generics` feature gate Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332. Adds the new feature gate `#![feature(min_const_generics)]`. This feature gate adds the following limitations to using const generics: - generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`) - generic parameters must be either integers, `bool` or `char`. We do allow arbitrary expressions in associated consts though, meaning that the following is allowed, even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable. ```rust trait Foo { const ASSOC: usize; } impl<const N: usize> Foo for [u8; N] { const ASSOC: usize = 64 / N; } ``` r? @varkor cc @eddyb @withoutboats
2020-08-07Small cleanupEsteban Küber-1/+1
* Add docstring to `Parser` field * Remove unnecessary `unwrap` * Remove unnecessary borrow * Fix indentation of some `teach`text output
2020-08-06allow complex expressions in assoc constsBastian Kauschke-17/+17
2020-08-05forbid generic params in complex constsBastian Kauschke-18/+75
2020-08-05Handle fieldless tuple structs in diagnostic codeAaron Hill-4/+3
Fixes #75062
2020-08-02Auto merge of #74963 - JohnTitor:ptn-ice, r=petrochenkovbors-19/+7
Fix ICEs with `@ ..` binding This reverts #74557 and introduces an alternative fix while ensuring that #74954 is not broken. The diagnostics are verbose though, it fixes three related issues. cc #74954, #74539, and #74702
2020-08-02Auto merge of #74210 - estebank:type-ascriptomatic, r=petrochenkovbors-80/+126
Deduplicate `::` -> `:` typo errors Deduplicate errors caused by the same type ascription typo, including ones suggested during parsing that would get reported again during resolve. Fix #70382.
2020-08-02Auto merge of #74785 - euclio:deprecation-kinds, r=petrochenkovbors-1/+1
report kind of deprecated item in message This is important for fields, which are incorrectly referred to as "items".
2020-07-31Move from `log` to `tracing`Oliver Scherer-1/+1
2020-07-31Reduce verbosity of some type ascription errorsEsteban Küber-80/+126
* Deduplicate type ascription LHS errors * Remove duplicated `:` -> `::` suggestion from parse error * Tweak wording to be more accurate * Modify `current_type_ascription` to reduce span wrangling * remove now unnecessary match arm * Add run-rustfix to appropriate tests
2020-07-31Fix ICEs with `@ ..` bindingYuki Okushi-3/+1
2020-07-31Revert "Fix an ICE on an invalid `binding @ ...` in a tuple struct pattern"Yuki Okushi-19/+9
This reverts commit f5e5eb6f46ef2cf0dd45dba4f975305509334fc6.
2020-07-27forbid generic params inside of anon consts in ty defaultsBastian Kauschke-8/+76