Skip to content
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

Removed ~str pattern #12756

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 7 additions & 7 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
}

pub fn str_mode(s: ~str) -> mode {
match s {
~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail,
~"run-pass" => mode_run_pass,
~"pretty" => mode_pretty,
~"debug-info" => mode_debug_info,
~"codegen" => mode_codegen,
match s.as_slice() {
"compile-fail" => mode_compile_fail,
"run-fail" => mode_run_fail,
"run-pass" => mode_run_pass,
"pretty" => mode_pretty,
"debug-info" => mode_debug_info,
"codegen" => mode_codegen,
_ => fail!("invalid mode")
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ use test::MetricMap;

pub fn run(config: config, testfile: ~str) {

match config.target {
match config.target.as_slice() {

~"arm-linux-androideabi" => {
"arm-linux-androideabi" => {
if !config.adb_device_status {
fail!("android device not available");
}
Expand Down Expand Up @@ -277,8 +277,8 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
let exe_file = make_exe_name(config, testfile);

let mut proc_args;
match config.target {
~"arm-linux-androideabi" => {
match config.target.as_slice() {
"arm-linux-androideabi" => {

cmds = cmds.replace("run","continue");

Expand Down Expand Up @@ -682,9 +682,9 @@ fn exec_compiled_test(config: &config, props: &TestProps,

let env = props.exec_env.clone();

match config.target {
match config.target.as_slice() {

~"arm-linux-androideabi" => {
"arm-linux-androideabi" => {
_arm_exec_compiled_test(config, props, testfile, env)
}

Expand Down Expand Up @@ -735,9 +735,9 @@ fn compose_and_run_compiler(
&auxres);
}

match config.target {
match config.target.as_slice() {

~"arm-linux-androideabi" => {
"arm-linux-androideabi" => {
_arm_push_aux_shared_library(config, testfile);
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ pub fn build_session_options(matches: &getopts::Matches)
}
};
let gc = debugging_opts & session::GC != 0;

let debuginfo = if matches.opt_present("g") {
if matches.opt_present("debuginfo") {
early_error("-g and --debuginfo both provided");
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Item {
pub fn doc_list<'a>(&'a self) -> Option<&'a [Attribute]> {
for attr in self.attrs.iter() {
match *attr {
List(~"doc", ref list) => { return Some(list.as_slice()); }
List(ref x, ref list) if "doc" == *x => { return Some(list.as_slice()); }
_ => {}
}
}
Expand All @@ -149,7 +149,7 @@ impl Item {
pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
for attr in self.attrs.iter() {
match *attr {
NameValue(~"doc", ref v) => { return Some(v.as_slice()); }
NameValue(ref x, ref v) if "doc" == *x => { return Some(v.as_slice()); }
_ => {}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ impl fmt::Show for clean::Type {
write!(f.buf, "{}{}fn{}{}",
PuritySpace(decl.purity),
match decl.abi {
~"" | ~"\"Rust\"" => ~"",
ref x if "" == *x => ~"",
ref x if "\"Rust\"" == *x => ~"",
ref s => " " + *s + " ",
},
decl.generics,
Expand Down
12 changes: 6 additions & 6 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
Some(attrs) => {
for attr in attrs.iter() {
match *attr {
clean::NameValue(~"html_favicon_url", ref s) => {
clean::NameValue(ref x, ref s) if "html_favicon_url" == *x => {
cx.layout.favicon = s.to_owned();
}
clean::NameValue(~"html_logo_url", ref s) => {
clean::NameValue(ref x, ref s) if "html_logo_url" == *x => {
cx.layout.logo = s.to_owned();
}
clean::Word(~"html_no_source") => {
clean::Word(ref x) if "html_no_source" == *x => {
cx.include_sources = false;
}
_ => {}
Expand Down Expand Up @@ -396,10 +396,10 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
// external crate
for attr in e.attrs.iter() {
match *attr {
clean::List(~"doc", ref list) => {
clean::List(ref x, ref list) if "doc" == *x => {
for attr in list.iter() {
match *attr {
clean::NameValue(~"html_root_url", ref s) => {
clean::NameValue(ref x, ref s) if "html_root_url" == *x => {
if s.ends_with("/") {
return Remote(s.to_owned());
}
Expand Down Expand Up @@ -666,7 +666,7 @@ impl DocFolder for Cache {
// extract relevant documentation for this impl
match attrs.move_iter().find(|a| {
match *a {
clean::NameValue(~"doc", _) => true,
clean::NameValue(ref x, _) if "doc" == *x => true,
_ => false
}
}) {
Expand Down
18 changes: 9 additions & 9 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ pub fn main_args(args: &[~str]) -> int {

info!("going to format");
let started = time::precise_time_ns();
match matches.opt_str("w") {
Some(~"html") | None => {
match matches.opt_str("w").as_ref().map(|s| s.as_slice()) {
Some("html") | None => {
match html::render::run(krate, output.unwrap_or(Path::new("doc"))) {
Ok(()) => {}
Err(e) => fail!("failed to generate documentation: {}", e),
}
}
Some(~"json") => {
Some("json") => {
match json_output(krate, res, output.unwrap_or(Path::new("doc.json"))) {
Ok(()) => {}
Err(e) => fail!("failed to write json: {}", e),
Expand All @@ -223,9 +223,9 @@ pub fn main_args(args: &[~str]) -> int {
/// and files and then generates the necessary rustdoc output for formatting.
fn acquire_input(input: &str,
matches: &getopts::Matches) -> Result<Output, ~str> {
match matches.opt_str("r") {
Some(~"rust") => Ok(rust_input(input, matches)),
Some(~"json") => json_input(input),
match matches.opt_str("r").as_ref().map(|s| s.as_slice()) {
Some("rust") => Ok(rust_input(input, matches)),
Some("json") => json_input(input),
Some(s) => Err("unknown input format: " + s),
None => {
if input.ends_with(".json") {
Expand Down Expand Up @@ -265,15 +265,15 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
Some(nested) => {
for inner in nested.iter() {
match *inner {
clean::Word(~"no_default_passes") => {
clean::Word(ref x) if "no_default_passes" == *x => {
default_passes = false;
}
clean::NameValue(~"passes", ref value) => {
clean::NameValue(ref x, ref value) if "passes" == *x => {
for pass in value.words() {
passes.push(pass.to_owned());
}
}
clean::NameValue(~"plugins", ref value) => {
clean::NameValue(ref x, ref value) if "plugins" == *x => {
for p in value.words() {
plugins.push(p.to_owned());
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
fn fold_item(&mut self, i: Item) -> Option<Item> {
for attr in i.attrs.iter() {
match attr {
&clean::List(~"doc", ref l) => {
&clean::List(ref x, ref l) if "doc" == *x => {
for innerattr in l.iter() {
match innerattr {
&clean::Word(ref s) if "hidden" == *s => {
Expand Down Expand Up @@ -223,7 +223,7 @@ pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
let mut avec: ~[clean::Attribute] = ~[];
for attr in i.attrs.iter() {
match attr {
&clean::NameValue(~"doc", ref s) => avec.push(
&clean::NameValue(ref x, ref s) if "doc" == *x => avec.push(
clean::NameValue(~"doc", unindent(*s))),
x => avec.push(x.clone())
}
Expand All @@ -245,15 +245,15 @@ pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
let mut i = i;
for attr in i.attrs.iter() {
match *attr {
clean::NameValue(~"doc", ref s) => {
clean::NameValue(ref x, ref s) if "doc" == *x => {
docstr.push_str(s.clone());
docstr.push_char('\n');
},
_ => ()
}
}
let mut a: ~[clean::Attribute] = i.attrs.iter().filter(|&a| match a {
&clean::NameValue(~"doc", _) => false,
&clean::NameValue(ref x, _) if "doc" == *x => false,
_ => true
}).map(|x| x.clone()).collect();
if "" != docstr {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ mod tests {
}
});
modify(my_key, |data| {
match data {
Some(~"first data") => Some(~"next data"),
match data.as_ref().map(|s| s.as_slice()) {
Some("first data") => Some(~"next data"),
Some(ref val) => fail!("wrong value: {}", *val),
None => fail!("missing value")
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ fn test_back_to_the_future_result() {
fn test_try_success() {
match try(proc() {
~"Success!"
}) {
result::Ok(~"Success!") => (),
}).as_ref().map(|s| s.as_slice()) {
result::Ok("Success!") => (),
_ => fail!()
}
}
Expand Down
19 changes: 1 addition & 18 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2838,24 +2838,7 @@ impl Parser {
// parse ~pat
self.bump();
let sub = self.parse_pat();
hi = sub.span.hi;
// HACK: parse ~"..." as a literal of a vstore ~str
pat = match sub.node {
PatLit(e) => {
match e.node {
ExprLit(lit) if lit_is_str(lit) => {
let vst = @Expr {
id: ast::DUMMY_NODE_ID,
node: ExprVstore(e, ExprVstoreUniq),
span: mk_sp(lo, hi),
};
PatLit(vst)
}
_ => PatUniq(sub)
}
}
_ => PatUniq(sub)
};
pat = PatUniq(sub);
hi = self.last_span.hi;
return @ast::Pat {
id: ast::DUMMY_NODE_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/test/auxiliary/static-methods-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ impl read for int {

impl read for bool {
fn readMaybe(s: ~str) -> Option<bool> {
match s {
~"true" => Some(true),
~"false" => Some(false),
match s.as_slice() {
"true" => Some(true),
"false" => Some(false),
_ => None
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/match-vec-unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
let x: &[~str] = x;
match x {
[a, _, _, ..] => { println!("{}", a); }
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
[_, _, _, _, _] => { } //~ ERROR unreachable pattern
_ => { }
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/borrowed-ptr-pattern-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

fn foo(s: &~str) -> bool {
match s {
&~"kitty" => true,
match s.as_slice() {
"kitty" => true,
_ => false
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-pass/issue-4541.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fn parse_args() -> ~str {
let mut n = 0;

while n < args.len() {
match args[n].clone() {
~"-v" => (),
match args[n].as_slice() {
"-v" => (),
s => {
return s;
return s.into_owned();
}
}
n += 1;
Expand Down
36 changes: 0 additions & 36 deletions src/test/run-pass/match-drop-strs-issue-4541.rs

This file was deleted.

10 changes: 5 additions & 5 deletions src/test/run-pass/match-str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
// Issue #53

pub fn main() {
match ~"test" { ~"not-test" => fail!(), ~"test" => (), _ => fail!() }
match "test" { "not-test" => fail!(), "test" => (), _ => fail!() }

enum t { tag1(~str), tag2, }


match tag1(~"test") {
tag2 => fail!(),
tag1(~"not-test") => fail!(),
tag1(~"test") => (),
tag1(ref s) if "test" != *s => fail!(),
tag1(ref s) if "test" == *s => (),
_ => fail!()
}

let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail!() };
let x = match "a" { "a" => 1, "b" => 2, _ => fail!() };
assert_eq!(x, 1);

match ~"a" { ~"a" => { } ~"b" => { }, _ => fail!() }
match "a" { "a" => { } "b" => { }, _ => fail!() }

}