diff options
| author | bors <bors@rust-lang.org> | 2017-09-05 02:21:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-05 02:21:02 +0000 |
| commit | 2f681bf6024b551c2bea777ae6df3e6fafaa985f (patch) | |
| tree | f86356dee9c0b35ab994159bd57696acfe45234f | |
| parent | 22d65983b9b9ef4300bc84926c0ae8e1ec1897dd (diff) | |
| parent | c4d5a1e17ba26ef3c049548470f85538eb94edfc (diff) | |
| download | rust-2f681bf6024b551c2bea777ae6df3e6fafaa985f.tar.gz rust-2f681bf6024b551c2bea777ae6df3e6fafaa985f.zip | |
Auto merge of #44248 - oli-obk:spans, r=jseyfried
Produce expansion info for more builtin macros r? @jseyfried fixes #43268
| -rw-r--r-- | src/librustc_lint/builtin.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax_ext/cfg.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax_ext/concat.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax_ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_ext/env.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-impl-fn.rs | 5 |
6 files changed, 15 insertions, 5 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 52b645638b8..780d34d5701 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -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 { ... }"); + } } } } diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 98da49545f9..1d8dc406468 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -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()); diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index bfe18dc4060..c79e7867c5f 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -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))) } diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 6f4c112acb6..8d0104e512b 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -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)), }) } diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index affebbabbbd..fcad065be52 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -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, diff --git a/src/test/compile-fail/lint-impl-fn.rs b/src/test/compile-fail/lint-impl-fn.rs index 608aec327b6..54a720d75b5 100644 --- a/src/test/compile-fail/lint-impl-fn.rs +++ b/src/test/compile-fail/lint-impl-fn.rs @@ -36,3 +36,8 @@ mod foo { fn main() { while true {} //~ ERROR: infinite loops } + +#[deny(while_true)] +fn bar() { + while cfg!(unix) {} // no error +} |
