summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late.rs
AgeCommit message (Collapse)AuthorLines
2023-09-29Auto merge of #116089 - estebank:issue-115992-2, r=compiler-errorsbors-1/+19
When suggesting `self.x` for `S { x }`, use `S { x: self.x }` Fix #115992. r? `@compiler-errors` Follow up to #116086.
2023-09-26Don't store lazyness in DefKindMichael Goulet-3/+3
2023-09-25When suggesting `self.x` for `S { x }`, use `S { x: self.x }`Esteban Küber-1/+19
Tweak output. Fix #115992.
2023-09-14Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naberbors-1/+1
Improve invalid let expression handling - Move all of the checks for valid let expression positions to parsing. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress some later errors and MIR construction for invalid let expressions. - Fix a (drop) scope issue that was also responsible for #104172. Fixes #104172 Fixes #104868
2023-09-11Move let expression checking to parsingMatthew Jasper-1/+1
There was an incomplete version of the check in parsing and a second version in AST validation. This meant that some, but not all, invalid uses were allowed inside macros/disabled cfgs. It also means that later passes have a hard time knowing when the let expression is in a valid location, sometimes causing ICEs. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress later errors and MIR construction for invalid let expressions.
2023-09-10Do not suggest generic const items unless enabledLeón Orell Valerian Liehr-1/+5
2023-09-01Fall through when resolving elided assoc const lifetimesMichael Goulet-34/+29
2023-08-30Capture lifetimes for associated type bounds destined to be lowered to opaquesMichael Goulet-0/+1
2023-08-28RPITITs capture all their lifetimesMichael Goulet-12/+9
2023-08-20Warn on elided lifetimes in associated constantsMichael Goulet-24/+55
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-3/+3
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-3/+3
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-3/+3
2023-08-06Auto merge of #114487 - compiler-errors:opaques-refactoring-idk, r=cjgillotbors-30/+29
Consolidate opaque ty and async fn lowering code The codepaths for lowering "regular" opaques and async fn were almost identical, modulo some bookkeeping that seemed pretty easy to consolidate. r? `@cjgillot`
2023-08-05a function is just another AnonymousCreateParameter ribMichael Goulet-30/+28
2023-08-05Consolidate opaque ty and async fn lowering codeMichael Goulet-0/+1
2023-08-05Remove invalid lint when there is a generic argument in prefix pathyukang-1/+2
2023-08-04Improve spans for indexing expressionsNilstrieb-1/+1
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-6/+2
2023-07-28Resolve generic const itemsLeón Orell Valerian Liehr-69/+101
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-22Use features() over features_untracked() where possibleLeón Orell Valerian Liehr-1/+1
2023-07-22fix doc links on `use` itemsLukas Markeffsky-2/+11
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-3/+8
2023-07-13Add machine-applicable suggestion for `unused_qualifications` lint许杰友 Jieyou Xu (Joe)-1/+5
2023-07-10Rollup merge of #113331 - chenyukang:yukang-fix-112590-false-positive, ↵Matthias Krüger-4/+4
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-07Add filter with next segment while lookup typo for pathyukang-4/+4
2023-07-05resolve: Use `Interned` for `Module`Vadim Petrochenkov-1/+1
2023-07-05resolve: Use `Interned` for `NameBinding`Vadim Petrochenkov-1/+1
2023-07-04Auto merge of #112917 - chenyukang:yukang-fix-112590, r=estebankbors-3/+8
Suggest importing for partial mod path matching in name resolving Fixes #112590
2023-07-02add testcase for 112590yukang-7/+8
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-22suggest importing for partial mod path in name resolvingyukang-1/+5
2023-06-19ReformattingTom Martin-3/+5
2023-06-18Add translatable diagnostic for invalid importsTom Martin-5/+5
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-4/+20
`#[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-23Ignore "non-real" type Res in rustdoc intra doc link resolutionGuillaume Gomez-7/+8
2023-05-18fix(resolve): only disambiguate binding key during definebohan-2/+3
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-11Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errorsMichael Goulet-0/+9
Improve suggestion for `self: Box<self>` Fixes #110642
2023-05-11Improve error for `self: Box<self>`clubby789-0/+9
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-2/+2
2023-05-05misc nameres changes for anon constsBoxy-101/+161
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-80/+78
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.