]> git.lizzy.rs Git - rust.git/blob - tests/ui-fulldeps/mod_dir_path_canonicalized.rs
Rollup merge of #106946 - dtolnay:hashlinecolumn, r=m-ou-se
[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 // no-remap-src-base: Reading `file!()` (expectedly) fails when enabled.
6
7 #![feature(rustc_private)]
8
9 extern crate rustc_ast;
10 extern crate rustc_parse;
11 extern crate rustc_session;
12 extern crate rustc_span;
13
14 // Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta
15 // files.
16 #[allow(unused_extern_crates)]
17 extern crate rustc_driver;
18
19 use rustc_parse::new_parser_from_file;
20 use rustc_session::parse::ParseSess;
21 use rustc_span::source_map::FilePathMapping;
22 use std::path::Path;
23
24 #[path = "mod_dir_simple/test.rs"]
25 mod gravy;
26
27 pub fn main() {
28     rustc_span::create_default_session_globals_then(|| parse());
29
30     assert_eq!(gravy::foo(), 10);
31 }
32
33 fn parse() {
34     let parse_session = ParseSess::new(FilePathMapping::empty());
35
36     let path = Path::new(file!());
37     let path = path.canonicalize().unwrap();
38     let mut parser = new_parser_from_file(&parse_session, &path, None);
39     let _ = parser.parse_crate_mod();
40 }