about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-03-16 08:50:19 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2019-03-31 03:11:55 +0200
commit438f6b04c6fe2daf7f6000294edd50c26f6da619 (patch)
treefe697b4619ad01961eb6da664adc49f8d7a80155 /src/libsyntax
parentbefeeb7c083c9e5edddc86563cc461185d897a13 (diff)
downloadrust-438f6b04c6fe2daf7f6000294edd50c26f6da619.tar.gz
rust-438f6b04c6fe2daf7f6000294edd50c26f6da619.zip
Fix lifetime on LocalInternedString::get function
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs8
-rw-r--r--src/libsyntax/print/pp.rs11
2 files changed, 12 insertions, 7 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ae8e57d54de..af069b527b0 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2165,9 +2165,11 @@ impl<'a> Parser<'a> {
                     suffix,
                 ) = self.token {
                     let suffix = suffix.and_then(|s| {
-                        let s = s.as_str().get();
-                        if ["f32", "f64"].contains(&s) {
-                            Some(s)
+                        let s = s.as_str();
+                        if s == "f32" {
+                            Some("f32")
+                        } else if s == "f64" {
+                            Some("f64")
                         } else {
                             None
                         }
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index d8a8cbb655b..740ca229030 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -369,7 +369,7 @@ impl<'a> Printer<'a> {
         Ok(())
     }
 
-    fn pretty_print_string(&mut self, s: Cow<'static, str>, len: isize) -> io::Result<()> {
+    fn pretty_print_string<'s>(&mut self, s: Cow<'s, str>, len: isize) -> io::Result<()> {
         if self.scan_stack.is_empty() {
             debug!("pp String('{}')/print Vec<{},{}>",
                    s, self.left, self.right);
@@ -378,7 +378,10 @@ impl<'a> Printer<'a> {
             debug!("pp String('{}')/buffer Vec<{},{}>",
                    s, self.left, self.right);
             self.advance_right();
-            self.buf[self.right] = BufEntry { token: Token::String(s, len), size: len };
+            self.buf[self.right] = BufEntry {
+                token: Token::String(s.into_owned().into(), len),
+                size: len
+            };
             self.right_total += len;
             self.check_stream()
         }
@@ -576,7 +579,7 @@ impl<'a> Printer<'a> {
         }
     }
 
-    pub fn print_string(&mut self, s: Cow<'static, str>, len: isize) -> io::Result<()> {
+    pub fn print_string(&mut self, s: Cow<'_, str>, len: isize) -> io::Result<()> {
         debug!("print String({})", s);
         // assert!(len <= space);
         self.space -= len;
@@ -641,7 +644,7 @@ impl<'a> Printer<'a> {
         self.pretty_print_eof()
     }
 
-    pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S) -> io::Result<()> {
+    pub fn word<'s, S: Into<Cow<'s, str>>>(&mut self, wrd: S) -> io::Result<()> {
         let s = wrd.into();
         let len = s.len() as isize;
         self.pretty_print_string(s, len)