]> git.lizzy.rs Git - rust.git/blob - tests/ui-fulldeps/mod_dir_path_canonicalized.rs
ff1be0804151b58973c1a41c5616e7a3cc5f73df
[rust.git] / tests / ui-fulldeps / mod_dir_path_canonicalized.rs
1 // run-pass
2 // Testing that a librustc_ast can parse modules with canonicalized base path
3 // ignore-cross-compile
4 // ignore-remote
5
6 #![feature(rustc_private)]
7
8 extern crate rustc_ast;
9 extern crate rustc_parse;
10 extern crate rustc_session;
11 extern crate rustc_span;
12
13 // Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta
14 // files.
15 #[allow(unused_extern_crates)]
16 extern crate rustc_driver;
17
18 use rustc_parse::new_parser_from_file;
19 use rustc_session::parse::ParseSess;
20 use rustc_span::source_map::FilePathMapping;
21 use std::path::Path;
22
23 #[path = "mod_dir_simple/test.rs"]
24 mod gravy;
25
26 pub fn main() {
27     rustc_span::create_default_session_globals_then(|| parse());
28
29     assert_eq!(gravy::foo(), 10);
30 }
31
32 fn parse() {
33     let parse_session = ParseSess::new(FilePathMapping::empty());
34
35     let path = Path::new(file!());
36     let path = path.canonicalize().unwrap();
37     let mut parser = new_parser_from_file(&parse_session, &path, None);
38     let _ = parser.parse_crate_mod();
39 }