Skip to content

Commit 37340a1

Browse files
committed
Auto merge of #119070 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`
2 parents e004adb + ebba9b3 commit 37340a1

Some content is hidden

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

59 files changed

+1079
-476
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
other_metrics:
6868
strategy:
6969
matrix:
70-
names: [self, ripgrep-13.0.0, webrender-2022, diesel-1.4.8, hyper-0.14.18]
70+
names: [self, rustc_tests, ripgrep-13.0.0, webrender-2022, diesel-1.4.8, hyper-0.14.18]
7171
runs-on: ubuntu-latest
7272
needs: [setup_cargo, build_metrics]
7373

@@ -118,6 +118,11 @@ jobs:
118118
with:
119119
name: self-${{ github.sha }}
120120

121+
- name: Download rustc_tests metrics
122+
uses: actions/download-artifact@v3
123+
with:
124+
name: rustc_tests-${{ github.sha }}
125+
121126
- name: Download ripgrep-13.0.0 metrics
122127
uses: actions/download-artifact@v3
123128
with:
@@ -146,7 +151,7 @@ jobs:
146151
chmod 700 ~/.ssh
147152
148153
git clone --depth 1 [email protected]:rust-analyzer/metrics.git
149-
jq -s ".[0] * .[1] * .[2] * .[3] * .[4] * .[5]" build.json self.json ripgrep-13.0.0.json webrender-2022.json diesel-1.4.8.json hyper-0.14.18.json -c >> metrics/metrics.json
154+
jq -s ".[0] * .[1] * .[2] * .[3] * .[4] * .[5] * .[6]" build.json self.json rustc_tests.json ripgrep-13.0.0.json webrender-2022.json diesel-1.4.8.json hyper-0.14.18.json -c >> metrics/metrics.json
150155
cd metrics
151156
git add .
152157
git -c user.name=Bot -c [email protected] commit --message 📈

src/tools/rust-analyzer/Cargo.lock

