Skip to content

Commit 1c582be

Browse files
committed
Moved module resolution test in mods.rs
1 parent 8579a9b commit 1c582be

File tree

4 files changed

+195
-193
lines changed

4 files changed

+195
-193
lines changed

crates/ra_hir/src/nameres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// This module implements import-resolution/macro expansion algorithm.
22
///
3-
/// The result of this module is `CrateDefMap`: a datastructure which contains:
3+
/// The result of this module is `CrateDefMap`: a data structure which contains:
44
///
55
/// * a tree of modules for the crate
66
/// * for each module, a set of items visible in the module (directly declared

crates/ra_hir/src/nameres/tests.rs

Lines changed: 1 addition & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod macros;
22
mod globs;
33
mod incremental;
44
mod primitives;
5+
mod mods;
56

67
use std::sync::Arc;
78

@@ -312,178 +313,6 @@ fn edition_2015_imports() {
312313
"###);
313314
}
314315

315-
#[test]
316-
fn module_resolution_works_for_non_standard_filenames() {
317-
let map = def_map_with_crate_graph(
318-
"
319-
//- /my_library.rs
320-
mod foo;
321-
use self::foo::Bar;
322-
323-
//- /foo/mod.rs
324-
pub struct Bar;
325-
",
326-
crate_graph! {
327-
"my_library": ("/my_library.rs", []),
328-
},
329-
);
330-
331-
assert_snapshot_matches!(map, @r###"
332-
⋮crate
333-
⋮Bar: t v
334-
⋮foo: t
335-
336-
⋮crate::foo
337-
⋮Bar: t v
338-
"###);
339-
}
340-
341-
#[test]
342-
fn module_resolution_works_for_raw_modules() {
343-
let map = def_map_with_crate_graph(
344-
"
345-
//- /library.rs
346-
mod r#async;
347-
use self::r#async::Bar;
348-
349-
//- /async.rs
350-
pub struct Bar;
351-
",
352-
crate_graph! {
353-
"library": ("/library.rs", []),
354-
},
355-
);
356-
357-
assert_snapshot_matches!(map, @r###"
358-
⋮crate
359-
⋮Bar: t v
360-
⋮async: t
361-
362-
⋮crate::async
363-
⋮Bar: t v
364-
"###);
365-
}
366-
367-
#[test]
368-
fn module_resolution_decl_path() {
369-
let map = def_map_with_crate_graph(
370-
"
371-
//- /library.rs
372-
#[path = \"bar/baz/foo.rs\"]
373-
mod foo;
374-
use self::foo::Bar;
375-
376-
//- /bar/baz/foo.rs
377-
pub struct Bar;
378-
",
379-
crate_graph! {
380-
"library": ("/library.rs", []),
381-
},
382-
);
383-
384-
assert_snapshot_matches!(map, @r###"
385-
⋮crate
386-
⋮Bar: t v
387-
⋮foo: t
388-
389-
⋮crate::foo
390-
⋮Bar: t v
391-
"###);
392-
}
393-
394-
#[test]
395-
fn module_resolution_module_with_path_in_mod_rs() {
396-
let map = def_map_with_crate_graph(
397-
"
398-
//- /main.rs
399-
mod foo;
400-
401-
//- /foo/mod.rs
402-
#[path = \"baz.rs\"]
403-
pub mod bar;
404-
405-
use self::bar::Baz;
406-
407-
//- /foo/baz.rs
408-
pub struct Baz;
409-
",
410-
crate_graph! {
411-
"main": ("/main.rs", []),
412-
},
413-
);
414-
415-
assert_snapshot_matches!(map, @r###"
416-
⋮crate
417-
⋮foo: t
418-
419-
⋮crate::foo
420-
⋮Baz: t v
421-
⋮bar: t
422-
423-
⋮crate::foo::bar
424-
⋮Baz: t v
425-
"###);
426-
}
427-
428-
#[test]
429-
fn module_resolution_module_with_path_non_crate_root() {
430-
let map = def_map_with_crate_graph(
431-
"
432-
//- /main.rs
433-
mod foo;
434-
435-
//- /foo.rs
436-
#[path = \"baz.rs\"]
437-
pub mod bar;
438-
439-
use self::bar::Baz;
440-
441-
//- /baz.rs
442-
pub struct Baz;
443-
",
444-
crate_graph! {
445-
"main": ("/main.rs", []),
446-
},
447-
);
448-
449-
assert_snapshot_matches!(map, @r###"
450-
⋮crate
451-
⋮foo: t
452-
453-
⋮crate::foo
454-
⋮Baz: t v
455-
⋮bar: t
456-
457-
⋮crate::foo::bar
458-
⋮Baz: t v
459-
"###);
460-
}
461-
462-
#[test]
463-
fn name_res_works_for_broken_modules() {
464-
covers!(name_res_works_for_broken_modules);
465-
let map = def_map(
466-
"
467-
//- /lib.rs
468-
mod foo // no `;`, no body
469-
470-
use self::foo::Baz;
471-
472-
//- /foo/mod.rs
473-
pub mod bar;
474-
475-
pub use self::bar::Baz;
476-
477-
//- /foo/bar.rs
478-
pub struct Baz;
479-
",
480-
);
481-
assert_snapshot_matches!(map, @r###"
482-
⋮crate
483-
⋮Baz: _
484-
"###);
485-
}
486-
487316
#[test]
488317
fn item_map_using_self() {
489318
let map = def_map(
@@ -676,22 +505,3 @@ fn values_dont_shadow_extern_crates() {
676505
⋮foo: v
677506
"###);
678507
}
679-
680-
#[test]
681-
fn unresolved_module_diagnostics() {
682-
let diagnostics = MockDatabase::with_files(
683-
r"
684-
//- /lib.rs
685-
mod foo;
686-
mod bar;
687-
mod baz {}
688-
//- /foo.rs
689-
",
690-
)
691-
.diagnostics();
692-
693-
assert_snapshot_matches!(diagnostics, @r###"
694-
"mod bar;": unresolved module
695-
"###
696-
);
697-
}

0 commit comments

Comments
 (0)