Skip to content

Subtree update of rust-analyzer #119070

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

Merged
merged 52 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0beba7c
fix: Fix incorrectly replacing references in macro invocation in "Con…
jinohkang-theori Nov 14, 2023
bf645be
Put copyright on a line by itself.
jonathanpallant Nov 22, 2023
11a70f6
also make 'core_intrinsics' internal
RalfJung Nov 22, 2023
5ef5e55
Use a u64 for the rmeta root position
saethlin Nov 27, 2023
76c972c
Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-…
compiler-errors Dec 5, 2023
5f95765
fix: Fix fragment parser replacing matches with dummies on incomplete…
Veykril Dec 8, 2023
5285df4
remove redundant imports
surechen Nov 10, 2023
f9453e3
Apply suggestions from code review
saethlin Dec 11, 2023
f532576
Merge commit '457b966b171b09a7e57acb710fbca29a4b3526f0' into sync-fro…
lnicola Dec 11, 2023
71d98c5
Fix typo in cfg
lnicola Dec 11, 2023
be6d34b
Query for nearest parent block around the hint to resolve
SomeoneToIgnore Dec 11, 2023
8ae42b5
Search for parent blocks and items when resolving inlay hints
SomeoneToIgnore Dec 11, 2023
3aa6306
Auto merge of #16089 - SomeoneToIgnore:fix-parameter-inlay-hints-reso…
bors Dec 11, 2023
4e82988
Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkin
bors Dec 11, 2023
18591ae
Always render the path to be imported in the completion detail
Veykril Dec 11, 2023
801c0ea
Replace `doc_comments_and_attrs` with `collect_attrs`, 2nd round
HKalbasi Dec 11, 2023
8c3e28e
Auto merge of #16094 - HKalbasi:rustc-tests-fixup, r=HKalbasi
bors Dec 11, 2023
a254cc5
Rollup merge of #118445 - ferrocene:jp-support-reuse-in-submodules, r…
matthiaskrgr Dec 12, 2023
be035e8
Auto merge of #118817 - lnicola:sync-from-ra, r=lnicola
bors Dec 12, 2023
df7b428
Merge branch 'master' into sync-from-rust
lnicola Dec 12, 2023
54acf87
Fix formatting
lnicola Dec 12, 2023
13d4609
Merge remote-tracking branch 'upstream/master' into sync-from-rust
lnicola Dec 12, 2023
e004a5d
Auto merge of #16098 - lnicola:sync-from-rust, r=lnicola
bors Dec 12, 2023
34ec665
Simplify and improve perf of import_assets::import_for_item
Veykril Dec 12, 2023
1604ad1
Bump DEFAULT_QUERY_SEARCH_LIMIT from 40 to 100
Veykril Dec 12, 2023
d4accf8
Auto merge of #16099 - Veykril:flyimport, r=Veykril
bors Dec 12, 2023
ca995d7
fix: Fix `import_map::search_dependencies` getting confused by assoc …
Veykril Dec 12, 2023
dd42c14
Auto merge of #16101 - Veykril:search-depedencies-fix, r=Veykril
bors Dec 12, 2023
c30fd42
Publish line-index
lnicola Dec 12, 2023
785bccb
Auto merge of #16102 - lnicola:publish-libs, r=lnicola
bors Dec 12, 2023
3b23e9a
Bump line-index
lnicola Dec 12, 2023
98a8053
Auto merge of #16104 - lnicola:bump-line-index, r=lnicola
bors Dec 12, 2023
c209b5f
fix: Fix syntax bridge assigning invalid span to lifetime tokens
Veykril Dec 12, 2023
5d7453c
Auto merge of #16106 - Veykril:fix-lifetime-span-split, r=Veykril
bors Dec 12, 2023
7cc6b0f
Partially revert #16101
Veykril Dec 12, 2023
b3af191
Auto merge of #16107 - Veykril:rev-16101, r=Veykril
bors Dec 12, 2023
94af6c6
Auto merge of #16061 - Veykril:vec-completion, r=Veykril
bors Dec 13, 2023
6a40400
Update builtin attrs from rustc
HKalbasi Dec 13, 2023
f81bd0c
Auto merge of #16115 - HKalbasi:rustc-tests-fixup, r=lnicola
bors Dec 13, 2023
dd07f1f
Auto merge of #15887 - jinohkang-theori:fix/ide-assists/convert_tuple…
bors Dec 13, 2023
070cd4e
minor: Add messages to some asserts for better debugging
Veykril Dec 14, 2023
35e2f13
Auto merge of #16121 - Veykril:assert-messages, r=Veykril
bors Dec 14, 2023
9083017
Remove `ModuleId` from `TypeOwnerId`
Veykril Dec 14, 2023
7b9595a
Run rust-analyzer on rustc tests in metrics
HKalbasi Dec 14, 2023
96f6608
Auto merge of #16125 - HKalbasi:rustc-tests, r=HKalbasi
bors Dec 14, 2023
4c45d23
fix: Syntax fixup now removes subtrees with fake spans
Veykril Dec 15, 2023
34d572e
Auto merge of #16130 - Veykril:syntax-fixup, r=Veykril
bors Dec 15, 2023
a776419
Auto merge of #16123 - Veykril:simplify, r=Veykril
bors Dec 15, 2023
4f72216
Fix false positive type mismatch in const reference patterns
HKalbasi Dec 15, 2023
fa5a327
Use depth 1 in git clone
HKalbasi Dec 15, 2023
21b06c1
Auto merge of #16131 - HKalbasi:rustc-tests-fixup, r=HKalbasi
bors Dec 15, 2023
ebba9b3
Merge commit '21b06c1beb9bb59369ffd652f5d617bcf6952e05' into sync-fro…
lnicola Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/tools/rust-analyzer/.github/workflows/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
other_metrics:
strategy:
matrix:
names: [self, ripgrep-13.0.0, webrender-2022, diesel-1.4.8, hyper-0.14.18]
names: [self, rustc_tests, ripgrep-13.0.0, webrender-2022, diesel-1.4.8, hyper-0.14.18]
runs-on: ubuntu-latest
needs: [setup_cargo, build_metrics]