+6-5
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ dependencies = [
684684
"indexmap",
685685
"itertools",
686686
"limit",
687-
"line-index 0.1.0-pre.1",
687+
"line-index 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
688688
"memchr",
689689
"nohash-hasher",
690690
"once_cell",
@@ -881,17 +881,17 @@ version = "0.0.0"
881881

882882
[[package]]
883883
name = "line-index"
884-
version = "0.1.0-pre.1"
885-
source = "registry+https://github.com/rust-lang/crates.io-index"
886-
checksum = "2cad96769710c1745e11d4f940a8ff36000ade4bbada4285b001cb8aa2f745ce"
884+
version = "0.1.1"
887885
dependencies = [
888886
"nohash-hasher",
889887
"text-size",
890888
]
891889

892890
[[package]]
893891
name = "line-index"
894-
version = "0.1.0"
892+
version = "0.1.1"
893+
source = "registry+https://github.com/rust-lang/crates.io-index"
894+
checksum = "67d61795376ae2683928c218fda7d7d7db136fd38c06b7552904667f0d55580a"
895895
dependencies = [
896896
"nohash-hasher",
897897
"text-size",
@@ -1545,6 +1545,7 @@ dependencies = [
15451545
"triomphe",
15461546
"vfs",
15471547
"vfs-notify",
1548+
"walkdir",
15481549
"winapi",
15491550
"xflags",
15501551
"xshell",

src/tools/rust-analyzer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
8585
proc-macro-test = { path = "./crates/proc-macro-test" }
8686

8787
# In-tree crates that are published separately and follow semver. See lib/README.md
88-
line-index = { version = "0.1.0-pre.1" }
88+
line-index = { version = "0.1.1" }
8989
la-arena = { version = "0.3.1" }
9090
lsp-server = { version = "0.7.4" }
9191

src/tools/rust-analyzer/crates/base-db/src/span.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,26 @@ impl fmt::Debug for HirFileIdRepr {
151151

152152
impl From<FileId> for HirFileId {
153153
fn from(id: FileId) -> Self {
154-
assert!(id.index() < Self::MAX_FILE_ID);
154+
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
155+
assert!(id.index() <= Self::MAX_HIR_FILE_ID, "FileId index {} is too large", id.index());
155156
HirFileId(id.index())
156157
}
157158
}
158159

159160
impl From<MacroFileId> for HirFileId {
160161
fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self {
162+
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
161163
let id = id.as_u32();
162-
assert!(id < Self::MAX_FILE_ID);
164+
assert!(id <= Self::MAX_HIR_FILE_ID, "MacroCallId index {} is too large", id);
163165
HirFileId(id | Self::MACRO_FILE_TAG_MASK)
164166
}
165167
}
166168

167169
impl HirFileId {
168-
const MAX_FILE_ID: u32 = u32::MAX ^ Self::MACRO_FILE_TAG_MASK;
170+
const ASSERT_MAX_FILE_ID_IS_SAME: () =
171+
[()][(Self::MAX_HIR_FILE_ID != FileId::MAX_FILE_ID) as usize];
172+
173+
const MAX_HIR_FILE_ID: u32 = u32::MAX ^ Self::MACRO_FILE_TAG_MASK;
169174
const MACRO_FILE_TAG_MASK: u32 = 1 << 31;
170175

171176
#[inline]

src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs

+29-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! The actual definitions were copied from rustc's `compiler/rustc_feature/src/builtin_attrs.rs`.
44
//!
5-
//! It was last synchronized with upstream commit e29821ff85a2a3000d226f99f62f89464028d5d6.
5+
//! It was last synchronized with upstream commit c3def263a44e07e09ae6d57abfc8650227fb4972.
66
//!
77
//! The macros were adjusted to only expand to the attribute name, since that is all we need to do
88
//! name resolution, and `BUILTIN_ATTRIBUTES` is almost entirely unchanged from the original, to
@@ -240,7 +240,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
240240
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
241241
experimental!(no_sanitize)
242242
),
243-
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, experimental!(coverage)),
243+
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
244244

245245
ungated!(
246246
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
@@ -364,7 +364,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
364364
allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
365365
"allow_internal_unsafe side-steps the unsafe_code lint",
366366
),
367-
ungated!(rustc_safe_intrinsic, Normal, template!(Word), DuplicatesOk),
368367
rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing,
369368
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
370369
through unstable paths"),
@@ -453,6 +452,12 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
453452
ErrorFollowing,
454453
INTERNAL_UNSTABLE
455454
),
455+
rustc_attr!(
456+
rustc_confusables, Normal,
457+
template!(List: r#""name1", "name2", ..."#),
458+
ErrorFollowing,
459+
INTERNAL_UNSTABLE,
460+
),
456461
// Enumerates "identity-like" conversion methods to suggest on type mismatch.
457462
rustc_attr!(
458463
rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
@@ -488,6 +493,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
488493
rustc_attr!(
489494
rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
490495
),
496+
// Ensure the argument to this function is &&str during const-check.
497+
rustc_attr!(
498+
rustc_const_panic_str, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
499+
),
491500

492501
// ==========================================================================
493502
// Internal attributes, Layout related:
@@ -520,6 +529,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
520529
rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
521530
"#[rustc_pass_by_value] is used to mark types that must be passed by value instead of reference."
522531
),
532+
rustc_attr!(
533+
rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing,
534+
"#[rustc_never_returns_null_ptr] is used to mark functions returning non-null pointers."
535+
),
523536
rustc_attr!(
524537
rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, @only_local: true,
525538
"#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."
@@ -533,7 +546,11 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
533546
"#[rustc_allow_incoherent_impl] has to be added to all impl items of an incoherent inherent impl."
534547
),
535548
rustc_attr!(
536-
rustc_deny_explicit_impl, AttributeType::Normal, template!(Word), ErrorFollowing, @only_local: false,
549+
rustc_deny_explicit_impl,
550+
AttributeType::Normal,
551+
template!(List: "implement_via_object = (true|false)"),
552+
ErrorFollowing,
553+
@only_local: true,
537554
"#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
538555
),
539556
rustc_attr!(
@@ -614,6 +631,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
614631
rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing,
615632
r#"`rustc_doc_primitive` is a rustc internal attribute"#,
616633
),
634+
rustc_attr!(
635+
rustc_safe_intrinsic, Normal, template!(Word), WarnFollowing,
636+
"the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe"
637+
),
617638

618639
// ==========================================================================
619640
// Internal attributes, Testing:
@@ -625,13 +646,16 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
625646
rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),
626647
rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word), WarnFollowing),
627648
rustc_attr!(TEST, rustc_variance, Normal, template!(Word), WarnFollowing),
649+
rustc_attr!(TEST, rustc_variance_of_opaques, Normal, template!(Word), WarnFollowing),
650+
rustc_attr!(TEST, rustc_hidden_type_of_opaques, Normal, template!(Word), WarnFollowing),
628651
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
652+
rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
629653
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
630654
rustc_attr!(
631655
TEST, rustc_error, Normal,
632656
template!(Word, List: "span_delayed_bug_from_inside_query"), WarnFollowingWordOnly
633657
),
634-
rustc_attr!(TEST, rustc_dump_user_substs, Normal, template!(Word), WarnFollowing),
658+
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
635659
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
636660
rustc_attr!(
637661
TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode"), DuplicatesOk

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
//! node for a *child*, and get its hir.
66
77
use either::Either;
8-
use hir_expand::HirFileId;
9-
use syntax::ast::HasDocComments;
8+
use hir_expand::{attrs::collect_attrs, HirFileId};
109

1110
use crate::{
1211
db::DefDatabase,
@@ -118,8 +117,8 @@ impl ChildBySource for ItemScope {
118117
|(ast_id, calls)| {
119118
let adt = ast_id.to_node(db.upcast());
120119
calls.for_each(|(attr_id, call_id, calls)| {
121-
if let Some(Either::Left(attr)) =
122-
adt.doc_comments_and_attrs().nth(attr_id.ast_index())
120+
if let Some((_, Either::Left(attr))) =
121+
collect_attrs(&adt).nth(attr_id.ast_index())
123122
{
124123
res[keys::DERIVE_MACRO_CALL].insert(attr, (attr_id, call_id, calls.into()));
125124
}

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,10 @@ impl GenericParams {
222222
let module = loc.container.module(db);
223223
let func_data = db.function_data(id);
224224

225-
// Don't create an `Expander` nor call `loc.source(db)` if not needed since this
226-
// causes a reparse after the `ItemTree` has been created.
227-
let mut expander = Lazy::new(|| {
228-
(module.def_map(db), Expander::new(db, loc.source(db).file_id, module))
229-
});
225+
// Don't create an `Expander` if not needed since this
226+
// could cause a reparse after the `ItemTree` has been created due to the spanmap.
227+
let mut expander =
228+
Lazy::new(|| (module.def_map(db), Expander::new(db, loc.id.file_id(), module)));
230229
for param in func_data.params.iter() {
231230
generic_params.fill_implicit_impl_trait_args(db, &mut expander, param);
232231
}

0 commit comments

Comments
 (0)