Skip to content

Produce expansion info for more builtin macros #44248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 { ... }");
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
2 changes: 1 addition & 1 deletion src/libsyntax_ext/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
})
}
1 change: 1 addition & 0 deletions src/libsyntax_ext/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/test/compile-fail/lint-impl-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ mod foo {
fn main() {
while true {} //~ ERROR: infinite loops
}

#[deny(while_true)]
fn bar() {
while cfg!(unix) {} // no error
}