Expand Down Expand Up @@ -118,6 +118,11 @@ jobs:
with:
name: self-${{ github.sha }}

- name: Download rustc_tests metrics
uses: actions/download-artifact@v3
with:
name: rustc_tests-${{ github.sha }}

- name: Download ripgrep-13.0.0 metrics
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -146,7 +151,7 @@ jobs:
chmod 700 ~/.ssh

git clone --depth 1 [email protected]:rust-analyzer/metrics.git
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
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
cd metrics
git add .
git -c user.name=Bot -c [email protected] commit --message 📈
Expand Down
11 changes: 6 additions & 5 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ dependencies = [
"indexmap",
"itertools",
"limit",
"line-index 0.1.0-pre.1",
"line-index 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr",
"nohash-hasher",
"once_cell",
Expand Down Expand Up @@ -881,17 +881,17 @@ version = "0.0.0"

[[package]]
name = "line-index"
version = "0.1.0-pre.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cad96769710c1745e11d4f940a8ff36000ade4bbada4285b001cb8aa2f745ce"
version = "0.1.1"
dependencies = [
"nohash-hasher",
"text-size",
]

[[package]]
name = "line-index"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67d61795376ae2683928c218fda7d7d7db136fd38c06b7552904667f0d55580a"
dependencies = [
"nohash-hasher",
"text-size",
Expand Down Expand Up @@ -1545,6 +1545,7 @@ dependencies = [
"triomphe",
"vfs",
"vfs-notify",
"walkdir",
"winapi",
"xflags",
"xshell",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
proc-macro-test = { path = "./crates/proc-macro-test" }

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

Expand Down
11 changes: 8 additions & 3 deletions src/tools/rust-analyzer/crates/base-db/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,26 @@ impl fmt::Debug for HirFileIdRepr {

impl From<FileId> for HirFileId {
fn from(id: FileId) -> Self {
assert!(id.index() < Self::MAX_FILE_ID);
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
assert!(id.index() <= Self::MAX_HIR_FILE_ID, "FileId index {} is too large", id.index());
HirFileId(id.index())
}
}

impl From<MacroFileId> for HirFileId {
fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self {
_ = Self::ASSERT_MAX_FILE_ID_IS_SAME;
let id = id.as_u32();
assert!(id < Self::MAX_FILE_ID);
assert!(id <= Self::MAX_HIR_FILE_ID, "MacroCallId index {} is too large", id);
HirFileId(id | Self::MACRO_FILE_TAG_MASK)
}
}

impl HirFileId {
const MAX_FILE_ID: u32 = u32::MAX ^ Self::MACRO_FILE_TAG_MASK;
const ASSERT_MAX_FILE_ID_IS_SAME: () =
[()][(Self::MAX_HIR_FILE_ID != FileId::MAX_FILE_ID) as usize];

const MAX_HIR_FILE_ID: u32 = u32::MAX ^ Self::MACRO_FILE_TAG_MASK;
const MACRO_FILE_TAG_MASK: u32 = 1 << 31;

#[inline]
Expand Down
34 changes: 29 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! The actual definitions were copied from rustc's `compiler/rustc_feature/src/builtin_attrs.rs`.
//!
//! It was last synchronized with upstream commit e29821ff85a2a3000d226f99f62f89464028d5d6.
//! It was last synchronized with upstream commit c3def263a44e07e09ae6d57abfc8650227fb4972.
//!
//! The macros were adjusted to only expand to the attribute name, since that is all we need to do
//! name resolution, and `BUILTIN_ATTRIBUTES` is almost entirely unchanged from the original, to
Expand Down Expand Up @@ -240,7 +240,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
experimental!(no_sanitize)
),
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, experimental!(coverage)),
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),

ungated!(
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
Expand Down Expand Up @@ -364,7 +364,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
"allow_internal_unsafe side-steps the unsafe_code lint",
),
ungated!(rustc_safe_intrinsic, Normal, template!(Word), DuplicatesOk),
rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing,
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
through unstable paths"),
Expand Down Expand Up @@ -453,6 +452,12 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
ErrorFollowing,
INTERNAL_UNSTABLE
),
rustc_attr!(
rustc_confusables, Normal,
template!(List: r#""name1", "name2", ..."#),
ErrorFollowing,
INTERNAL_UNSTABLE,
),
// Enumerates "identity-like" conversion methods to suggest on type mismatch.
rustc_attr!(
rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
Expand Down Expand Up @@ -488,6 +493,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_attr!(
rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
),
// Ensure the argument to this function is &&str during const-check.
rustc_attr!(
rustc_const_panic_str, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
),

// ==========================================================================
// Internal attributes, Layout related:
Expand Down Expand Up @@ -520,6 +529,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_pass_by_value, Normal, template!(Word), ErrorFollowing,
"#[rustc_pass_by_value] is used to mark types that must be passed by value instead of reference."
),
rustc_attr!(
rustc_never_returns_null_ptr, Normal, template!(Word), ErrorFollowing,
"#[rustc_never_returns_null_ptr] is used to mark functions returning non-null pointers."
),
rustc_attr!(
rustc_coherence_is_core, AttributeType::CrateLevel, template!(Word), ErrorFollowing, @only_local: true,
"#![rustc_coherence_is_core] allows inherent methods on builtin types, only intended to be used in `core`."
Expand All @@ -533,7 +546,11 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
"#[rustc_allow_incoherent_impl] has to be added to all impl items of an incoherent inherent impl."
),
rustc_attr!(
rustc_deny_explicit_impl, AttributeType::Normal, template!(Word), ErrorFollowing, @only_local: false,
rustc_deny_explicit_impl,
AttributeType::Normal,
template!(List: "implement_via_object = (true|false)"),
ErrorFollowing,
@only_local: true,
"#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
),
rustc_attr!(
Expand Down Expand Up @@ -614,6 +631,10 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_doc_primitive, Normal, template!(NameValueStr: "primitive name"), ErrorFollowing,
r#"`rustc_doc_primitive` is a rustc internal attribute"#,
),
rustc_attr!(
rustc_safe_intrinsic, Normal, template!(Word), WarnFollowing,
"the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe"
),

// ==========================================================================
// Internal attributes, Testing:
Expand All @@ -625,13 +646,16 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_variance, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_variance_of_opaques, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_hidden_type_of_opaques, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
rustc_attr!(
TEST, rustc_error, Normal,
template!(Word, List: "span_delayed_bug_from_inside_query"), WarnFollowingWordOnly
),
rustc_attr!(TEST, rustc_dump_user_substs, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
rustc_attr!(
TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode"), DuplicatesOk
Expand Down
7 changes: 3 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/child_by_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! node for a *child*, and get its hir.

use either::Either;
use hir_expand::HirFileId;
use syntax::ast::HasDocComments;
use hir_expand::{attrs::collect_attrs, HirFileId};

use crate::{
db::DefDatabase,
Expand Down Expand Up @@ -118,8 +117,8 @@ impl ChildBySource for ItemScope {
|(ast_id, calls)| {
let adt = ast_id.to_node(db.upcast());
calls.for_each(|(attr_id, call_id, calls)| {
if let Some(Either::Left(attr)) =
adt.doc_comments_and_attrs().nth(attr_id.ast_index())
if let Some((_, Either::Left(attr))) =
collect_attrs(&adt).nth(attr_id.ast_index())
{
res[keys::DERIVE_MACRO_CALL].insert(attr, (attr_id, call_id, calls.into()));
}
Expand Down
9 changes: 4 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,10 @@ impl GenericParams {
let module = loc.container.module(db);
let func_data = db.function_data(id);

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