You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
917 B
28 lines
917 B
7 months ago
|
use crate::gen::Opt;
|
||
|
use crate::syntax::report::Errors;
|
||
|
use crate::syntax::{error, Api};
|
||
|
use quote::{quote, quote_spanned};
|
||
|
use std::path::{Component, Path};
|
||
|
|
||
|
pub(super) use crate::syntax::check::typecheck;
|
||
|
|
||
|
pub(super) fn precheck(cx: &mut Errors, apis: &[Api], opt: &Opt) {
|
||
|
if !opt.allow_dot_includes {
|
||
|
check_dot_includes(cx, apis);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn check_dot_includes(cx: &mut Errors, apis: &[Api]) {
|
||
|
for api in apis {
|
||
|
if let Api::Include(include) = api {
|
||
|
let first_component = Path::new(&include.path).components().next();
|
||
|
if let Some(Component::CurDir) | Some(Component::ParentDir) = first_component {
|
||
|
let begin = quote_spanned!(include.begin_span=> .);
|
||
|
let end = quote_spanned!(include.end_span=> .);
|
||
|
let span = quote!(#begin #end);
|
||
|
cx.error(span, error::DOT_INCLUDE.msg);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|