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

⬆️ rust-analyzer #104454

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7c56896
Feat: extracted method from trait impl is placed in existing impl
TiddoLangerak Aug 9, 2022
7402366
Avoid cloning IMPL node if we don't have to
TiddoLangerak Aug 10, 2022
d5e6aa3
Pre-cast impl nodes to ast::Impl in find_non_trait_impl
TiddoLangerak Sep 1, 2022
c98fc53
Generalize reborrow hints as adjustment hints
Veykril Nov 4, 2022
95d20fc
Add adjustment hint tests
Veykril Nov 4, 2022
d841ad1
Fix up adjustment hints configurations
Veykril Nov 4, 2022
e468a1a
internal: Optimize `apply_document_changes` a bit
Veykril Nov 4, 2022
28afe57
Add tests for LineEndings::normalize
Veykril Nov 5, 2022
b87a23b
Rename convertor -> converter
lowr Nov 2, 2022
41b0c54
Fix `tt::Punct`'s spacing calculation
lowr Nov 5, 2022
1dcc25a
internal: Use a process group for flycheck
Veykril Nov 5, 2022
7742077
Auto merge of #13552 - Veykril:flycheck-process-group, r=Veykril
bors Nov 7, 2022
f54c313
Auto merge of #13547 - Veykril:line-index, r=Veykril
bors Nov 7, 2022
cff7ab1
Fix typos
lnicola Nov 7, 2022
364820a
Auto merge of #13566 - lnicola:therefor, r=lnicola
bors Nov 7, 2022
f24fbc2
rustfmt
Veykril Nov 7, 2022
8ad4a1d
Update sysroot crates
Veykril Nov 7, 2022
d3d3806
Auto merge of #12991 - TiddoLangerak:extract-method-from-trait-into-i…
bors Nov 7, 2022
180b4ce
Fix the length displayed for byte string literals with escaped newlines
noritada Nov 7, 2022
c0310c1
Auto merge of #13565 - Veykril:sysroot, r=Veykril
bors Nov 7, 2022
ee2dd93
Don't trigger adjustment hints in all inlay hint tests
Veykril Nov 7, 2022
ffd7bf8
Bump Cargo rust-version fields to latest stable
Veykril Nov 7, 2022
bdf8547
Clarify the intent
noritada Nov 7, 2022
3a839ea
Auto merge of #13569 - Veykril:rust-version, r=Veykril
bors Nov 7, 2022
b0e56ef
Auto merge of #13545 - Veykril:adjustment-hints, r=Veykril
bors Nov 7, 2022
2340d70
Add test code for unescaping byte strings
noritada Nov 7, 2022
b169e1e
Remove code duplication
Veykril Nov 7, 2022
8a633fe
Auto merge of #13570 - Veykril:dedup-crates-for, r=Veykril
bors Nov 7, 2022
d1c9775
Auto merge of #13568 - noritada:fix/len-of-byte-string-with-escaped-n…
bors Nov 7, 2022
6a06f6f
Deduplicate reference search results
Veykril Nov 7, 2022
a27e4da
Auto merge of #13571 - Veykril:unique-references, r=Veykril
bors Nov 7, 2022
fa70b0a
internal: Use Cancellable in favor of Result for clarity
Veykril Nov 7, 2022
0aa0da9
Auto merge of #13572 - Veykril:cancellable, r=Veykril
bors Nov 7, 2022
1cb6ab8
internal: error instead of panic on invalid file range
Veykril Nov 7, 2022
b8b1951
Auto merge of #13573 - Veykril:invalid-file-range, r=Veykril
bors Nov 7, 2022
90e2db8
fix: Fix item completions not working properly after unit structs and…
Veykril Nov 8, 2022
236c116
Auto merge of #13581 - Veykril:unit-struct-compl, r=Veykril
bors Nov 8, 2022
4403dde
Nest Cargo.lock under Cargo.toml in Code
lnicola Nov 8, 2022
977a029
Auto merge of #13582 - lnicola:nest-cargo-toml, r=lnicola
bors Nov 8, 2022
9be0615
Don't canonicalize self type when querying FnOnce signature
Nov 8, 2022
392784a
Auto merge of #13584 - jonas-schievink:fix-signature-panic, r=jonas-s…
bors Nov 8, 2022
3c35d44
Add proc-macro dependency to rustc_private crates
Veykril Nov 9, 2022
599142c
Auto merge of #13590 - Veykril:proc-macro-rustc-src, r=Veykril
bors Nov 9, 2022
4f415fc
Ignore outermost non-delimited `Subtree` when reversing fixups
lowr Nov 10, 2022
5b07061
Test `TokenTree`s' equality modulo `Punct`s' spacing
lowr Nov 10, 2022
dea49d0
fix: check visibility of each segment in path resolution
lowr Nov 11, 2022
e75afeb
Resolve invisible defs in `fix_visibility` assist
lowr Nov 11, 2022
19306c0
Fix tests that depended on loose visibility restriction
lowr Nov 11, 2022
e35836e
Send status notification if there are no found workspaces
Veykril Nov 11, 2022
ff78d24
Auto merge of #13603 - Veykril:no-workspaces, r=Veykril
bors Nov 11, 2022
6f313ce
Auto merge of #13548 - lowr:fix/tt-punct-spacing, r=Veykril
bors Nov 11, 2022
57cc2a6
Auto merge of #13602 - lowr:fix/nameres-transitive-visibility, r=Veykril
bors Nov 11, 2022
e50712c
fix: Fix hover in attributed items not preferring similar kinded tokens
Veykril Nov 11, 2022
add8539
Auto merge of #13604 - Veykril:hover-attr, r=Veykril
bors Nov 11, 2022
a143ff0
fix: Fix r-a eagerly showing no discovered workspace errors
Veykril Nov 11, 2022
d3531e8
Auto merge of #13605 - Veykril:empty-ws-error, r=Veykril
bors Nov 11, 2022
6674bd8
fix: Add trait alias grammar to rust.ungram
Veykril Nov 11, 2022
2656303
Auto merge of #13606 - Veykril:trait-alias, r=Veykril
bors Nov 11, 2022
6b4b7d8
internal: Add version info to unsupported proc macro abi error
Veykril Nov 11, 2022
45ec315
Auto merge of #13607 - Veykril:proc-macro-error, r=Veykril
bors Nov 11, 2022
5d36be5
:arrow_up: rust-analyzer
lnicola Nov 15, 2022
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
24 changes: 24 additions & 0 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ dependencies = [
"tracing",
]

