about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2023-06-19Remove unreachable and untested suggestion for invalid span enum derive(Default)Tom Martin-16/+5
2023-06-19ReformattingTom Martin-3/+5
2023-06-18refactor(resolve): delete `update_resolution` functionbohan-53/+40
2023-06-18Add translatable diagnostic for various strings in ↵Tom Martin-9/+42
resolve::unresolved_macro_suggestions
2023-06-18Add translatable diagnostic for cannot find in this scopeTom Martin-3/+19
2023-06-18Add translatable diagnostic for invalid importsTom Martin-5/+13
2023-06-18Add translatable diagnostic for changing import bindingTom Martin-8/+22
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-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-13/+6
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-12/+11
2023-05-24Auto merge of #111195 - GuillaumeGomez:fix-ice-intra-doc-link, r=petrochenkovbors-7/+8
Prevent crash when a path is not resolved in intra-doc link Fixes https://github.com/rust-lang/rust/issues/111189. cc `@petrochenkov` r? `@notriddle`
2023-05-23Ignore "non-real" type Res in rustdoc intra doc link resolutionGuillaume Gomez-7/+8
2023-05-23fix(resolve): not defined `extern crate shadow_name`bohan-1/+6
2023-05-20Rollup merge of #111652 - clubby789:self-import-improvement, r=compiler-errorsDylan DPC-1/+11
Better diagnostic for `use Self::..` Fixes #111627 cc `@petrochenkov,` you might have thoughts on a better way to handle this (https://github.com/rust-lang/rust/issues/63720#issuecomment-591597466)
2023-05-19Auto merge of #109602 - bvanjoi:fix-issue-109343, r=petrochenkovbors-5/+7
fix(resolve): replace bindings to dummy for unresolved imports close #109343 In #109343, `f` in `pub use f as g` points to: |namespace| binding| |-|-| |type| `external crate f`| |value| `None` | |macro| `None` | When resolve `value_ns` during `resolve_doc_links`, the value of the binding of single_import `pub use f as g` goes to `pub use inner::f`, and since it does not satisfy [!self.is_accessible_from(binding.vis, single_import.parent_scope.module)](https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/ident.rs#L971) and returns `Err(Undetermined)`, which eventually goes to `PathResult::Indeterminate => unreachable!`. This PR replace all namespace binding to `dummy_binding` for indeterminate import, so, the bindings of `pub use f as g` had been changed to followings after finalize: |namespace| binding| |-|-| |type| `dummy`| |value| `dummy` | |macro| `dummy` | r?`@petrochenkov`
2023-05-18fix(resolve): only disambiguate binding key during definebohan-16/+24
2023-05-18fix(resolve): replace bindings to dummy for unresolved importsbohan-5/+7
2023-05-17Rollup merge of #111557 - cjgillot:revert-111020, r=petrochenkovDylan DPC-5/+2
Revert "Validate resolution for SelfCtor too." This reverts commit 83453408a0ce91b9e3d3ae6e7f117b1fd28b487d. That PR introduced a breaking change. Fixes https://github.com/rust-lang/rust/issues/111541 Reopens https://github.com/rust-lang/rust/issues/89868 r? `@petrochenkov`
2023-05-16Better diagnostic for `use Self::..`clubby789-1/+11
2023-05-16Rollup merge of #111428 - bvanjoi:fix-109250, r=NilstriebNilstrieb-4/+0
refactor(resolve): clean up the early error return caused by non-call closes https://github.com/rust-lang/rust/issues/109250 It seems no bad happened, r? ``@Nilstrieb``
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+2
2023-05-14Revert "Validate resolution for SelfCtor too."Camille GILLOT-5/+2
This reverts commit 83453408a0ce91b9e3d3ae6e7f117b1fd28b487d.
2023-05-14Auto merge of #111425 - Bryanskiy:privacy_ef, r=petrochenkovbors-2/+2
Populate effective visibilities in `rustc_privacy` (take 2) Same as https://github.com/rust-lang/rust/pull/110907 + regressions fixes. Fixes https://github.com/rust-lang/rust/issues/111359. r? `@petrochenkov`
2023-05-11Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errorsMichael Goulet-24/+42
Improve suggestion for `self: Box<self>` Fixes #110642
2023-05-11Improve error for `self: Box<self>`clubby789-24/+42
2023-05-11Populate effective visibilities in rustc_privacyBryanskiy-2/+2
2023-05-10Only warn single-use lifetime when the binders match.Camille GILLOT-5/+11
2023-05-10refactor(resolve): clean up the early error return caused by non-callbohan-4/+0
2023-05-05improve diagnostics and bless testsBoxy-63/+158
2023-05-05misc nameres changes for anon constsBoxy-111/+163
2023-05-04Rollup merge of #110982 - cjgillot:elided-self-const, r=petrochenkovMatthias Krüger-0/+4
Do not recurse into const generic args when resolving self lifetime elision. Fixes https://github.com/rust-lang/rust/issues/110899 r? `@petrochenkov`
2023-05-04Rollup merge of #111070 - WaffleLapkin:break_ribs, r=lcnrMatthias Krüger-116/+113
Don't suffix `RibKind` variants This PR - Removes `use RibKind::*` - Renames `RibKind::{SomethingRibKind => Something}` It seems unnecessary to have "RibKind" in the end of all variants, if we can just use it as a normal enum. Additionally previously it was weird that `MacroDefinition` is the only unsuffixed variant.
2023-05-04Rollup merge of #111020 - cjgillot:validate-self-ctor, r=petrochenkovMatthias Krüger-2/+5
Validate resolution for SelfCtor too. Fixes https://github.com/rust-lang/rust/issues/89868 r? `@petrochenkov`
2023-05-04Rollup merge of #110908 - petrochenkov:notagain4, r=compiler-errorsDylan DPC-19/+9
resolve: One more attempt to simplify `module_children` If the next step is performed and `fn module_children_local` is merged with the `module_children` query, then it causes perf regressions, regardless of whether query result feeding is [used](https://perf.rust-lang.org/compare.html?start=43a78029b4f4d92978b8fde0a677ea300b113c41&end=2eb5bcc5068b9d92f74bcb1797da664865d6981d&stat=instructions:u) or [not](https://perf.rust-lang.org/compare.html?start=2fce2290865f012391b8f3e581c3852a248031fa&end=2a33d6cd99481d1712037a79e7d66a8aefadbf72&stat=instructions:u).
2023-05-03Do not recurse into const generic args when resolving self lifetime elision.Camille GILLOT-0/+4
2023-05-03Validate resolution for SelfCtor too.Camille GILLOT-2/+5
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-73/+76
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02resolve: One more attempt to simplify `module_children`Vadim Petrochenkov-19/+9
2023-05-01Remove "RibKind" suffix from `RibKind` variantsMaybe Waffle-110/+104
2023-05-01Don't `use RibKind::*`Maybe Waffle-105/+108