Skip to content

Commit 83ab648

Browse files
committed
Auto merge of #134377 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents eedc229 + 5c6bae0 commit 83ab648

File tree

71 files changed

+8793
-2177
lines changed

Some content is hidden

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

71 files changed

+8793
-2177
lines changed

src/tools/rust-analyzer/.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ jobs:
220220
timeout-minutes: 10
221221
env:
222222
FORCE_COLOR: 1
223-
TYPOS_VERSION: v1.18.0
223+
TYPOS_VERSION: v1.28.3
224224
steps:
225225
- name: download typos
226226
run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

src/tools/rust-analyzer/.typos.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ extend-ignore-re = [
1616
"raison d'être",
1717
"inout",
1818
"INOUT",
19-
"optin"
19+
"optin",
20+
"=Pn",
2021
]
2122

2223
[default.extend-words]
@@ -26,8 +27,12 @@ fo = "fo"
2627
ket = "ket"
2728
makro = "makro"
2829
trivias = "trivias"
30+
thir = "thir"
31+
jod = "jod"
2932

3033
[default.extend-identifiers]
34+
anc = "anc"
3135
datas = "datas"
3236
impl_froms = "impl_froms"
3337
selfs = "selfs"
38+
taits = "taits"

src/tools/rust-analyzer/Cargo.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ version = "0.1.5"
389389
source = "registry+https://github.com/rust-lang/crates.io-index"
390390
checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1"
391391

392+
[[package]]
393+
name = "edition"
394+
version = "0.0.0"
395+
392396
[[package]]
393397
name = "either"
394398
version = "1.13.0"
@@ -1266,6 +1270,7 @@ name = "parser"
12661270
version = "0.0.0"
12671271
dependencies = [
12681272
"drop_bomb",
1273+
"edition",
12691274
"expect-test",
12701275
"limit",
12711276
"ra-ap-rustc_lexer",
@@ -2662,6 +2667,7 @@ version = "0.1.0"
26622667
dependencies = [
26632668
"anyhow",
26642669
"directories",
2670+
"edition",
26652671
"either",
26662672
"flate2",
26672673
"itertools",

src/tools/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
8383
tt = { path = "./crates/tt", version = "0.0.0" }
8484
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8585
vfs = { path = "./crates/vfs", version = "0.0.0" }
86+
edition = { path = "./crates/edition", version = "0.0.0" }
8687

8788
ra-ap-rustc_lexer = { version = "0.85", default-features = false }
8889
ra-ap-rustc_parse_format = { version = "0.85", default-features = false }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "edition"
3+
version = "0.0.0"
4+
rust-version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
10+
[dependencies]
11+
12+
[lints]
13+
workspace = true

src/tools/rust-analyzer/crates/parser/src/edition.rs renamed to src/tools/rust-analyzer/crates/edition/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! The edition of the Rust language used in a crate.
2-
// Ideally this would be defined in the span crate, but the dependency chain is all over the place
3-
// wrt to span, parser and syntax.
2+
// This should live in a separate crate because we use it in both actual code and codegen.
43
use std::fmt;
54

65
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]

src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl BuiltinFnLikeExpander {
7474
}
7575

7676
pub fn is_asm(&self) -> bool {
77-
matches!(self, Self::Asm | Self::GlobalAsm)
77+
matches!(self, Self::Asm | Self::GlobalAsm | Self::NakedAsm)
7878
}
7979
}
8080

@@ -122,6 +122,7 @@ register_builtin! {
122122
(stringify, Stringify) => stringify_expand,
123123
(asm, Asm) => asm_expand,
124124
(global_asm, GlobalAsm) => asm_expand,
125+
(naked_asm, NakedAsm) => asm_expand,
125126
(cfg, Cfg) => cfg_expand,
126127
(core_panic, CorePanic) => panic_expand,
127128
(std_panic, StdPanic) => panic_expand,

src/tools/rust-analyzer/crates/hir-expand/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use rustc_hash::FxHashMap;
2828
use stdx::TupleExt;
2929
use triomphe::Arc;
3030

31+
use core::fmt;
3132
use std::hash::Hash;
3233

3334
use base_db::{ra_salsa::InternValueTrivial, CrateId};
@@ -147,6 +148,10 @@ impl ExpandError {
147148
pub fn span(&self) -> Span {
148149
self.inner.1
149150
}
151+
152+
pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
153+
self.inner.0.render_to_string(db)
154+
}
150155
}
151156

152157
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
@@ -164,18 +169,18 @@ pub enum ExpandErrorKind {
164169
ProcMacroPanic(Box<str>),
165170
}
166171

167-
impl ExpandError {
168-
pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
169-
self.inner.0.render_to_string(db)
170-
}
171-
}
172-
173172
pub struct RenderedExpandError {
174173
pub message: String,
175174
pub error: bool,
176175
pub kind: &'static str,
177176
}
178177

178+
impl fmt::Display for RenderedExpandError {
179+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
180+
write!(f, "{}", self.message)
181+
}
182+
}
183+
179184
impl RenderedExpandError {
180185
const GENERAL_KIND: &str = "macro-error";
181186
}

src/tools/rust-analyzer/crates/hir-ty/src/display.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,21 @@ impl HirDisplay for Ty {
10531053
generic_args_sans_defaults(f, Some(generic_def_id), parameters);
10541054
assert!(params_len >= parameters.len());
10551055
let defaults = params_len - parameters.len();
1056-
let without_impl =
1057-
self_param as usize + type_ + const_ + lifetime - defaults;
1056+
1057+
// Normally, functions cannot have default parameters, but they can,
1058+
// for function-like things such as struct names or enum variants.
1059+
// The former cannot have defaults but parents, and the later cannot have
1060+
// parents but defaults.
1061+
// So, if `parent_len` > 0, it have a parent and thus it doesn't have any
1062+
// default. Therefore, we shouldn't subtract defaults because those defaults
1063+
// are from their parents.
1064+
// And if `parent_len` == 0, either parents don't exists or they don't have
1065+
// any defaults. Thus, we can - and should - subtract defaults.
1066+
let without_impl = if parent_len > 0 {
1067+
params_len - parent_len - impl_
1068+
} else {
1069+
params_len - parent_len - impl_ - defaults
1070+
};
10581071
// parent's params (those from enclosing impl or trait, if any).
10591072
let (fn_params, parent_params) = parameters.split_at(without_impl + impl_);
10601073

src/tools/rust-analyzer/crates/hir-ty/src/interner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl chalk_ir::interner::Interner for Interner {
5555
type InternedConst = Interned<InternedWrapper<ConstData>>;
5656
type InternedConcreteConst = ConstScalar;
5757
type InternedGenericArg = GenericArgData;
58-
// We could do the following, but that saves "only" 20mb on self while increasing inferecene
58+
// We could do the following, but that saves "only" 20mb on self while increasing inference
5959
// time by ~2.5%
6060
// type InternedGoal = Interned<InternedWrapper<GoalData>>;
6161
type InternedGoal = Arc<GoalData>;

0 commit comments

Comments
 (0)