rust/src/test/ui-fulldeps/mod_dir_path_canonicalized.rs

33 lines
809 B
Rust
Raw Normal View History

// run-pass
// Testing that a libsyntax can parse modules with canonicalized base path
// ignore-cross-compile
#![feature(rustc_private)]
extern crate syntax;
2019-10-10 03:26:10 -05:00
extern crate syntax_expand;
use std::path::Path;
2019-10-14 03:08:26 -05:00
use syntax::sess::ParseSess;
2018-08-18 05:14:03 -05:00
use syntax::source_map::FilePathMapping;
2019-10-10 03:26:10 -05:00
use syntax::parse::new_parser_from_file;
use syntax_expand::config::process_configure_mod;
#[path = "mod_dir_simple/test.rs"]
mod gravy;
pub fn main() {
syntax::with_default_globals(|| parse());
assert_eq!(gravy::foo(), 10);
}
fn parse() {
2019-10-10 03:26:10 -05:00
let parse_session = ParseSess::new(FilePathMapping::empty(), process_configure_mod);
let path = Path::new(file!());
let path = path.canonicalize().unwrap();
2019-10-10 03:26:10 -05:00
let mut parser = new_parser_from_file(&parse_session, &path);
let _ = parser.parse_crate_mod();
}