Skip to content

Commit

Permalink
Emit test name in Run test runnables if it comes from a macro expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jul 2, 2021
1 parent dd69d4a commit 1d0582f
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 134 deletions.
10 changes: 10 additions & 0 deletions crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,16 @@ impl HasVisibility for AssocItem {
}
}

impl From<AssocItem> for ModuleDef {
fn from(assoc: AssocItem) -> Self {
match assoc {
AssocItem::Function(it) => ModuleDef::Function(it),
AssocItem::Const(it) => ModuleDef::Const(it),
AssocItem::TypeAlias(it) => ModuleDef::TypeAlias(it),
}
}
}

#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub enum GenericDef {
Function(Function),
Expand Down
34 changes: 24 additions & 10 deletions crates/ide/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,22 @@ pub(crate) fn annotations(
continue;
}

let action = runnable.action();
let range = runnable.nav.focus_or_full_range();

// dbg_runnable should go after the run annotation, to prevent a clone we do it this way
let dbg_runnable = (runnable.debugee() && config.debug).then(|| Annotation {
range,
kind: AnnotationKind::Runnable { debug: true, runnable: runnable.clone() },
});

if config.run {
annotations.push(Annotation {
range,

// FIXME: This one allocates without reason if run is enabled, but debug is disabled
kind: AnnotationKind::Runnable { debug: false, runnable: runnable.clone() },
kind: AnnotationKind::Runnable { debug: false, runnable },
});
}

if action.debugee && config.debug {
annotations.push(Annotation {
range,
kind: AnnotationKind::Runnable { debug: true, runnable },
});
}
annotations.extend(dbg_runnable);
}
}

Expand Down Expand Up @@ -228,6 +226,7 @@ fn main() {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -247,6 +246,7 @@ fn main() {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -332,6 +332,7 @@ fn main() {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -351,6 +352,7 @@ fn main() {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -440,6 +442,7 @@ fn main() {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -459,6 +462,7 @@ fn main() {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -601,6 +605,7 @@ fn main() {}
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -620,6 +625,7 @@ fn main() {}
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -674,6 +680,7 @@ fn main() {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -693,6 +700,7 @@ fn main() {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -816,6 +824,7 @@ mod tests {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -835,6 +844,7 @@ mod tests {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -854,6 +864,7 @@ mod tests {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -876,6 +887,7 @@ mod tests {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -898,6 +910,7 @@ mod tests {
kind: Runnable {
debug: false,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand All @@ -924,6 +937,7 @@ mod tests {
kind: Runnable {
debug: true,
runnable: Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down
2 changes: 2 additions & 0 deletions crates/ide/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2463,6 +2463,7 @@ fn foo_$0test() {}
),
Runnable(
Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down Expand Up @@ -2501,6 +2502,7 @@ mod tests$0 {
[
Runnable(
Runnable {
use_name_in_title: false,
nav: NavigationTarget {
file_id: FileId(
0,
Expand Down
Loading

0 comments on commit 1d0582f

Please sign in to comment.