about summary refs log tree commit diff
path: root/compiler/rustc_resolve
AgeCommit message (Collapse)AuthorLines
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/+168
r=fee1-dead Rewrite most diagnostics as translatable within resolve/imports
2023-06-25Add translatable diagnostic for import resolution stringsTom Martin-44/+168
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/+104
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?
2023-06-19Remove unreachable and untested suggestion for invalid span enum derive(Default)Tom Martin-19/+5
2023-06-19ReformattingTom Martin-3/+5
2023-06-18Fix tidyTom Martin-22/+21
2023-06-18refactor(resolve): delete `update_resolution` functionbohan-53/+40
2023-06-18Add translatable diagnostic for various strings in ↵Tom Martin-9/+55
resolve::unresolved_macro_suggestions
2023-06-18Add translatable diagnostic for cannot find in this scopeTom Martin-4/+23
2023-06-18Add translatable diagnostic for invalid importsTom Martin-5/+16
2023-06-18Add translatable diagnostic for changing import bindingTom Martin-8/+25
2023-06-15Fix suggestion for E0404 not dealing with multiple generics许杰友 Jieyou Xu (Joe)-23/+69
2023-06-15Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieubors-3/+3
Don't drain-on-drop in DrainFilter impls of various collections. This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288). closes #101122 [ACP](https://github.com/rust-lang/libs-team/issues/136) affected tracking issues * #43244 * #70530 * #59618 Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-3/+3
2023-06-14fix(resolve): update `shadowed_glob` more precisionbohan-1/+15
2023-06-10Auto merge of #112452 - MU001999:fix/issue-112439, r=petrochenkovbors-6/+13
Make "consider importing" consistent for macros Fixes #112439
2023-06-10Auto merge of #112426 - Bryanskiy:full_priv_ev, r=petrochenkovbors-1/+1
increase the accuracy of effective visibilities calculation Effective visibilities are calculated lazily due to performance restrictions. Therefore - crate should be walked at least 1 time in `compute_effective_visibilities` pass - Impl's should always be in the effective visibilities table to ensure that the table is filled in correctly. r? `@petrochenkov`
2023-06-10Make "consider importing" consistent for macrosMu001999-6/+13
2023-06-08increase the accuracy of effective visibilities calculationBryanskiy-1/+1
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-71/+220
`#[cfg]`s are frequently used to gate crate content behind cargo features. This can lead to very confusing errors when features are missing. For example, `serde` doesn't have the `derive` feature by default. Therefore, `serde::Serialize` fails to resolve with a generic error, even though the macro is present in the docs. This commit adds a list of all stripped item names to metadata. This is filled during macro expansion and then, through a fed query, persisted in metadata. The downstream resolver can then access the metadata to look at possible candidates for mentioning in the errors. This slightly increases metadata (800k->809k for the feature-heavy windows crate), but not enough to really matter.
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-16/+18
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-27Add warn-by-default lint for local binding shadowing exported glob re-export ↵许杰友 Jieyou Xu (Joe)-23/+64
item
2023-05-26Auto merge of #111858 - clubby789:fluent-alphabetical, r=jyn514,compiler-errorsbors-175/+175
Ensure Fluent messages are in alphabetical order Fixes #111847 This adds a tidy check to ensure Fluent messages are in alphabetical order, as well as sorting all existing messages. I think the error could be worded better, would appreciate suggestions. <details> <summary>Script used to sort files</summary> ```py import sys import re fn = sys.argv[1] with open(fn, 'r') as f: data = f.read().split("\n") chunks = [] cur = "" for line in data: if re.match(r"^([a-zA-Z0-9_]+)\s*=\s*", line): chunks.append(cur) cur = "" cur += line + "\n" chunks.append(cur) chunks.sort() with open(fn, 'w') as f: f.write(''.join(chunks).strip("\n\n") + "\n") ``` </details>
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-175/+175
2023-05-25Rollup merge of #111152 - lukas-code:markdown-parsers-are-hard, r=GuillaumeGomezMichael Goulet-1/+1
update `pulldown-cmark` to `0.9.3` This PR updates `pulldown-cmark` to version `0.9.3`, which does two main things: * Pulls in https://github.com/raphlinus/pulldown-cmark/pull/643 to fix https://github.com/rust-lang/rust/issues/111117 * Allows parsing strikethrough with single tildes, e.g. `~foo~` -> ~foo~. This matches the [GFM spec](https://github.github.com/gfm/#strikethrough-extension-). Full changelog: https://github.com/raphlinus/pulldown-cmark/pull/646
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-13/+6