Fixes #14185.
This fix suppresses dead_code warnings from code generated by regex! when the result of regex! is unused. Correct behavior should be a single unused variable warning. Regression tests are included for both `let` and `static` bound regex! values.
This commit is contained in:
@@ -142,11 +142,20 @@ impl<'a> NfaGen<'a> {
|
||||
let regex = self.original.as_slice();
|
||||
|
||||
quote_expr!(self.cx, {
|
||||
// When `regex!` is bound to a name that is not used, we have to make sure
|
||||
// that dead_code warnings don't bubble up to the user from the generated
|
||||
// code. Therefore, we suppress them by allowing dead_code. The effect is that
|
||||
// the user is only warned about *their* unused variable/code, and not the
|
||||
// unused code generated by regex!. See #14185 for an example.
|
||||
#[allow(dead_code)]
|
||||
static CAP_NAMES: &'static [Option<&'static str>] = &$cap_names;
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
|
||||
start: uint, end: uint) -> Vec<Option<uint>> {
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
use regex::native::{
|
||||
MatchKind, Exists, Location, Submatches,
|
||||
StepState, StepMatchEarlyReturn, StepMatch, StepContinue,
|
||||
|
||||
Reference in New Issue
Block a user