[[package]]
name = "command-group"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7a8a86f409b4a59df3a3e4bee2de0b83f1755fdd2a25e3a9684c396fc4bed2c"
dependencies = [
"nix",
"winapi",
]

[[package]]
name = "countme"
version = "3.0.1"
Expand Down Expand Up @@ -390,6 +400,7 @@ name = "flycheck"
version = "0.0.0"
dependencies = [
"cargo_metadata",
"command-group",
"crossbeam-channel",
"jod-thread",
"paths",
Expand Down Expand Up @@ -970,6 +981,19 @@ dependencies = [
"windows-sys 0.28.0",
]

[[package]]
name = "nix"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [
"bitflags",
"cc",
"cfg-if",
"libc",
"memoffset",
]

[[package]]
name = "notify"
version = "5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
description = "TBD"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.57"
rust-version = "1.65"

[lib]
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
description = "TBD"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.57"
rust-version = "1.65"

[lib]
doctest = false
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/flycheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
description = "TBD"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.57"
rust-version = "1.65"

[lib]
doctest = false
Expand All @@ -17,6 +17,7 @@ rustc-hash = "1.1.0"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.86"
jod-thread = "0.1.2"
command-group = "1.0.8"

toolchain = { path = "../toolchain", version = "0.0.0" }
stdx = { path = "../stdx", version = "0.0.0" }
Expand Down
21 changes: 12 additions & 9 deletions src/tools/rust-analyzer/crates/flycheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use std::{
time::Duration,
};

use command_group::{CommandGroup, GroupChild};
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
use paths::AbsPathBuf;
use rustc_hash::FxHashMap;
use serde::Deserialize;
use stdx::{process::streaming_output, JodChild};
use stdx::process::streaming_output;

pub use cargo_metadata::diagnostic::{
Applicability, Diagnostic, DiagnosticCode, DiagnosticLevel, DiagnosticSpan,
Expand Down Expand Up @@ -359,10 +360,12 @@ impl FlycheckActor {
}
}

struct JodChild(GroupChild);

/// A handle to a cargo process used for fly-checking.
struct CargoHandle {
/// The handle to the actual cargo process. As we cannot cancel directly from with
/// a read syscall dropping and therefor terminating the process is our best option.
/// a read syscall dropping and therefore terminating the process is our best option.
child: JodChild,
thread: jod_thread::JoinHandle<io::Result<(bool, String)>>,
receiver: Receiver<CargoMessage>,
Expand All @@ -371,10 +374,10 @@ struct CargoHandle {
impl CargoHandle {
fn spawn(mut command: Command) -> std::io::Result<CargoHandle> {
command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
let mut child = JodChild::spawn(command)?;
let mut child = command.group_spawn().map(JodChild)?;

let stdout = child.stdout.take().unwrap();
let stderr = child.stderr.take().unwrap();
let stdout = child.0.inner().stdout.take().unwrap();
let stderr = child.0.inner().stderr.take().unwrap();

let (sender, receiver) = unbounded();
let actor = CargoActor::new(sender, stdout, stderr);
Expand All @@ -386,13 +389,13 @@ impl CargoHandle {
}

fn cancel(mut self) {
let _ = self.child.kill();
let _ = self.child.wait();
let _ = self.child.0.kill();
let _ = self.child.0.wait();
}

fn join(mut self) -> io::Result<()> {
let _ = self.child.kill();
let exit_status = self.child.wait()?;
let _ = self.child.0.kill();
let exit_status = self.child.0.wait()?;
let (read_at_least_one_message, error) = self.thread.join()?;
if read_at_least_one_message || exit_status.success() {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
description = "TBD"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.57"
rust-version = "1.65"

[lib]
doctest = false
Expand Down
18 changes: 13 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,19 @@ impl TraitData {
.by_key("rustc_skip_array_during_method_dispatch")
.exists();

let mut collector =
AssocItemCollector::new(db, module_id, tree_id.file_id(), ItemContainerId::TraitId(tr));
collector.collect(&item_tree, tree_id.tree_id(), &tr_def.items);
let (items, attribute_calls, diagnostics) = collector.finish();

let (items, attribute_calls, diagnostics) = match &tr_def.items {
Some(items) => {
let mut collector = AssocItemCollector::new(
db,
module_id,
tree_id.file_id(),
ItemContainerId::TraitId(tr),
);
collector.collect(&item_tree, tree_id.tree_id(), items);
collector.finish()
}
None => Default::default(),
};
(
Arc::new(TraitData {
name,
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,8 @@ pub struct Trait {
pub generic_params: Interned<GenericParams>,
pub is_auto: bool,
pub is_unsafe: bool,
pub items: Box<[AssocItem]>,
/// This is [`None`] if this Trait is a trait alias.
pub items: Option<Box<[AssocItem]>>,
pub ast_id: FileAstId<ast::Trait>,
}

Expand Down
10 changes: 1 addition & 9 deletions src/tools/rust-analyzer/crates/hir-def/src/item_tree/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,7 @@ impl<'a> Ctx<'a> {
.collect()
});
let ast_id = self.source_ast_id_map.ast_id(trait_def);
let res = Trait {
name,
visibility,
generic_params,
is_auto,
is_unsafe,
items: items.unwrap_or_default(),
ast_id,
};
let res = Trait { name, visibility, generic_params, is_auto, is_unsafe, items, ast_id };
Some(id(self.data().traits.alloc(res)))
}

Expand Down
19 changes: 14 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/item_tree/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,21 @@ impl<'a> Printer<'a> {
}
w!(self, "trait {}", name);
self.print_generic_params(generic_params);
self.print_where_clause_and_opening_brace(generic_params);
self.indented(|this| {
for item in &**items {
this.print_mod_item((*item).into());
match items {
Some(items) => {
self.print_where_clause_and_opening_brace(generic_params);
self.indented(|this| {
for item in &**items {
this.print_mod_item((*item).into());
}
});
}
});
None => {
w!(self, " = ");
// FIXME: Print the aliased traits
self.print_where_clause_and_opening_brace(generic_params);
}
}
wln!(self, "}}");
}
ModItem::Impl(it) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ macro_rules! m {
($($s:stmt)*) => (stringify!($($s |)*);)
}
stringify!(;
|;
|92|;
|let x = 92|;
| ;
|92| ;
|let x = 92| ;
|loop {}
|;
| ;
|);
"#]],
);
Expand All @@ -118,7 +118,7 @@ m!(.. .. ..);
macro_rules! m {
($($p:pat)*) => (stringify!($($p |)*);)
}
stringify!(.. .. ..|);
stringify!(.. .. .. |);
"#]],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ fn attribute_macro_syntax_completion_2() {
#[proc_macros::identity_when_valid]
fn foo() { bar.; blub }
"#,
expect![[r##"
expect![[r#"
#[proc_macros::identity_when_valid]
fn foo() { bar.; blub }

fn foo() {
bar.;
bar. ;
blub
}"##]],
}"#]],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ impl Import {

#[derive(Debug, Eq, PartialEq)]
struct ImportDirective {
/// The module this import directive is in.
module_id: LocalModuleId,
import: Import,
status: PartialResolvedImport,
Expand Down Expand Up @@ -963,8 +964,10 @@ impl DefCollector<'_> {

fn update(
&mut self,
// The module for which `resolutions` have been resolve
module_id: LocalModuleId,
resolutions: &[(Option<Name>, PerNs)],
// Visibility this import will have
vis: Visibility,
import_type: ImportType,
) {
Expand All @@ -974,6 +977,7 @@ impl DefCollector<'_> {

fn update_recursive(
&mut self,
// The module for which `resolutions` have been resolve
module_id: LocalModuleId,
resolutions: &[(Option<Name>, PerNs)],
// All resolutions are imported with this visibility; the visibilities in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ impl DefMap {
pub(crate) fn resolve_visibility(
&self,
db: &dyn DefDatabase,
// module to import to
original_module: LocalModuleId,
// pub(path)
// ^^^^ this
visibility: &RawVisibility,
) -> Option<Visibility> {
let mut vis = match visibility {
Expand Down Expand Up @@ -115,6 +118,7 @@ impl DefMap {
&self,
db: &dyn DefDatabase,
mode: ResolveMode,
// module to import to
mut original_module: LocalModuleId,
path: &ModPath,
shadow: BuiltinShadowMode,
Expand Down Expand Up @@ -361,6 +365,9 @@ impl DefMap {
);
}
};

curr_per_ns = curr_per_ns
.filter_visibility(|vis| vis.is_visible_from_def_map(db, self, original_module));
}

ResolvePathResult::with(curr_per_ns, ReachedFixedPoint::Yes, None, Some(self.krate))
Expand Down
6 changes: 3 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/src/nameres/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ extern {
"#,
expect![[r#"
crate
E: t
E: _
S: t v
V: t v
V: _
foo: t

crate::foo
Expand Down Expand Up @@ -307,7 +307,7 @@ pub struct FromLib;
Bar: t v

crate::foo
Bar: t v
Bar: _
FromLib: t v
"#]],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ use foo::*;
use foo::bar::*;

//- /foo/mod.rs
mod bar;
pub mod bar;
fn Foo() {};
pub struct Foo {};

Expand All @@ -132,6 +132,7 @@ pub(crate) struct PubCrateStruct;
crate
Foo: t
PubCrateStruct: t v
bar: t
foo: t

crate::foo
Expand Down Expand Up @@ -336,3 +337,33 @@ mod d {
"#]],
);
}

#[test]
fn glob_name_collision_check_visibility() {
check(
r#"
mod event {
mod serenity {
pub fn Event() {}
}
use serenity::*;

pub struct Event {}
}

use event::Event;
"#,
expect![[r#"
crate
Event: t
event: t

crate::event
Event: t v
serenity: t

crate::event::serenity
Event: v
"#]],
);
}
Loading