Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtree update of rust-analyzer #129733

Merged
merged 145 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
c1245e1
Add new assist toggle_macro_delimiter
alibektas Aug 1, 2024
662f02f
Make toggle_macro_delimiters work only for macro_calls
alibektas Aug 2, 2024
aa6e8d3
Allow declaring cfg groups in rust-project.json, to help sharing comm…
ChayimFriedman2 Aug 11, 2024
5e058db
docs: Add a doc comment for OpQueue
Wilfred Aug 13, 2024
54ecca0
Auto merge of #17885 - Wilfred:op_queue_docs, r=lnicola
bors Aug 14, 2024
4a14155
Be more resilient to bad language item definitions in binop inference
lnicola Aug 14, 2024
e2f2e73
Auto merge of #17891 - lnicola:binop-bad-lang-items, r=flodiebold
bors Aug 14, 2024
81b68b2
fix: Panic while canonicalizing erroneous projection type
ShoyuVanilla Aug 14, 2024
89cd585
Auto merge of #17882 - ShoyuVanilla:issue-17866, r=lnicola
bors Aug 14, 2024
b0183f8
fix: Panic while displaying associated function with a type annotation
ShoyuVanilla Aug 14, 2024
e20180d
Auto merge of #17893 - ShoyuVanilla:issue-17871, r=flodiebold
bors Aug 15, 2024
a783e30
internal: Properly check the edition for edition dependent syntax kinds
Veykril Aug 15, 2024
a594a2d
Auto merge of #17896 - Veykril:editioned-syntax-kinds, r=Veykril
bors Aug 15, 2024
bf4d31d
Add scip/lsif flag to exclude vendored libaries
darichey Aug 15, 2024
23c8dcd
Allow flycheck process to exit gracefully
tmandry Aug 15, 2024
642a0f8
Replace once_cell with std's recently stabilized OnceCell/Lock and La…
ChayimFriedman2 Aug 16, 2024
0cbf6a7
Test for word boundary in `FindUsages`
ChayimFriedman2 Aug 16, 2024
b68992a
Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril
bors Aug 16, 2024
95f5e4b
Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykril
bors Aug 16, 2024
fdd5294
Auto merge of #17903 - tmandry:graceful-exit, r=Veykril
bors Aug 16, 2024
4ca597a
implement basic inferring of lifetimes
dfireBird Jun 29, 2024
2071778
Auto merge of #17595 - dfireBird:infer-lt, r=flodiebold
bors Aug 16, 2024
3d6129d
Properly account for editions in names
ChayimFriedman2 Aug 15, 2024
6908451
Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword,…
bors Aug 16, 2024
995a014
Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidba…
bors Aug 16, 2024
6fc487d
Remove rust-analyzer.workspace.discoverProjectRunner
darichey Aug 16, 2024
01245bd
Auto merge of #17909 - darichey:remove-discoverProjectRunner, r=lnicola
bors Aug 16, 2024
d3fa5e9
Pin `rowan` to `0.15.15`
ShoyuVanilla Aug 17, 2024
d2d41b4
Auto merge of #17917 - ShoyuVanilla:pin-rowan, r=lnicola
bors Aug 17, 2024
c4b8c65
fix: Wrong BoundVar index when lowering impl trait parameter of paren…
ShoyuVanilla Aug 17, 2024
eb12861
Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
bors Aug 17, 2024
d0ce97f
feat: Make rust-analyzer work partially when missing an internet conn…
Veykril Aug 17, 2024
324cf83
Adress new clippy::large_enum_variant diagnostics
Veykril Aug 17, 2024
51e3775
Auto merge of #17915 - Veykril:offline-no-deps, r=Veykril
bors Aug 17, 2024
74db4d3
Include generics when lowering extern type
darichey Aug 18, 2024
2c18533
Auto merge of #17925 - darichey:issue-17767, r=Veykril
bors Aug 19, 2024
1bfb362
chore(config): remove `invocationLocation` in favor of `invocationStr…
Tyrubias Aug 14, 2024
85f6d15
Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykril
bors Aug 19, 2024
036affc
fix: keep comments in convert_while_to_loop
roife Aug 19, 2024
05f5c77
Auto merge of #17928 - roife:fix-issue-17869, r=Veykril
bors Aug 19, 2024
b2062ea
Improve documentation for `InvocationStrategy`
Veykril Aug 19, 2024
f17e9a0
Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
bors Aug 19, 2024
bd6ea75
Remove the ability to configure the user config path
Veykril Aug 19, 2024
879fa66
Allow user config to not exist
Veykril Aug 19, 2024
ea12d79
fix: Panic when a TAIT exists in a RPIT
ShoyuVanilla Aug 18, 2024
f9c0c8a
Auto merge of #17924 - ShoyuVanilla:issue-17921, r=Veykril
bors Aug 19, 2024
f25cb80
ServerStatusParams should consider 'prime caches' in quiescent status
Wilfred Aug 13, 2024
df6ce96
Auto merge of #17886 - Wilfred:prime_caches_quiescent, r=Veykril
bors Aug 19, 2024
a7d15a8
fix: Fix panics for semantic highlighting at startup
Veykril Aug 20, 2024
a9e3555
Auto merge of #17932 - Veykril:default-reply-lat-sensitive, r=Veykril
bors Aug 20, 2024
a42c732
Define workspace level configs.
alibektas Aug 16, 2024
8e31598
Next up : generating configs for workspace level configs
alibektas Aug 16, 2024
1b2eaa5
Old configs are back
alibektas Aug 17, 2024
085aac3
Auto merge of #17930 - Veykril:config-user-config, r=alibektas
bors Aug 20, 2024
9cb66c2
Auto merge of #17913 - alibektas:ratoml_improvements, r=alibektas
bors Aug 20, 2024
94f206a
Run flycheck only on crate if target is binary.
alibektas Aug 20, 2024
3f89eeb
internal: Implement `module_path` macro
Veykril Aug 21, 2024
db2e8e1
fix: Wrong `Sized` predicate for `generic_predicates_for_param`
ShoyuVanilla Aug 21, 2024
614fb24
Auto merge of #17939 - ShoyuVanilla:maybe-sized-fix, r=Veykril
bors Aug 22, 2024
f845536
Remove DescendPreference::SameText
Veykril Aug 22, 2024
d893dcc
Drop MacroInputKind
Veykril Aug 22, 2024
aeb9c7b
Implement floating point casts in const eval
HKalbasi Aug 22, 2024
1179cbb
Remove DescendPreference::SameKind
Veykril Aug 22, 2024
8e82e44
Fully remove old macro descension API
Veykril Aug 22, 2024
4d61444
Rename macro descension functions
Veykril Aug 22, 2024
d79999a
Thread file id through descension API for semantic highlighting
Veykril Aug 22, 2024
b0e7ef4
Sort hover results by relevance
Veykril Aug 22, 2024
f9db48f
Consider interleaving hover kinds
Veykril Aug 22, 2024
06228b9
Auto merge of #17942 - HKalbasi:fp-const-eval, r=HKalbasi
bors Aug 22, 2024
71c7cea
Fix sorting order for tokens in hover
Veykril Aug 22, 2024
81a9956
Auto merge of #17898 - Veykril:descend-2.0, r=Veykril
bors Aug 22, 2024
0a27711
Improve proc-macro panic message and workspace loading failure diagno…
Veykril Aug 22, 2024
1b0e158
Auto merge of #17943 - Veykril:diags, r=Veykril
bors Aug 22, 2024
f65d605
When descending into macros in search, first check if there is a need…
ChayimFriedman2 Aug 16, 2024
a57def2
Speed up search for short associated functions, especially very commo…
ChayimFriedman2 Aug 18, 2024
a44152a
Add cov_marks to test #17927
ChayimFriedman2 Aug 22, 2024
0251cfa
Apply changes
alibektas Aug 22, 2024
b88a4f0
Auto merge of #17912 - alibektas:cargo_check_on_binary, r=Veykril
bors Aug 23, 2024
916c559
Remove incorrect FIXME comment
Veykril Aug 23, 2024
39cc5b6
Auto merge of #17927 - ChayimFriedman2:speedup-new-usages, r=Veykril
bors Aug 23, 2024
ac912c7
Auto merge of #17936 - Veykril:module_path, r=Veykril
bors Aug 23, 2024
5f7489a
internal: Don't requery crates_for for flycheck when crates are known
Veykril Aug 23, 2024
e030cf0
Auto merge of #17946 - Veykril:flycheck-crates-for, r=Veykril
bors Aug 23, 2024
3a097e1
Auto merge of #17857 - ChayimFriedman2:rust-project-cfg-group, r=Veykril
bors Aug 23, 2024
eb896a5
fix: Wrong `Self: Sized` predicate for trait assoc items
ShoyuVanilla Aug 23, 2024
3bd42d3
Auto merge of #17948 - ShoyuVanilla:parent-self-sized, r=Veykril
bors Aug 23, 2024
bdbc057
Include buildfile path in watcher list
Wilfred Aug 23, 2024
a074e1a
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
bors Aug 24, 2024
12faedd
Fix few bugs in closure capture computation, and add tests
ChayimFriedman2 Aug 24, 2024
77ab568
Preserve all spans for closure captures, not just one
ChayimFriedman2 Aug 24, 2024
cf243e5
Add `gen` modifier to functions
ChayimFriedman2 Aug 22, 2024
1e0df17
Handle associated types that are lang items
ChayimFriedman2 Aug 22, 2024
2c6a521
Provide `Future::Output` and `Iterator` lang items
ChayimFriedman2 Aug 22, 2024
737a969
Add helper methods to retrieve `Future::Output` and `Iterator::Item`
ChayimFriedman2 Aug 22, 2024
7339337
Modify `hacks::parse_expr_from_str()` to take an edition too
ChayimFriedman2 Aug 22, 2024
6340522
Provide `impl From<ast::TypeOrConstParam> for ast::GenericParam`
ChayimFriedman2 Aug 22, 2024
becfc5a
Impl PartialEq and Eq for `IndentLevel`
ChayimFriedman2 Aug 22, 2024
7bd3ca1
Don't enable the search fast path for short associated functions when…
ChayimFriedman2 Aug 25, 2024
cba00a8
Auto merge of #17955 - ChayimFriedman2:fix-fast-search-with-scope, r=…
bors Aug 25, 2024
d9d8d94
fix: Fix metadata retrying eating original errors
Veykril Aug 25, 2024
c223013
Auto merge of #17956 - Veykril:metadata-err, r=Veykril
bors Aug 25, 2024
606401f
fix: Fix trait method completions not acknowledging Deref impls
Veykril Aug 25, 2024
bdee5c9
Auto merge of #17958 - Veykril:deref-chain-method-completions, r=Veykril
bors Aug 25, 2024
2703ea1
fix: add extra_test_bin_args to test explorer test runner
Aug 25, 2024
98e23d3
internal: Don't allocate autoderef steps when not needed
Veykril Aug 25, 2024
31a532a
Auto merge of #17961 - Veykril:autoderef-alloc, r=Veykril
bors Aug 25, 2024
e0b1719
Auto merge of #17960 - duncanawoods:master, r=HKalbasi
bors Aug 25, 2024
326a1c6
Fix Return Type Syntax to include `..` (i.e. `method(..)` and not `me…
ChayimFriedman2 Aug 25, 2024
a3f1196
Auto merge of #17962 - ChayimFriedman2:update-rtn, r=Veykril
bors Aug 26, 2024
239dc5d
Auto merge of #17941 - ChayimFriedman2:pre-closure-to-fn, r=Veykril
bors Aug 26, 2024
9dad25a
Show and render error lifetime args as `'_`
avrong Aug 26, 2024
9d4fdc0
Show lifetime args if there are only error ones
avrong Aug 26, 2024
05e6fb6
Auto merge of #17963 - avrong:avrong/error-lifetimes, r=Veykril
bors Aug 26, 2024
65e9f8b
Fix "Unwrap block" assist with block modifiers
ChayimFriedman2 Aug 26, 2024
65d25fe
Revert "feat: Implement `module_path` macro"
Veykril Aug 27, 2024
f0bfd43
Auto merge of #17972 - rust-lang:revert-17936-module_path, r=Veykril
bors Aug 27, 2024
6593688
Auto merge of #17970 - ChayimFriedman2:unwrap-unsafe-block, r=Veykril
bors Aug 27, 2024
df4580b
Expand proc-macros in workspace root, not package root
Veykril Aug 27, 2024
b592256
Drop Apache license appendices
lnicola Aug 27, 2024
e4c404e
Auto merge of #17973 - Veykril:proc-macro-curr-dir, r=Veykril
bors Aug 27, 2024
2dce250
Auto merge of #17974 - lnicola:rm-apache-appendix, r=lnicola
bors Aug 27, 2024
c9a3b02
Fix tests
Veykril Aug 27, 2024
199c01d
Auto merge of #17757 - alibektas:toggle_macro_delimiters, r=Veykril
bors Aug 27, 2024
34e50f5
Create an assist to convert closure to freestanding fn
ChayimFriedman2 Aug 22, 2024
51055f7
Fix cwd used for proc macro expansion
lnicola Aug 28, 2024
248a557
Auto merge of #17981 - lnicola:proc-macro-cwd, r=Veykril
bors Aug 28, 2024
4880eee
Fix name resolution of shadowed builtin macro
ChayimFriedman2 Aug 28, 2024
2a7ec0b
Consider all expressions that autoderef in "Extract variable", not ju…
ChayimFriedman2 Aug 28, 2024
fe5f91e
Don't add reference when it isn't needed for the "Extract variable" a…
ChayimFriedman2 Aug 28, 2024
5aefe78
internal: Avoid newlines in fetch workspace errors
Wilfred Aug 28, 2024
3ff3d39
Also handle deref expressions in "Extract variable"
ChayimFriedman2 Aug 28, 2024
b3fcd8e
Consider field attributes when converting from tuple to named struct …
ChayimFriedman2 Aug 28, 2024
c2c1bd0
Fix incorrect symbol definitions in SCIP output
darichey Aug 28, 2024
3a14e30
Auto merge of #17992 - Wilfred:newlines_in_logs, r=Veykril
bors Aug 29, 2024
14ec120
fix: Fix proc-macro server crashing when parsing a non-lexable string…
Veykril Aug 29, 2024
03d6745
fix: Fix TokenStream::to_string implementation dropping quotation marks
Veykril Aug 29, 2024
266bb1f
Auto merge of #17994 - Veykril:proc-macro-srv-from-str-panic, r=Veykril
bors Aug 29, 2024
2ec71c8
Preparing for merge from rust-lang/rust
lnicola Aug 29, 2024
26888c3
Merge from rust-lang/rust
lnicola Aug 29, 2024
f05888d
Auto merge of #17995 - lnicola:sync-from-rust, r=lnicola
bors Aug 29, 2024
b195ff3
Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykril
bors Aug 29, 2024
e0625d5
Auto merge of #17988 - darichey:fix-scip-def, r=Veykril
bors Aug 29, 2024
b6d0fd0
Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykril
bors Aug 29, 2024
cd377d9
Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykril
bors Aug 29, 2024
34e7e79
Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykril
bors Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 4 additions & 3 deletions src/tools/rust-analyzer/.git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
# prettier format
f247090558c9ba3c551566eae5882b7ca865225f

