about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-05-25Avoid clone when constructing runnable label.Mathew Horner-3/+3
2024-05-24Auto merge of #17275 - roife:fix-issue-17012, r=Veykrilbors-33/+122
Fix inconsistent cwd of `run` and `debug` command in client Fix #17012. Also related to #13022 and #15993. When the `kind` of runnable is `bin`, Cargo would use the workspace root as the cwd for the `run` command; otherwise, Cargo defaults to the package root as the cwd for `run`. Initially, r-a assumed the workspace root as the cwd for all runnables in `debug` command, which led to issue #13022. In this case, during unit testing, the `run` command would use the package root while `debug` would use the workspace root, causing inconsistency. PR #15993 addressed this problem by using the package root as the cwd for `debug` command. However, it also resulted in an inconsistency: when executing the `run` command within the main fn of a package (whose target is `bin`), Cargo would use the workspace root, whereas `debug` would use the package root, leading to issue #17012. The preferable approach is to determine the cwd based on the runnable's type. To resolve this, this PR introduces a new `cwd` field within `CargoRunnable`, allowing r-a to decide the appropriate cwd depending on the specific kind of the runnable.
2024-05-24tests: update test for runnablesroife-0/+93
2024-05-24Update docsroife-1/+2
2024-05-24Use cwd from runnable.args for debuggerroife-3/+4
2024-05-24Revert "Debug use cargo workspace root as cwd. fixes #13022"roife-32/+12
This reverts commit 4ca86edac97d47eecb78b16abf255950c10b67ca.
2024-05-24Add cwd to CargoRunnableroife-0/+14
2024-05-23Auto merge of #17287 - Veykril:sysroot-encode-empty, r=Veykrilbors-361/+277
Allow sysroots to only consist of the source root dir Fixes https://github.com/rust-lang/rust-analyzer/issues/17159 This PR encodes the `None` case of an optional sysroot into `Sysroot` itself. This simplifies a lot of things and allows us to have sysroots that consist of nothing, only standard library sources, everything but the standard library sources or everything. This makes things a lot more flexible. Additionally, this removes the workspace status bar info again, as it turns out that that can be too much information for the status bar to handle (this is better rendered somewhere else, like in the status view).
2024-05-23Allow sysroots to only consist of the source root dirLukas Wirth-361/+277
2024-05-23Auto merge of #17284 - Veykril:doc-links, r=Veykrilbors-3/+7
fix: Use correct toolchain channel when generating builtin type doc links
2024-05-23Use correct toolchain channel when generating builtin type doc linksLukas Wirth-3/+7
2024-05-23Auto merge of #17174 - Kohei316:fix-infer-async-block-with-tail-return-expr, ↵bors-1/+43
r=Veykril Fix: infer type of async block with tail return expr Fixes #17106 The `infer_async_block` method calls the `infer_block` method internally, which returns the never type without coercion when `tail_expr` is `None` and `ctx.diverges` is `Diverges::Always`.This is the reason for the bug in this issue. https://github.com/rust-lang/rust-analyzer/blob/cfce2bb46da62950a8b70ddb0b2a12332da1b1e1/crates/hir-ty/src/infer/expr.rs#L1411-L1413 This PR solves the bug by adding a process to coerce after calling `infer_block` method. This code passes all the tests, including tests I added for this isuue, however, I am not sure if this solution is right. I think that this solution is an ad hoc solution. So, I would appreciate to have your review. I apologize if I'm off the mark, but `infer_async_block` method should be rewritten to share code with the process of infering type of `expr::Closure` instead of the `infer_block` method. That way it will be closer to the infer process of rustc.
2024-05-23Update crates/hir-ty/src/infer/expr.rsLukas Wirth-0/+1
2024-05-23Auto merge of #17140 - harrysarson:harry-unused-self, r=Veykrilbors-2/+53
handle {self} when removing unused imports Fixes #17139 On master ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner::{self, X}$0; fn f() { let y = inner::Y(); } } ``` becomes ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner:self; fn f() { let y = inner::Y(); } } ``` with this fix it instead becomes ``` ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner; fn f() { let y = inner::Y(); } } ```
2024-05-22Auto merge of #17270 - ↵bors-2/+53
davidbarsky:david/fix-completions-from-associated-types, r=Veykril fix: ensure implied bounds from associated types are considered in autocomplete closes: #16989 rust-analyzer needs to consider implied bounds from associated types in order to get all methods suggestions people expect. A pretty easy way to do that is to keep the `candidate_trait_id`'s receiver if it matches `TyFingerprint::Unnameable`. When benchmarking this change, I didn't notice a meaningful difference in autocomplete latency. (`TyFingerprint::Unnameable` corresponds to `TyKind::AssociatedType`, `TyKind::OpaqueType`, `TyKind::FnDef`, `TyKind::Closure`, `TyKind::Coroutine`, and `TyKind::CoroutineWitness`.)
2024-05-22fix: ensure implied bounds from associated types are considered in autocompleteDavid Barsky-2/+53
2024-05-22Auto merge of #17251 - roife:fix-issue-17057, r=Veykrilbors-6/+71
fix: resolve extern prelude for local mods in block modules fix https://github.com/rust-lang/rust-analyzer/issues/17057, https://github.com/rust-lang/rust-analyzer/issues/17032. We should use `ModuleOrigin` to check if the current module is a pseudo-module introduced by blocks (where names might be shadowed), rather than checking `block_def_map`.
2024-05-22Auto merge of #17252 - ↵bors-365/+313
davidbarsky:david/refactor-standalone-bools-into-struct, r=Veykril internal: refactor `prefer_no_std`/`prefer_prelude` bools into a struct I noticed that there's a large number of functions/arguments during an unrelated change that take two booleans and realized they're _probably_ better off being in a single struct—less error-prone, etc. Feel free to suggest a better name than `ImportPathConfig`/close this entirely! I can also make these args enums; just hopefully making this a little more misuse-resistant.
2024-05-22SimplifyLukas Wirth-16/+11
2024-05-22internal: refactor `prefer_no_std`/`prefer_prelude` bools into a structDavid Barsky-351/+304
2024-05-23fix: check pseudo-block by local_id instead of ModuleOriginroife-5/+3
2024-05-22Auto merge of #17277 - Veykril:find-path-fixes, r=Veykrilbors-346/+647
fix: Various find path fixes Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
2024-05-22Auto merge of #17279 - Veykril:format_args-escape, r=Veykrilbors-6/+18
fix: Fix format_args lowering passing incorrect parameters to `rustc_parse_format`
2024-05-22fix: Fix format_args lowering passing incorrect parameters to rustc_parse_formatLukas Wirth-6/+18
2024-05-22Auto merge of #17248 - mladedav:dm/delay-clear, r=Veykrilbors-1/+10
Clear diagnostics only after new ones were received Closes #15934 This adds a flag inside the global state which controls when old diagnostics are cleared. Now, old diagnostics should be cleared only after at least one new diagnostic is available.
2024-05-22Auto merge of #17268 - Veykril:signatures, r=Veykrilbors-226/+388
feat: More callable info With this PR we retain more info about callables other than functions, allowing for closure parameter type inlay hints to be linkable as well as better signature help around closures and `Fn*` implementors.
2024-05-22Update assists test fixturesLukas Wirth-29/+18
2024-05-22expectify find_path testsLukas Wirth-184/+447
2024-05-22fix: Fix general find-path inconsistenciesLukas Wirth-193/+242
2024-05-21test: add tests for extern preludes resolving in local modsroife-0/+62
2024-05-19Auto merge of #17259 - lnicola:sync-from-rust, r=lnicolabors-492474/+2972490
internal: Sync from downstream
2024-05-19Bump rustc cratesLaurențiu Nicola-15/+38
2024-05-19Merge from rust-lang/rustLaurențiu Nicola-492459/+2972451
2024-05-19Preparing for merge from rust-lang/rustLaurențiu Nicola-0/+1
2024-05-19Auto merge of #124500 - VladimirMakaev:lldb-str-formatters, r=Mark-Simulacrumbors-4/+70
lldb-formatters: Use StdSliceSyntheticProvider for &str &str has associated summary provider which correctly displays string values in debugger, but while working on https://github.com/rust-lang/rust/pull/124458 I've noticed that a &str inside an enum displays a blob of memory until a 0 is reached (as a c-string) which makes a very bizarre experience when debugging However there is already StdSliceSyntheticProvider which we use for other slices. This PR enables the same synthetic provider to be used for &str, however the summary provider is still fixed to return the string value I've added a test `debuginfo/strings-and-strs.rs` which prior to this PR would output the following in LLDB: ``` * thread #1, name = 'a', stop reason = breakpoint 1.1 frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5 44 let plain_str = "Hello"; 45 let str_in_struct = Foo { inner: "Hello" }; 46 let str_in_tuple = ("Hello", "World"); -> 47 zzz(); // #break 48 } 49 50 fn zzz() { (lldb) frame var (alloc::string::String) plain_string = "Hello" { vec = size=5 { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } (&str) plain_str = "Hello" { data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py" length = 5 } (strings_and_strs::Foo) str_in_struct = { inner = "Hello" { data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py" length = 5 } } ((&str, &str)) str_in_tuple = { 0 = "Hello" { data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py" length = 5 } 1 = "World" { data_ptr = 0x0000555555557268 "World\U00000001gdb_load_rust_pretty_printers.py" length = 5 } } ``` After this PR it would look the following way: ``` * thread #1, name = 'a', stop reason = breakpoint 1.1 frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5 44 let plain_str = "Hello"; 45 let str_in_struct = Foo { inner: "Hello" }; 46 let str_in_tuple = ("Hello", "World"); -> 47 zzz(); // #break 48 } 49 50 fn zzz() { (lldb) frame var (alloc::string::String) plain_string = "Hello" { vec = size=5 { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } (&str) plain_str = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } (strings_and_strs::Foo) str_in_struct = { inner = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } ((&str, &str)) str_in_tuple = { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } ```
2024-05-19Auto merge of #99969 - calebsander:feature/collect-box-str, r=dtolnaybors-4/+54
alloc: implement FromIterator for Box<str> `Box<[T]>` implements `FromIterator<T>` using `Vec<T>` + `into_boxed_slice()`. Add analogous `FromIterator` implementations for `Box<str>` matching the current implementations for `String`. Remove the `Global` allocator requirement for `FromIterator<Box<str>>` too. ACP: https://github.com/rust-lang/libs-team/issues/196
2024-05-19Auto merge of #125230 - compiler-errors:uplift-query-stuff, r=lcnrbors-681/+886
Uplift more query stuff - Uplift various query input/response internals - Uplift the `ProofTree` structures and make the `ProofTreeBuilder` stuff (mostly) generic over `Interner` - Stop using `TyCtxt::def_kind` in favor of `AliasTerm::kind` r? lcnr
2024-05-18Auto merge of #125257 - jieyouxu:rollup-11evnm9, r=jieyouxubors-57/+1844
Rollup of 3 pull requests Successful merges: - #125214 (Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability) - #125236 (Add tests for `-Zunpretty=expanded` ported from stringify's tests) - #125251 (Clarify how String::leak and into_boxed_str differ ) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-18Move NormalizesTo back downMichael Goulet-6/+12
I tried to rebase this down into the first commit but it is WAY too annoying x
2024-05-18Stop using def_kind() in solverMichael Goulet-17/+8
2024-05-18Make proof tree building genericMichael Goulet-93/+111
2024-05-18Uplift inspect into rustc_type_irMichael Goulet-318/+399
2024-05-18Uplift GenericArgKind, CanonicalVarValues, QueryInputMichael Goulet-268/+377
and make NestedGoals generic
2024-05-18Rollup merge of #125251 - jonhoo:patch-1, r=Nilstrieb许杰友 Jieyou Xu (Joe)-5/+7
Clarify how String::leak and into_boxed_str differ
2024-05-18Rollup merge of #125236 - dtolnay:expandtest, r=nnethercote许杰友 Jieyou Xu (Joe)-51/+1807
Add tests for `-Zunpretty=expanded` ported from stringify's tests This PR adds a new set of tests for the AST pretty-printer. Previously, pretty-printer edge cases were tested by way of `stringify!` in [tests/ui/macros/stringify.rs](https://github.com/rust-lang/rust/blob/1.78.0/tests/ui/macros/stringify.rs), such as the tests added by https://github.com/rust-lang/rust/commit/419b26931b73209bfafdb9938c09e12b9d650613 and https://github.com/rust-lang/rust/commit/527e2eac17c5d3709e4e30e8b72ae33a6e8990b1. Those tests will no longer provide effective coverage of the AST pretty-printer after #124141. `Nonterminal` and `TokenKind::Interpolated` are being removed, and a consequence is that `stringify!` will perform token stream pretty printing, instead of AST pretty printing, in all of the `stringify!` cases including $:expr and all other interpolations. This PR adds 2 new ui tests with `compile-flags: -Zunpretty=expanded`: - **tests/ui/unpretty/expanded-exhaustive.rs** &mdash; this test aims for exhaustive coverage of all the variants of `ExprKind`, `ItemKind`, `PatKind`, `StmtKind`, `TyKind`, and `VisibilityKind`. Some parts could use being fleshed out further, but the current state is roughly on par with what exists in the old stringify-based tests. - **tests/ui/unpretty/expanded-interpolation.rs** &mdash; this test covers tricky macro metavariable edge cases that require the AST pretty printer to synthesize parentheses in order for the printed code to be valid Rust syntax. r? `@nnethercote`
2024-05-18Rollup merge of #125214 - compiler-errors:gat-guide, r=lcnr许杰友 Jieyou Xu (Joe)-1/+30
Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability In #123537, I tweaked the hack from #93892 to use `resolve_vars_if_possible` instead of `shallow_resolve`. This considers more inference guidance ambiguous. This resulted in crater regressions in #125196. I've effectively reverted the change to the old behavior. That being said, I don't *like* this behavior, but I'd rather keep it for now since #123537 was not meant to make any behavioral changes. See the attached example. This also affects the new solver, for the record, which doesn't have any rules about not guiding inference from param-env candidates which may constrain GAT args as a side-effect. r? `@lcnr` or `@jackh726`
2024-05-18Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726bors-494/+460
Rename Unsafe to Safety Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18Add tests for -Zunpretty=expanded ported from stringify's testsDavid Tolnay-51/+1807
2024-05-18Auto merge of #125254 - matthiaskrgr:rollup-ukvsxbc, r=matthiaskrgrbors-83/+120
Rollup of 4 pull requests Successful merges: - #125117 (Improve parser) - #125184 (Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen) - #125240 (Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable) - #125248 (Migrate `run-make/rustdoc-scrape-examples-invalid-expr` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-18Clarify how String::leak and into_boxed_str differJon Gjengset-5/+7