Skip to content

Commit a00bd75

Browse files
authored
Rollup merge of rust-lang#129733 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? ````@ghost````
2 parents 6ab726c + 34e7e79 commit a00bd75

File tree

303 files changed

+9203
-2888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+9203
-2888
lines changed

src/tools/rust-analyzer/.git-blame-ignore-revs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
# prettier format
88
f247090558c9ba3c551566eae5882b7ca865225f
99

10-
# subtree syncs
11-
932d85b52946d917deab2c23ead552f7f713b828
10+
# pre-josh subtree syncs
1211
3e358a6827d83e8d6473913a5e304734aadfed04
12+
932d85b52946d917deab2c23ead552f7f713b828
1313
9d2cb42a413e51deb50b36794a2e1605381878fc
14-
f532576ac53ddcc666bc8d59e0b6437065e2f599
14+
b2f6fd4f961fc7e4fbfdb80cae2e6065f8436f15
1515
c48062fe2ab9a2d913d1985a6b0aec4bf936bfc1
16+
f532576ac53ddcc666bc8d59e0b6437065e2f599

src/tools/rust-analyzer/Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ dependencies = [
495495
"hir-ty",
496496
"intern",
497497
"itertools",
498-
"once_cell",
499498
"rustc-hash",
500499
"smallvec",
501500
"span",
@@ -528,7 +527,6 @@ dependencies = [
528527
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
529528
"limit",
530529
"mbe",
531-
"once_cell",
532530
"ra-ap-rustc_abi",
533531
"ra-ap-rustc_parse_format",
534532
"rustc-hash",
@@ -595,7 +593,6 @@ dependencies = [
595593
"la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
596594
"limit",
597595
"nohash-hasher",
598-
"once_cell",
599596
"oorandom",
600597
"project-model",
601598
"ra-ap-rustc_abi",
@@ -691,7 +688,6 @@ dependencies = [
691688
"hir",
692689
"ide-db",
693690
"itertools",
694-
"once_cell",
695691
"smallvec",
696692
"stdx",
697693
"syntax",
@@ -720,7 +716,6 @@ dependencies = [
720716
"line-index 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
721717
"memchr",
722718
"nohash-hasher",
723-
"once_cell",
724719
"parser",
725720
"profile",
726721
"rayon",
@@ -746,7 +741,6 @@ dependencies = [
746741
"hir",
747742
"ide-db",
748743
"itertools",
749-
"once_cell",
750744
"paths",
751745
"serde_json",
752746
"stdx",
@@ -1933,7 +1927,6 @@ dependencies = [
19331927
"expect-test",
19341928
"indexmap",
19351929
"itertools",
1936-
"once_cell",
19371930
"parser",
19381931
"ra-ap-rustc_lexer",
19391932
"rayon",

src/tools/rust-analyzer/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ rowan.opt-level = 3
1919
rustc-hash.opt-level = 3
2020
smol_str.opt-level = 3
2121
text-size.opt-level = 3
22+
serde.opt-level = 3
23+
salsa.opt-level = 3
2224
# This speeds up `cargo xtask dist`.
2325
miniz_oxide.opt-level = 3
24-
salsa.opt-level = 3
2526

2627
[profile.release]
2728
incremental = true
@@ -184,6 +185,8 @@ style = { level = "warn", priority = -1 }
184185
suspicious = { level = "warn", priority = -1 }
185186

186187
## allow following lints
188+
# subjective
189+
single_match = "allow"
187190
# () makes a fine error in most cases
188191
result_unit_err = "allow"
189192
# We don't expose public APIs that matter like this

src/tools/rust-analyzer/LICENSE-APACHE

-25
Original file line numberDiff line numberDiff line change
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
174174
of your accepting any such warranty or additional liability.
175175

176176
END OF TERMS AND CONDITIONS
177-
178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright [yyyy] [name of copyright owner]
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
http://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

src/tools/rust-analyzer/crates/hir-def/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ fst = { version = "0.4.7", default-features = false }
2323
indexmap.workspace = true
2424
itertools.workspace = true
2525
la-arena.workspace = true
26-
once_cell = "1.17.0"
2726
rustc-hash.workspace = true
2827
tracing.workspace = true
2928
smallvec.workspace = true

src/tools/rust-analyzer/crates/hir-def/src/body.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use hir_expand::{name::Name, ExpandError, InFile};
1414
use la_arena::{Arena, ArenaMap, Idx, RawIdx};
1515
use rustc_hash::FxHashMap;
1616
use smallvec::SmallVec;
17-
use span::MacroFileId;
17+
use span::{Edition, MacroFileId};
1818
use syntax::{ast, AstPtr, SyntaxNodePtr};
1919
use triomphe::Arc;
2020

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

204-
pub fn pretty_print(&self, db: &dyn DefDatabase, owner: DefWithBodyId) -> String {
205-
pretty::print_body_hir(db, self, owner)
204+
pub fn pretty_print(
205+
&self,
206+
db: &dyn DefDatabase,
207+
owner: DefWithBodyId,
208+
edition: Edition,
209+
) -> String {
210+
pretty::print_body_hir(db, self, owner, edition)
206211
}
207212

208213
pub fn pretty_print_expr(
209214
&self,
210215
db: &dyn DefDatabase,
211216
owner: DefWithBodyId,
212217
expr: ExprId,
218+
edition: Edition,
213219
) -> String {
214-
pretty::print_expr_hir(db, self, owner, expr)
220+
pretty::print_expr_hir(db, self, owner, expr, edition)
215221
}
216222

217223
fn new(

src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs

+41-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::fmt::{self, Write};
44

55
use itertools::Itertools;
6+
use span::Edition;
67

78
use crate::{
89
hir::{
@@ -15,20 +16,26 @@ use crate::{
1516

1617
use super::*;
1718

18-
pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBodyId) -> String {
19+
pub(super) fn print_body_hir(
20+
db: &dyn DefDatabase,
21+
body: &Body,
22+
owner: DefWithBodyId,
23+
edition: Edition,
24+
) -> String {
1925
let header = match owner {
20-
DefWithBodyId::FunctionId(it) => {
21-
it.lookup(db).id.resolved(db, |it| format!("fn {}", it.name.display(db.upcast())))
22-
}
26+
DefWithBodyId::FunctionId(it) => it
27+
.lookup(db)
28+
.id
29+
.resolved(db, |it| format!("fn {}", it.name.display(db.upcast(), edition))),
2330
DefWithBodyId::StaticId(it) => it
2431
.lookup(db)
2532
.id
26-
.resolved(db, |it| format!("static {} = ", it.name.display(db.upcast()))),
33+
.resolved(db, |it| format!("static {} = ", it.name.display(db.upcast(), edition))),
2734
DefWithBodyId::ConstId(it) => it.lookup(db).id.resolved(db, |it| {
2835
format!(
2936
"const {} = ",
3037
match &it.name {
31-
Some(name) => name.display(db.upcast()).to_string(),
38+
Some(name) => name.display(db.upcast(), edition).to_string(),
3239
None => "_".to_owned(),
3340
}
3441
)
@@ -39,13 +46,13 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
3946
let enum_loc = loc.parent.lookup(db);
4047
format!(
4148
"enum {}::{}",
42-
enum_loc.id.item_tree(db)[enum_loc.id.value].name.display(db.upcast()),
43-
loc.id.item_tree(db)[loc.id.value].name.display(db.upcast()),
49+
enum_loc.id.item_tree(db)[enum_loc.id.value].name.display(db.upcast(), edition),
50+
loc.id.item_tree(db)[loc.id.value].name.display(db.upcast(), edition),
4451
)
4552
}
4653
};
4754

48-
let mut p = Printer { db, body, buf: header, indent_level: 0, needs_indent: false };
55+
let mut p = Printer { db, body, buf: header, indent_level: 0, needs_indent: false, edition };
4956
if let DefWithBodyId::FunctionId(it) = owner {
5057
p.buf.push('(');
5158
let function_data = &db.function_data(it);
@@ -86,8 +93,10 @@ pub(super) fn print_expr_hir(
8693
body: &Body,
8794
_owner: DefWithBodyId,
8895
expr: ExprId,
96+
edition: Edition,
8997
) -> String {
90-
let mut p = Printer { db, body, buf: String::new(), indent_level: 0, needs_indent: false };
98+
let mut p =
99+
Printer { db, body, buf: String::new(), indent_level: 0, needs_indent: false, edition };
91100
p.print_expr(expr);
92101
p.buf
93102
}
@@ -113,6 +122,7 @@ struct Printer<'a> {
113122
buf: String,
114123
indent_level: usize,
115124
needs_indent: bool,
125+
edition: Edition,
116126
}
117127

118128
impl Write for Printer<'_> {
@@ -173,13 +183,14 @@ impl Printer<'_> {
173183
Expr::OffsetOf(offset_of) => {
174184
w!(self, "builtin#offset_of(");
175185
self.print_type_ref(&offset_of.container);
186+
let edition = self.edition;
176187
w!(
177188
self,
178189
", {})",
179190
offset_of
180191
.fields
181192
.iter()
182-
.format_with(".", |field, f| f(&field.display(self.db.upcast())))
193+
.format_with(".", |field, f| f(&field.display(self.db.upcast(), edition)))
183194
);
184195
}
185196
Expr::Path(path) => self.print_path(path),
@@ -201,7 +212,7 @@ impl Printer<'_> {
201212
}
202213
Expr::Loop { body, label } => {
203214
if let Some(lbl) = label {
204-
w!(self, "{}: ", self.body[*lbl].name.display(self.db.upcast()));
215+
w!(self, "{}: ", self.body[*lbl].name.display(self.db.upcast(), self.edition));
205216
}
206217
w!(self, "loop ");
207218
self.print_expr(*body);
@@ -221,10 +232,11 @@ impl Printer<'_> {
221232
}
222233
Expr::MethodCall { receiver, method_name, args, generic_args } => {
223234
self.print_expr(*receiver);
224-
w!(self, ".{}", method_name.display(self.db.upcast()));
235+
w!(self, ".{}", method_name.display(self.db.upcast(), self.edition));
225236
if let Some(args) = generic_args {
226237
w!(self, "::<");
227-
print_generic_args(self.db, args, self).unwrap();
238+
let edition = self.edition;
239+
print_generic_args(self.db, args, self, edition).unwrap();
228240
w!(self, ">");
229241
}
230242
w!(self, "(");
@@ -259,13 +271,13 @@ impl Printer<'_> {
259271
Expr::Continue { label } => {
260272
w!(self, "continue");
261273
if let Some(lbl) = label {
262-
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast()));
274+
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast(), self.edition));
263275
}
264276
}
265277
Expr::Break { expr, label } => {
266278
w!(self, "break");
267279
if let Some(lbl) = label {
268-
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast()));
280+
w!(self, " {}", self.body[*lbl].name.display(self.db.upcast(), self.edition));
269281
}
270282
if let Some(expr) = expr {
271283
self.whitespace();
@@ -307,9 +319,10 @@ impl Printer<'_> {
307319
}
308320

309321
w!(self, "{{");
322+
let edition = self.edition;
310323
self.indented(|p| {
311324
for field in &**fields {
312-
w!(p, "{}: ", field.name.display(self.db.upcast()));
325+
w!(p, "{}: ", field.name.display(self.db.upcast(), edition));
313326
p.print_expr(field.expr);
314327
wln!(p, ",");
315328
}
@@ -326,7 +339,7 @@ impl Printer<'_> {
326339
}
327340
Expr::Field { expr, name } => {
328341
self.print_expr(*expr);
329-
w!(self, ".{}", name.display(self.db.upcast()));
342+
w!(self, ".{}", name.display(self.db.upcast(), self.edition));
330343
}
331344
Expr::Await { expr } => {
332345
self.print_expr(*expr);
@@ -464,8 +477,9 @@ impl Printer<'_> {
464477
}
465478
Expr::Literal(lit) => self.print_literal(lit),
466479
Expr::Block { id: _, statements, tail, label } => {
467-
let label =
468-
label.map(|lbl| format!("{}: ", self.body[lbl].name.display(self.db.upcast())));
480+
let label = label.map(|lbl| {
481+
format!("{}: ", self.body[lbl].name.display(self.db.upcast(), self.edition))
482+
});
469483
self.print_block(label.as_deref(), statements, tail);
470484
}
471485
Expr::Unsafe { id: _, statements, tail } => {
@@ -539,9 +553,10 @@ impl Printer<'_> {
539553
}
540554

541555
w!(self, " {{");
556+
let edition = self.edition;
542557
self.indented(|p| {
543558
for arg in args.iter() {
544-
w!(p, "{}: ", arg.name.display(self.db.upcast()));
559+
w!(p, "{}: ", arg.name.display(self.db.upcast(), edition));
545560
p.print_pat(arg.pat);
546561
wln!(p, ",");
547562
}
@@ -686,11 +701,13 @@ impl Printer<'_> {
686701
}
687702

688703
fn print_type_ref(&mut self, ty: &TypeRef) {
689-
print_type_ref(self.db, ty, self).unwrap();
704+
let edition = self.edition;
705+
print_type_ref(self.db, ty, self, edition).unwrap();
690706
}
691707

692708
fn print_path(&mut self, path: &Path) {
693-
print_path(self.db, path, self).unwrap();
709+
let edition = self.edition;
710+
print_path(self.db, path, self, edition).unwrap();
694711
}
695712

696713
fn print_binding(&mut self, id: BindingId) {
@@ -701,6 +718,6 @@ impl Printer<'_> {
701718
BindingAnnotation::Ref => "ref ",
702719
BindingAnnotation::RefMut => "ref mut ",
703720
};
704-
w!(self, "{}{}", mode, name.display(self.db.upcast()));
721+
w!(self, "{}{}", mode, name.display(self.db.upcast(), self.edition));
705722
}
706723
}

src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn main() {
219219
},
220220
);
221221
}"#]]
222-
.assert_eq(&body.pretty_print(&db, def))
222+
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
223223
}
224224

225225
#[test]
@@ -285,7 +285,7 @@ impl SsrError {
285285
),
286286
);
287287
}"#]]
288-
.assert_eq(&body.pretty_print(&db, def))
288+
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
289289
}
290290

291291
#[test]
@@ -333,5 +333,5 @@ fn f(a: i32, b: u32) -> String {
333333
);
334334
};
335335
}"#]]
336-
.assert_eq(&body.pretty_print(&db, def))
336+
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
337337
}

0 commit comments

Comments
 (0)