diff options
| author | bors <bors@rust-lang.org> | 2015-02-07 02:04:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-07 02:04:47 +0000 |
| commit | 7ebf9bc5c22155d622537ded42b4ebf94238b296 (patch) | |
| tree | b3f937f2f554e961236d3a2048778441ab062c5e /src/libsyntax/parse | |
| parent | d3732a12e896ab98aa27eaffab99a78bbaf837e4 (diff) | |
| parent | a2e01c62d5b6259d55b6688c8b059ac28e5dd03e (diff) | |
| download | rust-7ebf9bc5c22155d622537ded42b4ebf94238b296.tar.gz rust-7ebf9bc5c22155d622537ded42b4ebf94238b296.zip | |
Auto merge of #21505 - GuillaumeGomez:interned_string, r=alexcrichton
It's in order to make the code more homogeneous.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 7 |
3 files changed, 8 insertions, 13 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 694da9b8b28..5f4cf9af5ee 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -1201,19 +1201,19 @@ mod test { let source = "/// doc comment\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); - assert_eq!(doc.get(), "/// doc comment"); + assert_eq!(&doc[], "/// doc comment"); let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap(); - let docs = item.attrs.iter().filter(|a| a.name().get() == "doc") - .map(|a| a.value_str().unwrap().get().to_string()).collect::<Vec<_>>(); + let docs = item.attrs.iter().filter(|a| &a.name()[] == "doc") + .map(|a| a.value_str().unwrap().to_string()).collect::<Vec<_>>(); let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()]; assert_eq!(&docs[], b); let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name, source, Vec::new(), &sess).unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); - assert_eq!(doc.get(), "/** doc comment\n * with CRLF */"); + assert_eq!(&doc[], "/** doc comment\n * with CRLF */"); } #[test] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cae23c5a2cc..3107f47de78 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5133,7 +5133,7 @@ impl<'a> Parser<'a> { outer_attrs, "path") { Some(d) => (dir_path.join(d), true), None => { - let mod_name = mod_string.get().to_string(); + let mod_name = mod_string.to_string(); let default_path_str = format!("{}.rs", mod_name); let secondary_path_str = format!("{}/mod.rs", mod_name); let default_path = dir_path.join(&default_path_str[]); @@ -5145,7 +5145,7 @@ impl<'a> Parser<'a> { self.span_err(id_sp, "cannot declare a new module at this location"); let this_module = match self.mod_path_stack.last() { - Some(name) => name.get().to_string(), + Some(name) => name.to_string(), None => self.root_module_name.as_ref().unwrap().clone(), }; self.span_note(id_sp, @@ -5191,7 +5191,7 @@ impl<'a> Parser<'a> { }; self.eval_src_mod_from_path(file_path, owns_directory, - mod_string.get().to_string(), id_sp) + mod_string.to_string(), id_sp) } fn eval_src_mod_from_path(&mut self, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 129c1d20bc0..45f4f044ea4 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -625,11 +625,6 @@ impl InternedString { string: string, } } - - #[inline] - pub fn get<'a>(&'a self) -> &'a str { - &self.string[] - } } impl Deref for InternedString { @@ -644,7 +639,7 @@ impl BytesContainer for InternedString { // of `BytesContainer`, which is itself a workaround for the lack of // DST. unsafe { - let this = self.get(); + let this = &self[]; mem::transmute::<&[u8],&[u8]>(this.container_as_bytes()) } } |