# subtree syncs
932d85b52946d917deab2c23ead552f7f713b828
# pre-josh subtree syncs
3e358a6827d83e8d6473913a5e304734aadfed04
932d85b52946d917deab2c23ead552f7f713b828
9d2cb42a413e51deb50b36794a2e1605381878fc
f532576ac53ddcc666bc8d59e0b6437065e2f599
b2f6fd4f961fc7e4fbfdb80cae2e6065f8436f15
c48062fe2ab9a2d913d1985a6b0aec4bf936bfc1
f532576ac53ddcc666bc8d59e0b6437065e2f599
7 changes: 0 additions & 7 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ dependencies = [
"hir-ty",
"intern",
"itertools",
"once_cell",
"rustc-hash",
"smallvec",
"span",
Expand Down Expand Up @@ -528,7 +527,6 @@ dependencies = [
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"limit",
"mbe",
"once_cell",
"ra-ap-rustc_abi",
"ra-ap-rustc_parse_format",
"rustc-hash",
Expand Down Expand Up @@ -595,7 +593,6 @@ dependencies = [
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"limit",
"nohash-hasher",
"once_cell",
"oorandom",
"project-model",
"ra-ap-rustc_abi",
Expand Down Expand Up @@ -691,7 +688,6 @@ dependencies = [
"hir",
"ide-db",
"itertools",
"once_cell",
"smallvec",
"stdx",
"syntax",
Expand Down Expand Up @@ -720,7 +716,6 @@ dependencies = [
"line-index 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr",
"nohash-hasher",
"once_cell",
"parser",
"profile",
"rayon",
Expand All @@ -746,7 +741,6 @@ dependencies = [
"hir",
"ide-db",
"itertools",
"once_cell",
"paths",
"serde_json",
"stdx",
Expand Down Expand Up @@ -1933,7 +1927,6 @@ dependencies = [
"expect-test",
"indexmap",
"itertools",
"once_cell",
"parser",
"ra-ap-rustc_lexer",
"rayon",
Expand Down
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ rowan.opt-level = 3
rustc-hash.opt-level = 3
smol_str.opt-level = 3
text-size.opt-level = 3
serde.opt-level = 3
salsa.opt-level = 3
# This speeds up `cargo xtask dist`.
miniz_oxide.opt-level = 3
salsa.opt-level = 3

[profile.release]
incremental = true
Expand Down Expand Up @@ -184,6 +185,8 @@ style = { level = "warn", priority = -1 }
suspicious = { level = "warn", priority = -1 }

## allow following lints
# subjective
single_match = "allow"
# () makes a fine error in most cases
result_unit_err = "allow"
# We don't expose public APIs that matter like this
Expand Down
25 changes: 0 additions & 25 deletions src/tools/rust-analyzer/LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1 change: 0 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fst = { version = "0.4.7", default-features = false }
indexmap.workspace = true
itertools.workspace = true
la-arena.workspace = true
once_cell = "1.17.0"
rustc-hash.workspace = true
tracing.workspace = true
smallvec.workspace = true
Expand Down
14 changes: 10 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hir_expand::{name::Name, ExpandError, InFile};
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use span::MacroFileId;
use span::{Edition, MacroFileId};
use syntax::{ast, AstPtr, SyntaxNodePtr};
use triomphe::Arc;

Expand Down Expand Up @@ -201,17 +201,23 @@ impl Body {
self.block_scopes.iter().map(move |&block| (block, db.block_def_map(block)))
}

pub fn pretty_print(&self, db: &dyn DefDatabase, owner: DefWithBodyId) -> String {
pretty::print_body_hir(db, self, owner)
pub fn pretty_print(
&self,
db: &dyn DefDatabase,
owner: DefWithBodyId,
edition: Edition,
) -> String {
pretty::print_body_hir(db, self, owner, edition)
}

pub fn pretty_print_expr(
&self,
db: &dyn DefDatabase,
owner: DefWithBodyId,
expr: ExprId,
edition: Edition,
) -> String {
pretty::print_expr_hir(db, self, owner, expr)
pretty::print_expr_hir(db, self, owner, expr, edition)
}

fn new(
Expand Down
65 changes: 41 additions & 24 deletions src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::fmt::{self, Write};

use itertools::Itertools;
use span::Edition;

use crate::{
hir::{
Expand All @@ -15,20 +16,26 @@ use crate::{

use super::*;

pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBodyId) -> String {
pub(super) fn print_body_hir(
db: &dyn DefDatabase,
body: &Body,
owner: DefWithBodyId,
edition: Edition,
) -> String {
let header = match owner {
DefWithBodyId::FunctionId(it) => {
it.lookup(db).id.resolved(db, |it| format!("fn {}", it.name.display(db.upcast())))
}
DefWithBodyId::FunctionId(it) => it
.lookup(db)
.id
.resolved(db, |it| format!("fn {}", it.name.display(db.upcast(), edition))),
DefWithBodyId::StaticId(it) => it
.lookup(db)
.id
.resolved(db, |it| format!("static {} = ", it.name.display(db.upcast()))),
.resolved(db, |it| format!("static {} = ", it.name.display(db.upcast(), edition))),
DefWithBodyId::ConstId(it) => it.lookup(db).id.resolved(db, |it| {
format!(
"const {} = ",
match &it.name {
Some(name) => name.display(db.upcast()).to_string(),
Some(name) => name.display(db.upcast(), edition).to_string(),
None => "_".to_owned(),
}
)
Expand All @@ -39,13 +46,13 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
let enum_loc = loc.parent.lookup(db);
format!(
"enum {}::{}",
enum_loc.id.item_tree(db)[enum_loc.id.value].name.display(db.upcast()),
loc.id.item_tree(db)[loc.id.value].name.display(db.upcast()),
enum_loc.id.item_tree(db)[enum_loc.id.value].name.display(db.upcast(), edition),
loc.id.item_tree(db)[loc.id.value].name.display(db.upcast(), edition),
)
}
};

let mut p = Printer { db, body, buf: header, indent_level: 0, needs_indent: false };
let mut p = Printer { db, body, buf: header, indent_level: 0, needs_indent: false, edition };
if let DefWithBodyId::FunctionId(it) = owner {
p.buf.push('(');
let function_data = &db.function_data(it);
Expand Down Expand Up @@ -86,8 +93,10 @@ pub(super) fn print_expr_hir(
body: &Body,
_owner: DefWithBodyId,
expr: ExprId,
edition: Edition,
) -> String {
let mut p = Printer { db, body, buf: String::new(), indent_level: 0, needs_indent: false };
let mut p =
Printer { db, body, buf: String::new(), indent_level: 0, needs_indent: false, edition };
p.print_expr(expr);
p.buf
}
Expand All @@ -113,6 +122,7 @@ struct Printer<'a> {
buf: String,
indent_level: usize,
needs_indent: bool,
edition: Edition,
}

impl Write for Printer<'_> {
Expand Down Expand Up @@ -173,13 +183,14 @@ impl Printer<'_> {
Expr::OffsetOf(offset_of) => {
w!(self, "builtin#offset_of(");
self.print_type_ref(&offset_of.container);
let edition = self.edition;
w!(
self,
", {})",
offset_of
.fields
.iter()
.format_with(".", |field, f| f(&field.display(self.db.upcast())))
.format_with(".", |field, f| f(&field.display(self.db.upcast(), edition)))
);
}
Expr::Path(path) => self.print_path(path),
Expand All @@ -201,7 +212,7 @@ impl Printer<'_> {
}
Expr::Loop { body, label } => {
if let Some(lbl) = label {
w!(self, "{}: ", self.body[*lbl].name.display(self.db.upcast()));
w!(self, "{}: ", self.body[*lbl].name.display(self.db.upcast(), self.edition));
}
w!(self, "loop ");
self.print_expr(*body);
Expand All @@ -221,10 +232,11 @@ impl Printer<'_> {
}
Expr::MethodCall { receiver, method_name, args, generic_args } => {
self.print_expr(*receiver);
w!(self, ".{}", method_name.display(self.db.upcast()));
w!(self, ".{}", method_name.display(self.db.upcast(), self.edition));
if let Some(args) = generic_args {
w!(self, "::<");
print_generic_args(self.db, args, self).unwrap();
let edition = self.edition;
print_generic_args(self.db, args, self, edition).unwrap();
w!(self, ">");
}
w!(self, "(");
Expand Down Expand Up @@ -259,13 +271,13 @@ impl Printer<'_> {
Expr::Continue { label } => {
w!(self, "continue");
if let Some(lbl) = label {
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast()));
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast(), self.edition));
}
}
Expr::Break { expr, label } => {
w!(self, "break");
if let Some(lbl) = label {
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast()));
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast(), self.edition));
}
if let Some(expr) = expr {
self.whitespace();
Expand Down Expand Up @@ -307,9 +319,10 @@ impl Printer<'_> {
}

w!(self, "{{");
let edition = self.edition;
self.indented(|p| {
for field in &**fields {
w!(p, "{}: ", field.name.display(self.db.upcast()));
w!(p, "{}: ", field.name.display(self.db.upcast(), edition));
p.print_expr(field.expr);
wln!(p, ",");
}
Expand All @@ -326,7 +339,7 @@ impl Printer<'_> {
}
Expr::Field { expr, name } => {
self.print_expr(*expr);
w!(self, ".{}", name.display(self.db.upcast()));
w!(self, ".{}", name.display(self.db.upcast(), self.edition));
}
Expr::Await { expr } => {
self.print_expr(*expr);
Expand Down Expand Up @@ -464,8 +477,9 @@ impl Printer<'_> {
}
Expr::Literal(lit) => self.print_literal(lit),
Expr::Block { id: _, statements, tail, label } => {
let label =
label.map(|lbl| format!("{}: ", self.body[lbl].name.display(self.db.upcast())));
let label = label.map(|lbl| {
format!("{}: ", self.body[lbl].name.display(self.db.upcast(), self.edition))
});
self.print_block(label.as_deref(), statements, tail);
}
Expr::Unsafe { id: _, statements, tail } => {
Expand Down Expand Up @@ -539,9 +553,10 @@ impl Printer<'_> {
}

w!(self, " {{");
let edition = self.edition;
self.indented(|p| {
for arg in args.iter() {
w!(p, "{}: ", arg.name.display(self.db.upcast()));
w!(p, "{}: ", arg.name.display(self.db.upcast(), edition));
p.print_pat(arg.pat);
wln!(p, ",");
}
Expand Down Expand Up @@ -686,11 +701,13 @@ impl Printer<'_> {
}

fn print_type_ref(&mut self, ty: &TypeRef) {
print_type_ref(self.db, ty, self).unwrap();
let edition = self.edition;
print_type_ref(self.db, ty, self, edition).unwrap();
}

fn print_path(&mut self, path: &Path) {
print_path(self.db, path, self).unwrap();
let edition = self.edition;
print_path(self.db, path, self, edition).unwrap();
}

fn print_binding(&mut self, id: BindingId) {
Expand All @@ -701,6 +718,6 @@ impl Printer<'_> {
BindingAnnotation::Ref => "ref ",
BindingAnnotation::RefMut => "ref mut ",
};
w!(self, "{}{}", mode, name.display(self.db.upcast()));
w!(self, "{}{}", mode, name.display(self.db.upcast(), self.edition));
}
}
6 changes: 3 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn main() {
},
);
}"#]]
.assert_eq(&body.pretty_print(&db, def))
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
}

#[test]
Expand Down Expand Up @@ -285,7 +285,7 @@ impl SsrError {
),
);
}"#]]
.assert_eq(&body.pretty_print(&db, def))
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
}

#[test]
Expand Down Expand Up @@ -333,5 +333,5 @@ fn f(a: i32, b: u32) -> String {
);
};
}"#]]
.assert_eq(&body.pretty_print(&db, def))
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
}
Loading
Loading