From 763392cb8ca09e0f332c1ab9b75376afbdafc18f Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Wed, 16 Jan 2019 23:05:50 +0900 Subject: Fix memory leak in P::filter_map --- src/libsyntax/ptr.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index bb1744e2df1..3effe53cd29 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -101,6 +101,7 @@ impl P { // Recreate self from the raw pointer. Some(P { ptr: Box::from_raw(p) }) } else { + drop(Box::from_raw(p)); None } } -- cgit 1.4.1-3-g733a5 From 051835b903181ac0a2e549327de9e8d89cf3d457 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Mon, 21 Jan 2019 08:09:56 +0100 Subject: Corrected spelling inconsistency resolves #57773 --- src/librustc/hir/lowering.rs | 4 ++-- src/libsyntax/ast.rs | 8 ++++---- src/libsyntax/fold.rs | 12 ++++++------ src/libsyntax/parse/parser.rs | 4 ++-- src/test/ui/parenthesised-deref-suggestion.rs | 11 ----------- src/test/ui/parenthesised-deref-suggestion.stderr | 21 --------------------- src/test/ui/parenthesized-deref-suggestion.rs | 11 +++++++++++ src/test/ui/parenthesized-deref-suggestion.stderr | 21 +++++++++++++++++++++ 8 files changed, 46 insertions(+), 46 deletions(-) delete mode 100644 src/test/ui/parenthesised-deref-suggestion.rs delete mode 100644 src/test/ui/parenthesised-deref-suggestion.stderr create mode 100644 src/test/ui/parenthesized-deref-suggestion.rs create mode 100644 src/test/ui/parenthesized-deref-suggestion.stderr (limited to 'src/libsyntax') diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f7af135bc76..905a3ceed81 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1931,7 +1931,7 @@ impl<'a> LoweringContext<'a> { fn lower_parenthesized_parameter_data( &mut self, - data: &ParenthesisedArgs, + data: &ParenthesizedArgs, ) -> (hir::GenericArgs, bool) { // Switch to `PassThrough` mode for anonymous lifetimes: this // means that we permit things like `&Ref`, where `Ref` has @@ -1941,7 +1941,7 @@ impl<'a> LoweringContext<'a> { self.with_anonymous_lifetime_mode( AnonymousLifetimeMode::PassThrough, |this| { - let &ParenthesisedArgs { ref inputs, ref output, span } = data; + let &ParenthesizedArgs { ref inputs, ref output, span } = data; let inputs = inputs .iter() .map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed())) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 405cf612543..798f14dcba9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -136,7 +136,7 @@ pub enum GenericArgs { /// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>` AngleBracketed(AngleBracketedArgs), /// The `(A,B)` and `C` in `Foo(A,B) -> C` - Parenthesized(ParenthesisedArgs), + Parenthesized(ParenthesizedArgs), } impl GenericArgs { @@ -173,7 +173,7 @@ impl Into>> for AngleBracketedArgs { } } -impl Into>> for ParenthesisedArgs { +impl Into>> for ParenthesizedArgs { fn into(self) -> Option> { Some(P(GenericArgs::Parenthesized(self))) } @@ -181,7 +181,7 @@ impl Into>> for ParenthesisedArgs { /// A path like `Foo(A,B) -> C` #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct ParenthesisedArgs { +pub struct ParenthesizedArgs { /// Overall span pub span: Span, @@ -192,7 +192,7 @@ pub struct ParenthesisedArgs { pub output: Option>, } -impl ParenthesisedArgs { +impl ParenthesizedArgs { pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs { AngleBracketedArgs { span: self.span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index a4c3b38f691..fdcbbb939a6 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -207,8 +207,8 @@ pub trait Folder : Sized { noop_fold_angle_bracketed_parameter_data(p, self) } - fn fold_parenthesized_parameter_data(&mut self, p: ParenthesisedArgs) - -> ParenthesisedArgs + fn fold_parenthesized_parameter_data(&mut self, p: ParenthesizedArgs) + -> ParenthesizedArgs { noop_fold_parenthesized_parameter_data(p, self) } @@ -504,12 +504,12 @@ pub fn noop_fold_angle_bracketed_parameter_data(data: AngleBracketedA } } -pub fn noop_fold_parenthesized_parameter_data(data: ParenthesisedArgs, +pub fn noop_fold_parenthesized_parameter_data(data: ParenthesizedArgs, fld: &mut T) - -> ParenthesisedArgs + -> ParenthesizedArgs { - let ParenthesisedArgs { inputs, output, span } = data; - ParenthesisedArgs { + let ParenthesizedArgs { inputs, output, span } = data; + ParenthesizedArgs { inputs: inputs.move_map(|ty| fld.fold_ty(ty)), output: output.map(|ty| fld.fold_ty(ty)), span: fld.new_span(span) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 439eec5b0c4..09ea0995253 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,5 +1,5 @@ use rustc_target::spec::abi::{self, Abi}; -use ast::{AngleBracketedArgs, ParenthesisedArgs, AttrStyle, BareFnTy}; +use ast::{AngleBracketedArgs, ParenthesizedArgs, AttrStyle, BareFnTy}; use ast::{GenericBound, TraitBoundModifier}; use ast::Unsafety; use ast::{Mod, AnonConst, Arg, Arm, Guard, Attribute, BindingMode, TraitItemKind}; @@ -2203,7 +2203,7 @@ impl<'a> Parser<'a> { } else { None }; - ParenthesisedArgs { inputs, output, span }.into() + ParenthesizedArgs { inputs, output, span }.into() }; PathSegment { ident, args, id: ast::DUMMY_NODE_ID } diff --git a/src/test/ui/parenthesised-deref-suggestion.rs b/src/test/ui/parenthesised-deref-suggestion.rs deleted file mode 100644 index 0b4ccdd5a56..00000000000 --- a/src/test/ui/parenthesised-deref-suggestion.rs +++ /dev/null @@ -1,11 +0,0 @@ -struct Session { - opts: u8, -} - -fn main() { - let sess: &Session = &Session { opts: 0 }; - (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` - - let x = [0u32]; - (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` -} diff --git a/src/test/ui/parenthesised-deref-suggestion.stderr b/src/test/ui/parenthesised-deref-suggestion.stderr deleted file mode 100644 index 71a2bf67f06..00000000000 --- a/src/test/ui/parenthesised-deref-suggestion.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0609]: no field `opts` on type `*const Session` - --> $DIR/parenthesised-deref-suggestion.rs:7:30 - | -LL | (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` - | ^^^^ -help: `(sess as *const Session)` is a raw pointer; try dereferencing it - | -LL | (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*const Session` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0609]: no field `0` on type `[u32; 1]` - --> $DIR/parenthesised-deref-suggestion.rs:10:21 - | -LL | (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` - | ----------------^ - | | - | help: instead of using tuple indexing, use array indexing: `(x as [u32; 1])[0]` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/parenthesized-deref-suggestion.rs b/src/test/ui/parenthesized-deref-suggestion.rs new file mode 100644 index 00000000000..0b4ccdd5a56 --- /dev/null +++ b/src/test/ui/parenthesized-deref-suggestion.rs @@ -0,0 +1,11 @@ +struct Session { + opts: u8, +} + +fn main() { + let sess: &Session = &Session { opts: 0 }; + (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` + + let x = [0u32]; + (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` +} diff --git a/src/test/ui/parenthesized-deref-suggestion.stderr b/src/test/ui/parenthesized-deref-suggestion.stderr new file mode 100644 index 00000000000..fd9b0e8216b --- /dev/null +++ b/src/test/ui/parenthesized-deref-suggestion.stderr @@ -0,0 +1,21 @@ +error[E0609]: no field `opts` on type `*const Session` + --> $DIR/parenthesized-deref-suggestion.rs:7:30 + | +LL | (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` + | ^^^^ +help: `(sess as *const Session)` is a raw pointer; try dereferencing it + | +LL | (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*const Session` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0609]: no field `0` on type `[u32; 1]` + --> $DIR/parenthesized-deref-suggestion.rs:10:21 + | +LL | (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` + | ----------------^ + | | + | help: instead of using tuple indexing, use array indexing: `(x as [u32; 1])[0]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. -- cgit 1.4.1-3-g733a5