summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late
AgeCommit message (Collapse)AuthorLines
2023-07-05resolve: Use `Interned` for `Module`Vadim Petrochenkov-1/+1
2023-07-04Auto merge of #112917 - chenyukang:yukang-fix-112590, r=estebankbors-2/+56
Suggest importing for partial mod path matching in name resolving Fixes #112590
2023-07-02add testcase for 112590yukang-10/+36
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-22Tweak privacy errors to account for reachable itemsEsteban Küber-0/+1
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-1/+29
2023-06-15Fix suggestion for E0404 not dealing with multiple generics许杰友 Jieyou Xu (Joe)-23/+69
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-1/+1
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-9/+28
`#[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-13/+15
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-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-2/+1
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-7/+6
2023-05-05improve diagnostics and bless testsBoxy-25/+45
2023-05-04Rollup merge of #111070 - WaffleLapkin:break_ribs, r=lcnrMatthias Krüger-2/+2
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-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-26/+29
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-01Remove "RibKind" suffix from `RibKind` variantsMaybe Waffle-2/+2
2023-05-01clean up debug codeyukang-1/+0
2023-05-01remove type_ascription_path_suggestions in parseryukang-38/+0
2023-05-01Remove more diagnostics for ascription in resolveyukang-80/+8
2023-05-01Rip it outNilstrieb-8/+4
My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
2023-04-17Spelling - compilerJosh Soref-2/+2
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-07suggest adding const paramLeón Orell Valerian Liehr-5/+10
2023-03-15error-msg: impl better suggestion for `E0532`Ezra Shaw-16/+32
2023-03-13resolve: Remove `struct_field_names_untracked`Vadim Petrochenkov-17/+27
2023-03-13resolve: Centralize retrieval of items span and item nameVadim Petrochenkov-31/+16
2023-03-13resolve: Remove `fn_has_self_parameter_untracked`Vadim Petrochenkov-1/+11
2023-03-13resolve: Remove `struct_field_visibilities_untracked`Vadim Petrochenkov-12/+31
2023-03-07Simplify `sort_by` callsMaybe Waffle-1/+1
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-3/+2
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-03Match unmatched backticks in comments in compiler/est31-1/+1
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-3/+2
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-21Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkovbors-30/+41
give the resolver access to TyCtxt The resolver is now created after TyCtxt is created. Then macro expansion and name resolution are run and the results fed into queries just like before this PR. Since the resolver had (before this PR) mutable access to the `CStore` and the source span table, these two datastructures are now behind a `RwLock`. To ensure that these are not mutated anymore after the resolver is done, a read lock to them is leaked right after the resolver finishes. ### PRs split out of this one and leading up to it: * https://github.com/rust-lang/rust/pull/105423 * https://github.com/rust-lang/rust/pull/105357 * https://github.com/rust-lang/rust/pull/105603 * https://github.com/rust-lang/rust/pull/106776 * https://github.com/rust-lang/rust/pull/106810 * https://github.com/rust-lang/rust/pull/106812 * https://github.com/rust-lang/rust/pull/108032
2023-02-20Prepare crate loader for LockGuardOli Scherer-2/+1
2023-02-20Prepare for adding a `TyCtxt` to `Resolver`Oli Scherer-28/+40
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-3/+3
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-5/+3
2023-02-14Separate the lifetime of the session and the arena in the resolverOli Scherer-2/+2
2023-02-13rustdoc: Eliminate remaining uses of resolverVadim Petrochenkov-2/+2
2023-02-03unused-lifetimes: don't warn about lifetimes originating from expanded codeMatthias Krüger-12/+16
previously, we would warn like this: ```` warning: lifetime parameter `'s` never used --> /tmp/unusedlif/code.rs:6:62 | 5 | #[derive(Clone)] | - help: elide the unused lifetime 6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As)); | ^^ | = note: requested on the command line with `-W unused-lifetimes` ```` Fixes #104432
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-1/+1
2023-01-25suggest qualifying bare associated constantsAndy Russell-5/+12
2023-01-16fix #104440Takayuki Maeda-3/+19
2023-01-12Don't suggest dyn as parameter to addMichael Goulet-1/+5
2023-01-11review comments: Tweak outputEsteban Küber-12/+3
* Account for `struct S(pub(super)Ty);` in suggestion * Suggest changing field visibility in E0603 too
2023-01-11review commentEsteban Küber-1/+1
2023-01-11Suggest making private tuple struct field publicEsteban Küber-0/+20
Fix #52144.
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-2/+2
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-18use &str / String literals instead of format!()Matthias Krüger-6/+2
2022-12-13Rollup merge of #104864 - chenyukang:yukang/fix-104700-binding, r=estebankMatthias Krüger-0/+16
Account for item-local in inner scope for E0425 Fixes #104700