about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-3/+1
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-25is_{some,ok}_andMichael Goulet-1/+1
2023-11-25resolve: Avoid clones of `MacroData`Vadim Petrochenkov-55/+52
And move declarative macro compilation to an earlier point in def collector, which is required for #118188.
2023-11-24Auto merge of #117934 - Young-Flash:dev, r=petrochenkovbors-3/+12
feat: make `let_binding_suggestion` more reasonable This is my first PR for rustc, which trying to fix https://github.com/rust-lang/rust/issues/117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
2023-11-23feat: make let_binding_suggestion more reasonableYoung-Flash-3/+12
2023-11-23Auto merge of #118065 - estebank:core-not-found-404, r=TaKO8Kibors-0/+9
When failing to import `core`, suggest `std`
2023-11-22When failing to import `core`, suggest `std`Esteban Küber-0/+9
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-25/+25
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-20let-chain fmtEsteban Küber-31/+24
2023-11-20Rely in resolve and not on path name for `&str` -> `String` suggestionEsteban Küber-49/+54
2023-11-20Do not consider traits as ownable in suggestionEsteban Küber-7/+55
2023-11-20Account for '_ in lifetime suggestionEsteban Küber-4/+15
2023-11-20Suggest 'a when trait object assoc type has '_Esteban Küber-12/+21
2023-11-20Fix incorrect lifetime suggestionEsteban Küber-2/+2
2023-11-20Tweak wordingEsteban Küber-4/+4
2023-11-20Account for impl Trait in lifetime suggestionEsteban Küber-5/+72
When encountering ```rust fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { /* */ } ``` Suggest ```rust fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { /* */ } ```
2023-11-20On borrow return type, suggest borrowing from arg or owned return typeEsteban Küber-12/+126
When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type. ``` error[E0106]: missing lifetime specifier --> $DIR/variadic-ffi-6.rs:7:6 | LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | LL | x: &usize, | + help: ...or alternatively, to want to return an owned value | LL - ) -> &usize { LL + ) -> usize { | ``` Fix #85843.
2023-11-19fix rebaseEsteban Küber-1/+4
2023-11-19review commentsEsteban Küber-22/+13
2023-11-19Account for number of arguments in suggestionEsteban Küber-5/+24
2023-11-19fix tidyEsteban Küber-1/+1
2023-11-19Suggest using builder on curly brace struct called as fnEsteban Küber-165/+178
2023-11-19Do not suggest struct literal when fields are privateEsteban Küber-35/+64
2023-11-19On private tuple struct, suggest `Default::default` when possibleEsteban Küber-1/+56
2023-11-19Don't sort `span_suggestions`, leave that to callerEsteban Küber-5/+9
2023-11-19When encountering struct fn call literal with private fields, suggest all ↵Esteban Küber-16/+75
builders When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.
2023-11-17Rollup merge of #117964 - estebank:issue-81232, r=petrochenkovMatthias Krüger-1/+13
When using existing fn as module, don't claim it doesn't exist Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item. Fix #81232.
2023-11-17On resolve error of `[rest..]`, suggest `[rest @ ..]`Esteban Küber-0/+35
When writing a pattern to collect multiple entries of a slice in a single binding, it is easy to misremember or typo the appropriate syntax to do so, instead writing the experimental `X..` pattern syntax. When we encounter a resolve error because `X` isn't available, we suggest `X @ ..` as an alternative. ``` error[E0425]: cannot find value `rest` in this scope --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13 | LL | [1, rest..] => println!("{rest:?}"), | ^^^^ not found in this scope | help: if you meant to collect the rest of the slice in `rest`, use the at operator | LL | [1, rest @ ..] => println!("{rest:?}"), | + ``` Fix #88404.
2023-11-16When using existing fn as module, don't claim it doesn't existEsteban Küber-1/+13
Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item. Fix #81232.
2023-11-15Bump cfg(bootstrap)sMark Rousskov-2/+2
2023-11-08rustc: minor changes suggested by clippy perf lints.Nicholas Nethercote-1/+1
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-14/+14
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-27Rename `RibKind::ClosureOrAsync` to reflect how it is actually usedOli Scherer-12/+12
2023-10-27Add gen blocks to ast and do some broken ast loweringOli Scherer-2/+2
2023-10-27Auto merge of #116858 - estebank:issue-22488, r=petrochenkovbors-1/+20
Suggest assoc fn `new` when trying to build tuple struct with private fields Fix #22488.
2023-10-26Suggest assoc fn `new` when trying to build tuple struct with private fieldsEsteban Küber-1/+20
Fix #22488.
2023-10-26Rollup merge of #116905 - Fenex:refactor/compiler/resolve, r=petrochenkovMatthias Krüger-11/+10
refactor(compiler/resolve): simplify some code Removes unnecessary allocate and double-sorting the same vector, makes the code a little nicer.
2023-10-25Rollup merge of #117009 - fmease:diag-disambig-sugg-crate, r=b-naberMatthias Krüger-14/+44
On unresolved imports, suggest a disambiguated path if necessary to avoid collision with local items Fixes #116970.
2023-10-22use visibility to check unused imports and delete some stmtsbohan-4/+1
2023-10-21on unresolved import disambiguate suggested path if it would collideLeón Orell Valerian Liehr-14/+44
2023-10-21Rollup merge of #116961 - estebank:issue-60164, r=oli-obkMatthias Krüger-2/+15
Typo suggestion to change bindings with leading underscore When encountering a binding that isn't found but has a typo suggestion for a binding with a leading underscore, suggest changing the binding definition instead of the use place. Fix #60164.
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-10-20Typo suggestion to change bindings with leading underscoreEsteban Küber-2/+15
When encountering a binding that isn't found but has a typo suggestion for a binding with a leading underscore, suggest changing the binding definition instead of the use place. Fix #60164.
2023-10-19refactor(compiler/resolve): simplify some codeVitaliy Busko-11/+10
Removes unnecessary allocates and double-sorting the same vector, makes the code a little nicer.
2023-10-13Format all the let chains in compilerMichael Goulet-144/+211
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-10-05Rename `Resolver::active_features`.Nicholas Nethercote-9/+4
For the reasons described in the previous commit.
2023-10-02Rollup merge of #114454 - Nilstrieb:no-evil-sorting, r=cjgillotTyler Mandry-20/+18
Replace `HashMap` with `IndexMap` in pattern binding resolve fixes https://github.com/rust-lang/rust/pull/114332#discussion_r1284189179
2023-10-02Replace `HashMap` with `IndexMap` in pattern binding resolveNilstrieb-20/+18
It will be iterated over, so we should avoid using `HashMap`.