about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late
AgeCommit message (Collapse)AuthorLines
2023-10-26Suggest assoc fn `new` when trying to build tuple struct with private fieldsEsteban Küber-1/+20
Fix #22488.
2023-10-13Format all the let chains in compilerMichael Goulet-75/+91
2023-09-29Auto merge of #116089 - estebank:issue-115992-2, r=compiler-errorsbors-21/+69
When suggesting `self.x` for `S { x }`, use `S { x: self.x }` Fix #115992. r? `@compiler-errors` Follow up to #116086.
2023-09-27fix clippy::{redundant_guards, useless_format}Matthias Krüger-1/+1
2023-09-26Don't store lazyness in DefKindMichael Goulet-2/+2
2023-09-25Point at field definition when unresolved name exists in `Self`Esteban Küber-7/+7
2023-09-25When suggesting `self.x` for `S { x }`, use `S { x: self.x }`Esteban Küber-14/+62
Tweak output. Fix #115992.
2023-09-23Tweak wording and logicEsteban Küber-5/+10
2023-09-23When encountering method on `Self` that we can't suggest, mention itEsteban Küber-30/+28
2023-09-23More accurate suggestion for `self.` and `Self::`Esteban Küber-5/+12
Fix #115992.
2023-08-08fix: not insert missing lifetime for `ConstParamTy`bohan-2/+4
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-2/+2
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-2/+2
2023-08-06refactor on span_look_aheadyukang-10/+10
2023-08-02trivial style fixyukang-30/+27
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-35/+27
2023-07-28Resolve generic const itemsLeón Orell Valerian Liehr-0/+8
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-11/+27
2023-07-10Rollup merge of #113331 - chenyukang:yukang-fix-112590-false-positive, ↵Matthias Krüger-19/+47
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-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-17/+45
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