mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-14 16:03:17 +00:00
Auto merge of #44248 - oli-obk:spans, r=jseyfried
Produce expansion info for more builtin macros r? @jseyfried fixes #43268
This commit is contained in:
commit
2f681bf602
@ -44,7 +44,7 @@ use std::collections::HashSet;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
|
||||
use syntax_pos::Span;
|
||||
use syntax_pos::{Span, SyntaxContext};
|
||||
use syntax::symbol::keywords;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
@ -75,9 +75,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
|
||||
if let hir::ExprWhile(ref cond, ..) = e.node {
|
||||
if let hir::ExprLit(ref lit) = cond.node {
|
||||
if let ast::LitKind::Bool(true) = lit.node {
|
||||
cx.span_lint(WHILE_TRUE,
|
||||
e.span,
|
||||
"denote infinite loops with loop { ... }");
|
||||
if lit.span.ctxt() == SyntaxContext::empty() {
|
||||
cx.span_lint(WHILE_TRUE,
|
||||
e.span,
|
||||
"denote infinite loops with loop { ... }");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
tts: &[tokenstream::TokenTree])
|
||||
-> Box<base::MacResult + 'static> {
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
let cfg = panictry!(p.parse_meta_item());
|
||||
|
||||
|
@ -57,5 +57,6 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
||||
}
|
||||
}
|
||||
}
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator)))
|
||||
}
|
||||
|
@ -92,6 +92,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
|
||||
|
||||
Box::new(Result {
|
||||
ident: res,
|
||||
span: sp,
|
||||
span: sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)),
|
||||
})
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
|
||||
Some(v) => v,
|
||||
};
|
||||
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let e = match env::var(&*var.as_str()) {
|
||||
Err(..) => {
|
||||
cx.expr_path(cx.path_all(sp,
|
||||
|
@ -36,3 +36,8 @@ mod foo {
|
||||
fn main() {
|
||||
while true {} //~ ERROR: infinite loops
|
||||
}
|
||||
|
||||
#[deny(while_true)]
|
||||
fn bar() {
|
||||
while cfg!(unix) {} // no error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user