about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhkalbasi <hamidrezakalbasi@protonmail.com>2023-01-16 23:45:12 +0330
committerhkalbasi <hamidrezakalbasi@protonmail.com>2023-01-16 23:45:12 +0330
commitec65b3b3aa96bbf9cd44580c938c80034f066f0d (patch)
tree054dd5aec140cb744b6023a30f519b0a9e2b43d7
parent77efa0267dcae86235d8688d8b886d13e2b99c0b (diff)
downloadrust-ec65b3b3aa96bbf9cd44580c938c80034f066f0d.tar.gz
rust-ec65b3b3aa96bbf9cd44580c938c80034f066f0d.zip
fix tests
-rw-r--r--crates/base-db/src/fixture.rs4
-rw-r--r--crates/ide/src/hover/tests.rs24
2 files changed, 21 insertions, 7 deletions
diff --git a/crates/base-db/src/fixture.rs b/crates/base-db/src/fixture.rs
index 6f83ea40e76..b267700a431 100644
--- a/crates/base-db/src/fixture.rs
+++ b/crates/base-db/src/fixture.rs
@@ -110,6 +110,7 @@ impl ChangeFixture {
         let mut crates = FxHashMap::default();
         let mut crate_deps = Vec::new();
         let mut default_crate_root: Option<FileId> = None;
+        let mut default_target_data_layout: Option<String> = None;
         let mut default_cfg = CfgOptions::default();
 
         let mut file_set = FileSet::default();
@@ -175,6 +176,7 @@ impl ChangeFixture {
                 assert!(default_crate_root.is_none());
                 default_crate_root = Some(file_id);
                 default_cfg = meta.cfg;
+                default_target_data_layout = meta.target_data_layout;
             }
 
             change.change_file(file_id, Some(Arc::new(text)));
@@ -198,7 +200,7 @@ impl ChangeFixture {
                 Ok(Vec::new()),
                 false,
                 CrateOrigin::CratesIo { repo: None, name: None },
-                None,
+                default_target_data_layout.map(|x| x.into()),
             );
         } else {
             for (from, to, prelude) in crate_deps {
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index c7f241f2fea..f90ca86f9b6 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -527,6 +527,7 @@ fn hover_field_offset() {
     // Hovering over the field when instantiating
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
 struct Foo { fiel$0d_a: u8, field_b: i32, field_c: i16 }
 "#,
         expect![[r#"
@@ -548,6 +549,7 @@ fn hover_shows_struct_field_info() {
     // Hovering over the field when instantiating
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
 struct Foo { field_a: u32 }
 
 fn main() {
@@ -570,6 +572,7 @@ fn main() {
     // Hovering over the field in the definition
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
 struct Foo { field_a$0: u32 }
 
 fn main() {
@@ -1515,6 +1518,8 @@ fn my() {}
 fn test_hover_struct_doc_comment() {
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
+
 /// This is an example
 /// multiline doc
 ///
@@ -1573,7 +1578,7 @@ fn foo() { let bar = Ba$0r; }
             ```
 
             ```rust
-            struct Bar // size = 0, align = 1
+            struct Bar
             ```
 
             ---
@@ -1602,7 +1607,7 @@ fn foo() { let bar = Ba$0r; }
             ```
 
             ```rust
-            struct Bar // size = 0, align = 1
+            struct Bar
             ```
 
             ---
@@ -1630,7 +1635,7 @@ pub struct B$0ar
             ```
 
             ```rust
-            pub struct Bar // size = 0, align = 1
+            pub struct Bar
             ```
 
             ---
@@ -1657,7 +1662,7 @@ pub struct B$0ar
             ```
 
             ```rust
-            pub struct Bar // size = 0, align = 1
+            pub struct Bar
             ```
 
             ---
@@ -2959,6 +2964,8 @@ fn main() { let foo_test = name_with_dashes::wrapper::Thing::new$0(); }
 fn hover_field_pat_shorthand_ref_match_ergonomics() {
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
+
 struct S {
     f: i32,
 }
@@ -4398,6 +4405,7 @@ fn main() {
 fn hover_intra_doc_links() {
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
 
 pub mod theitem {
     /// This is the item. Cool!
@@ -4539,7 +4547,7 @@ trait A where
 fn string_shadowed_with_inner_items() {
     check(
         r#"
-//- /main.rs crate:main deps:alloc
+//- /main.rs crate:main deps:alloc target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
 
 /// Custom `String` type.
 struct String;
@@ -5234,7 +5242,7 @@ foo_macro!(
             ```
 
             ```rust
-            pub struct Foo // size = 0, align = 1
+            pub struct Foo
             ```
 
             ---
@@ -5248,6 +5256,8 @@ foo_macro!(
 fn hover_intra_in_attr() {
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
+
 #[doc = "Doc comment for [`Foo$0`]"]
 pub struct Foo(i32);
 "#,
@@ -5368,6 +5378,8 @@ enum Enum {
 fn hover_record_variant_field() {
     check(
         r#"
+//- /main.rs target_data_layout:e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128
+
 enum Enum {
     RecordV { field$0: u32 }
 }