9 use base_db::{fixture::WithFixture, SourceDatabase};
10 use expect::{expect, Expect};
13 use crate::{db::DefDatabase, nameres::*, test_db::TestDB};
15 fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
16 let db = TestDB::with_files(fixture);
17 let krate = db.crate_graph().iter().next().unwrap();
18 db.crate_def_map(krate)
21 fn check(ra_fixture: &str, expect: Expect) {
22 let db = TestDB::with_files(ra_fixture);
23 let krate = db.crate_graph().iter().next().unwrap();
24 let actual = db.crate_def_map(krate).dump();
25 expect.assert_eq(&actual);
29 fn crate_def_map_smoke_test() {
35 use crate::foo::bar::E;
45 union U { to_be: bool, not_to_be: u8 }
75 fn crate_def_map_super_super() {
108 fn crate_def_map_fn_mod_same_name() {
130 mark::check!(bogus_paths);
158 use crate::foo::Baz as Foo;
180 use crate::foo::bar::{Baz, Quux};
215 pub use self::bar::Baz;
237 mark::check!(std_prelude);
240 //- /main.rs crate:main deps:test_crate
243 //- /lib.rs crate:test_crate
249 pub enum Foo { Bar, Baz };
260 fn can_import_enum_variant() {
261 mark::check!(can_import_enum_variant);
276 fn edition_2015_imports() {
279 //- /main.rs crate:main deps:other_crate edition:2015
288 use other_crate::FromLib;
290 //- /lib.rs crate:other_crate edition:2018
309 fn item_map_using_self() {
314 use crate::foo::bar::Baz::{self};
337 fn item_map_across_crates() {
340 //- /main.rs crate:main deps:test_crate
343 //- /lib.rs crate:test_crate
354 fn extern_crate_rename() {
357 //- /main.rs crate:main deps:alloc
358 extern crate alloc as alloc_crate;
363 use alloc_crate::Arc;
365 //- /lib.rs crate:alloc
380 fn extern_crate_rename_2015_edition() {
383 //- /main.rs crate:main deps:alloc edition:2015
384 extern crate alloc as alloc_crate;
389 use alloc_crate::Arc;
391 //- /lib.rs crate:alloc
406 fn reexport_across_crates() {
409 //- /main.rs crate:main deps:test_crate
412 //- /lib.rs crate:test_crate
427 fn values_dont_shadow_extern_crates() {
430 //- /main.rs crate:main deps:foo
434 //- /foo/lib.rs crate:foo
446 fn std_prelude_takes_precedence_above_core_prelude() {
449 //- /main.rs crate:main deps:core,std
452 //- /std.rs crate:std deps:core
454 pub use self::prelude::*;
457 pub use core::prelude::Bar;
460 //- /core.rs crate:core
462 pub use self::prelude::*;
479 //- /main.rs crate:main deps:std
482 //- /lib.rs crate:std
484 pub use self::prelude::*;
490 #[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
507 //- /main.rs crate:main deps:std
510 //- /lib.rs crate:std cfg:test,feature=foo,feature=bar,opt=42
512 pub use self::prelude::*;
518 #[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
532 fn infer_multiple_namespace() {
544 pub const T: () = ();
563 fn underscore_import() {
589 fn underscore_reexport() {
598 use crate::tr::PrivTr as _;
599 pub use crate::tr::PubTr as _;
621 fn underscore_pub_crate_reexport() {
622 mark::check!(upgrade_underscore_visibility);
625 //- /main.rs crate:main deps:lib
628 //- /lib.rs crate:lib
644 fn underscore_nontrait() {
651 pub const CONST: () = ();
653 use crate::m::{Struct as _, Enum as _, CONST as _};
668 fn underscore_name_conflict() {