All notable changes to this project will be documented in this file.
## 0.0.70 — TBD
-* [`invalid_regex`] and [`trivial_regex`] can now warn on `RegexSet::new` and
- byte regexes
+* [`invalid_regex`] and [`trivial_regex`] can now warn on `RegexSet::new`,
+ `RegexBuilder::new` and byte regexes
## 0.0.69 — 2016-05-20
* Rustup to *rustc 1.10.0-nightly (476fe6eef 2016-05-21)*
check_regex(cx, &args[0], true);
} else if match_def_path(cx, def_id, &paths::REGEX_BYTES_NEW) {
check_regex(cx, &args[0], false);
+ } else if match_def_path(cx, def_id, &paths::REGEX_BUILDER_NEW) {
+ check_regex(cx, &args[0], true);
+ } else if match_def_path(cx, def_id, &paths::REGEX_BYTES_BUILDER_NEW) {
+ check_regex(cx, &args[0], false);
} else if match_def_path(cx, def_id, &paths::REGEX_SET_NEW) {
check_set(cx, &args[0], true);
} else if match_def_path(cx, def_id, &paths::REGEX_BYTES_SET_NEW) {
pub const RANGE_TO_INCLUSIVE_STD: [&'static str; 3] = ["std", "ops", "RangeToInclusive"];
pub const RANGE_TO_STD: [&'static str; 3] = ["std", "ops", "RangeTo"];
pub const REGEX: [&'static str; 3] = ["regex", "re_unicode", "Regex"];
+pub const REGEX_BUILDER_NEW: [&'static str; 5] = ["regex", "re_builder", "unicode", "RegexBuilder", "new"];
pub const REGEX_BYTES: [&'static str; 3] = ["regex", "re_bytes", "Regex"];
+pub const REGEX_BYTES_BUILDER_NEW: [&'static str; 5] = ["regex", "re_builder", "bytes", "RegexBuilder", "new"];
pub const REGEX_BYTES_NEW: [&'static str; 4] = ["regex", "re_bytes", "Regex", "new"];
pub const REGEX_BYTES_SET_NEW: [&'static str; 5] = ["regex", "re_set", "bytes", "RegexSet", "new"];
pub const REGEX_NEW: [&'static str; 4] = ["regex", "re_unicode", "Regex", "new"];
extern crate regex;
-use regex::{Regex, RegexSet};
-use regex::bytes::{Regex as BRegex, RegexSet as BRegexSet};
+use regex::{Regex, RegexSet, RegexBuilder};
+use regex::bytes::{Regex as BRegex, RegexSet as BRegexSet, RegexBuilder as BRegexBuilder};
const OPENING_PAREN : &'static str = "(";
const NOT_A_REAL_REGEX : &'static str = "foobar";
fn syntax_error() {
let pipe_in_wrong_position = Regex::new("|");
//~^ERROR: regex syntax error: empty alternate
+ let pipe_in_wrong_position_builder = RegexBuilder::new("|");
+ //~^ERROR: regex syntax error: empty alternate
let wrong_char_ranice = Regex::new("[z-a]");
//~^ERROR: regex syntax error: invalid character class range
let some_unicode = Regex::new("[é-è]");
//~^ERROR: regex syntax error: empty alternate
let some_binary_regex = BRegex::new(OPENING_PAREN);
//~^ERROR: regex syntax error on position 0: unclosed
+ let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN);
+ //~^ERROR: regex syntax error on position 0: unclosed
let closing_paren = ")";
let not_linted = Regex::new(closing_paren);
//~^ERROR: trivial regex
//~|HELP consider using `==` on `str`s
+ let trivial_eq_builder = RegexBuilder::new("^foobar$");
+ //~^ERROR: trivial regex
+ //~|HELP consider using `==` on `str`s
+
let trivial_starts_with = Regex::new("^foobar");
//~^ERROR: trivial regex
//~|HELP consider using `str::starts_with`
// non-trivial regexes
let non_trivial_dot = Regex::new("a.b");
+ let non_trivial_dot_builder = RegexBuilder::new("a.b");
let non_trivial_eq = Regex::new("^foo|bar$");
let non_trivial_starts_with = Regex::new("^foo|bar");
let non_trivial_ends_with = Regex::new("^foo|bar");
let non_trivial_ends_with = Regex::new("foo|bar");
let non_trivial_binary = BRegex::new("foo|bar");
+ let non_trivial_binary_builder = BRegexBuilder::new("foo|bar");
}
fn main() {