about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-08-02Resolve visibility paths as modules not as types.Camille GILLOT-1/+1
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-6/+0
2023-08-02trivial style fixyukang-30/+27
2023-07-31Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkovMatthias Krüger-23/+30
fix(resolve): report unresolved imports firstly Fixes #81413 An easy fix, r? ```@petrochenkov```
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-90/+75
2023-07-29Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkovbors-46/+175
fix(resolve): update the ambiguity glob binding as warning recursively Fixes #47525 Fixes #56593, but `issue-56593-2.rs` is not fixed to ensure backward compatibility. Fixes #98467 Fixes #105235 Fixes #112713 This PR had added a field called `warn_ambiguous` in `NameBinding` which is only for back compatibly reason and used for lint. More details: https://github.com/rust-lang/rust/pull/112743 r? `@petrochenkov`
2023-07-28Resolve generic const itemsLeón Orell Valerian Liehr-69/+109
2023-07-29fix(resolve): update the ambiguity glob binding as warning recursivelybohan-46/+175
2023-07-29fix(resolve): report unresolved imports firstlybohan-23/+30
2023-07-28Introduce the `#[diagnostic]` attribute namespaceGeorg Semmler-3/+17
Co-authored-by: est31 <est31@users.noreply.github.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-07-25Auto merge of #113980 - bvanjoi:fix-113953, r=petrochenkovbors-5/+8
fix(resolve): skip panic when resolution is dummy Fixes #113953 Skip the panic when the binding refers to a dummy node during the finalization. r? `@petrochenkov`
2023-07-25Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkovbors-2/+11
fix intra-doc links on nested `use` and `extern crate` items This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example: ```rust /// Re-export [`fmt`] and [`io`]. pub use std::{fmt, io}; // "nested" use = use with braces /// Re-export [`std`]. pub extern crate std; ``` Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`. <details> During AST->HIR lowering, nested `use` items are desugared like this: ```rust pub use std::{}; // "list stem" pub use std::fmt; pub use std::io; ``` Each of these HIR nodes has it's own effective visibility and the list stem is always considered private. To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items. </details> For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places. As as side effect of fixing `extern crate`, i've turned ```rust #[doc(masked)] extern crate self as _; ``` into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus. fixes https://github.com/rust-lang/rust/issues/113896
2023-07-25resolve: ensure compile failed when has dummy or ambiguousbohan-8/+8
2023-07-25fix(resolve): skip panic when resolution is dummybohan-1/+4
2023-07-23fix clippy::useless_formatMatthias Krüger-2/+2
2023-07-22Use features() over features_untracked() where possibleLeón Orell Valerian Liehr-5/+2
2023-07-22fix doc links on `use` itemsLukas Markeffsky-2/+11
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-8/+8
2023-07-18Fix removal span calculation of unused_qualifications suggestion许杰友 Jieyou Xu (Joe)-3/+3
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-1/+1
2023-07-14Rollup merge of #112729 - jieyouxu:unused-qualifications-suggestion, r=b-naberMatthias Krüger-1/+5
Add machine-applicable suggestion for `unused_qualifications` lint ``` error: unnecessary qualification --> $DIR/unused-qualifications-suggestion.rs:17:5 | LL | foo::bar(); | ^^^^^^^^ | note: the lint level is defined here --> $DIR/unused-qualifications-suggestion.rs:3:9 | LL | #![deny(unused_qualifications)] | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with the unqualified path | LL | bar(); | ~~~ ``` Closes #92198.
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-18/+40
2023-07-13Add machine-applicable suggestion for `unused_qualifications` lint许杰友 Jieyou Xu (Joe)-1/+5
2023-07-10Auto merge of #112988 - spastorino:new-rpitit-24, r=compiler-errorsbors-1/+0
Replace RPITIT current impl with new strategy that lowers as a GAT This PR replaces the current implementation of RPITITs with the new implementation that we had under -Zlower-impl-trait-in-trait-to-assoc-ty flag that lowers the RPIT as a GAT on the trait and on the impls that implement that trait. Opening this PR as a draft because this goes after #112682, ~#112981~ and ~#112983~. As soon as those are merged, I can rebase and we should run perf, crater and test a lot. r? `@compiler-errors`
2023-07-10Rollup merge of #113331 - chenyukang:yukang-fix-112590-false-positive, ↵Matthias Krüger-23/+51
r=estebank Add filter with following segment while lookup typo for path From the discussion: https://github.com/rust-lang/rust/pull/112917#discussion_r1239150173 Seems we can not get the assoc items for `Struct`, `Enum` in the resolving phase. A obvious filter is avoid suggesting the same name with the following segment path. Use `following_seg` can extend the function `smart_resolve_partial_mod_path_errors` for more scenarios, such as `std::sync_error::atomic::AtomicBool` in test case. r? `@estebank`
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-1/+0
2023-07-07adjust smart_resolve_partial_mod_path_errorsyukang-2/+1
2023-07-07smart_resolve_partial_mod_path_errors should not suggest parentyukang-3/+4
2023-07-07Add filter with next segment while lookup typo for pathyukang-21/+49
2023-07-05resolve: Add comments explaining use of `Interned`Vadim Petrochenkov-0/+6
2023-07-05resolve: Use `Interned` for `Module`Vadim Petrochenkov-65/+59
2023-07-05resolve: Use `Interned` for `Import`Vadim Petrochenkov-71/+58
2023-07-05resolve: Use `Interned` for `NameBinding`Vadim Petrochenkov-124/+106
2023-07-04Auto merge of #112917 - chenyukang:yukang-fix-112590, r=estebankbors-5/+64
Suggest importing for partial mod path matching in name resolving Fixes #112590
2023-07-02add testcase for 112590yukang-17/+44
2023-07-01fix(resolve): skip assertion judgment when `NonModule` is dummybohan-4/+5
2023-06-30Rollup merge of #113177 - estebank:hrlt-sugg, r=compiler-errorsMatthias Krüger-3/+7
Use structured suggestion when telling user about `for<'a>` ``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-30Use structured suggestion when telling user about `for<'a>`Esteban Küber-3/+7
``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-29resolve: Remove artificial import ambiguity errorsVadim Petrochenkov-37/+22
2023-06-27Rollup merge of #113084 - WaffleLapkin:less_map_or, r=NilstriebMatthias Krüger-4/+3
Simplify some conditions r? `@Nilstrieb` Some things taken out of my `is_none_or` pr.
2023-06-27Simplify some conditionsMaybe Waffle-4/+3
2023-06-26Rollup merge of #112979 - NotStirred:translatable_diag/resolve_imports, ↵Matthias Krüger-44/+130
r=fee1-dead Rewrite most diagnostics as translatable within resolve/imports
2023-06-25Add translatable diagnostic for import resolution stringsTom Martin-44/+130
Add translatable diagnostic for cannot be reexported error also added for subdiagnostics Add translatable diagnostics for resolve_glob_import errors Add translatable diag for unable to determine import resolution Add translatable diag for is not directly importable
2023-06-24fix: add cfg diagnostic for unresolved import errorbohan-1/+12
2023-06-22Tweak privacy errors to account for reachable itemsEsteban Küber-28/+100
Suggest publicly accessible paths for items in private mod: When encountering a path in non-import situations that are not reachable due to privacy constraints, search for any public re-exports that the user could use instead. Track whether an import suggestion is offering a re-export. When encountering a path with private segments, mention if the item at the final path segment is not publicly accessible at all. Add item visibility metadata to privacy errors from imports: On unreachable imports, record the item that was being imported in order to suggest publicly available re-exports or to be explicit that the item is not available publicly from any path. In order to allow this, we add a mode to `resolve_path` that will not add new privacy errors, nor return early if it encounters one. This way we can get the `Res` corresponding to the final item in the import, which is used in the privacy error machinery.
2023-06-22suggest importing for partial mod path in name resolvingyukang-2/+34
2023-06-21resolve: Minor cleanup to `fn resolve_path_with_ribs`Vadim Petrochenkov-51/+38
A single-use closure is inlined and one unnecessary enum is removed.
2023-06-20Revert "Rollup merge of #112758 - bvanjoi:clean-up-resolve, r=petrochenkov"bohan-40/+53
This reverts commit 3b059e0fdbf0257ac4921552781d070e8288233a, reversing changes made to d70be670474c98e62eefc67674b7bb3c7c4f5053.
2023-06-19Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=WaffleLapkinMatthias Krüger-24/+86
Rewrite various resolve/diagnostics errors as translatable diagnostics additional question: For trivial strings is it ever accepted to use `fluent_generated::foo` in a `label` for example? Or is an empty struct `Diagnostic` preferred?