Merge pull request #3330 from shssoichiro/3309-goblin-ice

Resolve ICE in needless range loop lint
This commit is contained in:
Philipp Hansch 2018-10-17 21:01:15 +02:00 committed by GitHub
commit adbaa85ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -31,7 +31,7 @@ use std::mem;
use crate::syntax::ast;
use crate::syntax::source_map::Span;
use crate::syntax_pos::BytePos;
use crate::utils::{sugg, sext};
use crate::utils::{in_macro, sugg, sext};
use crate::utils::usage::mutated_variables;
use crate::consts::{constant, Constant};
@ -1030,6 +1030,10 @@ fn check_for_loop_range<'a, 'tcx>(
body: &'tcx Expr,
expr: &'tcx Expr,
) {
if in_macro(expr.span) {
return;
}
if let Some(higher::Range {
start: Some(start),
ref end,

View file

@ -17,5 +17,10 @@ use proc_macro::{TokenStream, quote};
pub fn mini_macro(_: TokenStream) -> TokenStream {
quote!(
#[allow(unused)] fn needless_take_by_value(s: String) { println!("{}", s.len()); }
#[allow(unused)] fn needless_loop(items: &[u8]) {
for i in 0..items.len() {
println!("{}", items[i]);
}
}
)
}