From de2ecea3592c81eae5c0ce4e3d26729f7d552c34 Mon Sep 17 00:00:00 2001 From: CrLF0710 Date: Sun, 1 Jul 2018 16:51:44 +0800 Subject: [PATCH 01/19] Provide llvm-strip in llvm-tools component Shipping this tool gives people reliable way to reduce the generated executable size. I'm not sure if this strip tool is available from the llvm version current rust is built on. But let's take a look. @japaric --- src/bootstrap/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b5d450b88392..148f22bd0a5b 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -204,7 +204,8 @@ const LLVM_TOOLS: &[&str] = &[ "llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume "llvm-objdump", // used to disassemble programs "llvm-profdata", // used to inspect and merge files generated by profiles - "llvm-size", // prints the size of the linker sections of a program + "llvm-size", // used to prints the size of the linker sections of a program + "llvm-strip", // used to discard symbols from binary files to reduce their size ]; /// A structure representing a Rust compiler. From 603553458639cd65f3cc75b9b74f8176af81aa2b Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 4 Jul 2018 21:54:45 +0200 Subject: [PATCH 02/19] Implement `Option::replace` in the core library --- src/libcore/option.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 20bc173f7e15..db0a807d152a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -845,6 +845,33 @@ impl Option { pub fn take(&mut self) -> Option { mem::replace(self, None) } + + /// Replaces the actual value in the option by the value given in parameter, + /// returning the old value if present, + /// leaving a `Some` in its place without deinitializing either one. + /// + /// [`Some`]: #variant.Some + /// + /// # Examples + /// + /// ``` + /// #![feature(option_replace)] + /// + /// let mut x = Some(2); + /// let old = x.replace(5); + /// assert_eq!(x, Some(5)); + /// assert_eq!(old, Some(2)); + /// + /// let mut x = None; + /// let old = x.replace(3); + /// assert_eq!(x, Some(3)); + /// assert_eq!(old, None); + /// ``` + #[inline] + #[unstable(feature = "option_replace", issue = "51998")] + pub fn replace(&mut self, value: T) -> Option { + mem::replace(self, Some(value)) + } } impl<'a, T: Clone> Option<&'a T> { From 2c2add6e0259efd9b375c849d1bde187972b65b3 Mon Sep 17 00:00:00 2001 From: Kevin Zajler Date: Sun, 8 Jul 2018 18:07:17 +0200 Subject: [PATCH 03/19] Update std::ascii::ASCIIExt deprecation notes --- src/libstd/ascii.rs | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 6472edb0aa7d..376410677346 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -163,7 +163,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_alphabetic)`. + /// For `str` use `.bytes().all(u8::is_ascii_alphabetic)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_alphabetic(&self) -> bool { unimplemented!(); } @@ -176,7 +178,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_uppercase)`. + /// For `str` use `.bytes().all(u8::is_ascii_uppercase)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_uppercase(&self) -> bool { unimplemented!(); } @@ -189,7 +193,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_lowercase)`. + /// For `str` use `.bytes().all(u8::is_ascii_lowercase)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_lowercase(&self) -> bool { unimplemented!(); } @@ -203,7 +209,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_alphanumeric)`. + /// For `str` use `.bytes().all(u8::is_ascii_alphanumeric)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_alphanumeric(&self) -> bool { unimplemented!(); } @@ -216,7 +224,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_digit)`. + /// For `str` use `.bytes().all(u8::is_ascii_digit)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_digit(&self) -> bool { unimplemented!(); } @@ -230,7 +240,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_hexdigit)`. + /// For `str` use `.bytes().all(u8::is_ascii_hexdigit)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_hexdigit(&self) -> bool { unimplemented!(); } @@ -248,7 +260,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_punctuation)`. + /// For `str` use `.bytes().all(u8::is_ascii_punctuation)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_punctuation(&self) -> bool { unimplemented!(); } @@ -261,7 +275,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_graphic)`. + /// For `str` use `.bytes().all(u8::is_ascii_graphic)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_graphic(&self) -> bool { unimplemented!(); } @@ -291,7 +307,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_whitespace)`. + /// For `str` use `.bytes().all(u8::is_ascii_whitespace)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_whitespace(&self) -> bool { unimplemented!(); } @@ -304,7 +322,9 @@ pub trait AsciiExt { /// # Note /// /// This method will be deprecated in favor of the identically-named - /// inherent methods on `u8`, `char`, `[u8]` and `str`. + /// inherent methods on `u8` and `char`. + /// For `[u8]` use `.iter().all(u8::is_ascii_control)`. + /// For `str` use `.bytes().all(u8::is_ascii_control)`. #[unstable(feature = "ascii_ctype", issue = "39658")] #[rustc_deprecated(since = "1.26.0", reason = "use inherent methods instead")] fn is_ascii_control(&self) -> bool { unimplemented!(); } From af87a3594a9f852de0eb7fec7a2f2e7c5fdb4fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20RENAULT?= Date: Mon, 9 Jul 2018 14:50:54 +0200 Subject: [PATCH 04/19] Add a basic test to `Option::replace` --- src/libcore/tests/lib.rs | 1 + src/libcore/tests/option.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 9d4a5213992a..ca7db6e4639a 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -44,6 +44,7 @@ #![feature(reverse_bits)] #![feature(iterator_find_map)] #![feature(slice_internals)] +#![feature(option_replace)] extern crate core; extern crate test; diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index 22109e28edd9..bc3e61a4f541 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -297,3 +297,18 @@ fn test_try() { } assert_eq!(try_option_err(), Err(NoneError)); } + +#[test] +fn test_replace() { + let mut x = Some(2); + let old = x.replace(5); + + assert_eq!(x, Some(5)); + assert_eq!(old, Some(2)); + + let mut x = None; + let old = x.replace(3); + + assert_eq!(x, Some(3)); + assert_eq!(old, None); +} From c8f0e6f210caccdaea7dc59fd970c81018ddfb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20RENAULT?= Date: Mon, 9 Jul 2018 14:52:32 +0200 Subject: [PATCH 05/19] Fix the documentation of `Option::replace` --- src/libcore/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index db0a807d152a..f3e823670aaa 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -848,7 +848,7 @@ impl Option { /// Replaces the actual value in the option by the value given in parameter, /// returning the old value if present, - /// leaving a `Some` in its place without deinitializing either one. + /// leaving a [`Some`] in its place without deinitializing either one. /// /// [`Some`]: #variant.Some /// From f45d5eb4f00424344682d745c8f30ccacf213209 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 11 Jul 2018 20:03:34 -0500 Subject: [PATCH 06/19] llvm-tools-preview: fix build-manifest --- src/tools/build-manifest/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index c2f0687a5a99..bb20678d4a11 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -492,7 +492,7 @@ impl Builder { format!("clippy-{}-{}.tar.gz", self.clippy_release, target) } else if component == "rustfmt" || component == "rustfmt-preview" { format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target) - } else if component == "llvm_tools" { + } else if component == "llvm-tools" || component == "llvm-tools-preview" { format!("llvm-tools-{}-{}.tar.gz", self.llvm_tools_release, target) } else { format!("{}-{}-{}.tar.gz", component, self.rust_release, target) From 0d7b2e6e28dbaada91aac03964b345036894967a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 10:26:22 +0200 Subject: [PATCH 07/19] Deny bare trait objects in src/librustc_save_analysis --- src/librustc_save_analysis/json_dumper.rs | 4 ++-- src/librustc_save_analysis/lib.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 1b09df16a7d1..2fe7d73de8aa 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -46,7 +46,7 @@ impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> { } pub struct CallbackOutput<'b> { - callback: &'b mut FnMut(&Analysis), + callback: &'b mut dyn FnMut(&Analysis), } impl<'b> DumpOutput for CallbackOutput<'b> { @@ -67,7 +67,7 @@ impl<'b, W: Write> JsonDumper> { impl<'b> JsonDumper> { pub fn with_callback( - callback: &'b mut FnMut(&Analysis), + callback: &'b mut dyn FnMut(&Analysis), config: Config, ) -> JsonDumper> { JsonDumper { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 447b5f1fe47e..055fbb236d8f 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -13,6 +13,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] #![allow(unused_attributes)] +#![deny(bare_trait_objects)] #![recursion_limit="256"] @@ -1088,7 +1089,7 @@ impl<'a> SaveHandler for DumpHandler<'a> { /// Call a callback with the results of save-analysis. pub struct CallbackHandler<'b> { - pub callback: &'b mut FnMut(&rls_data::Analysis), + pub callback: &'b mut dyn FnMut(&rls_data::Analysis), } impl<'b> SaveHandler for CallbackHandler<'b> { From f29ac5a680f57851f68ad2584972e605402156a9 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 10:57:04 +0200 Subject: [PATCH 08/19] Deny bare trait objects in librustc_typeck --- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/closure.rs | 4 ++-- src/librustc_typeck/check/coercion.rs | 4 ++-- src/librustc_typeck/check/writeback.rs | 6 +++--- src/librustc_typeck/coherence/builtin.rs | 2 +- src/librustc_typeck/collect.rs | 6 +++--- src/librustc_typeck/diagnostics.rs | 4 ++-- src/librustc_typeck/lib.rs | 1 + 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2e467d315bed..5e38c0bbcb4a 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -98,7 +98,7 @@ struct ParamRange { /// This type must not appear anywhere in other converted types. const TRAIT_OBJECT_DUMMY_SELF: ty::TypeVariants<'static> = ty::TyInfer(ty::FreshTy(0)); -impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { +impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { pub fn ast_region_to_region(&self, lifetime: &hir::Lifetime, def: Option<&ty::GenericParamDef>) diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index cfe9e420c5fe..f2745d06390e 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -604,7 +604,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// If there is no expected signature, then we will convert the /// types that the user gave into a signature. fn supplied_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> { - let astconv: &AstConv = self; + let astconv: &dyn AstConv = self; // First, convert the types that the user supplied (if any). let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a)); @@ -630,7 +630,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// so should yield an error, but returns back a signature where /// all parameters are of type `TyErr`. fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> { - let astconv: &AstConv = self; + let astconv: &dyn AstConv = self; let supplied_arguments = decl.inputs.iter().map(|a| { // Convert the types that the user supplied (if any), but ignore them. diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index e276dcff0601..e3b0b8cccf31 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1071,7 +1071,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> pub fn coerce_forced_unit<'a>(&mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, cause: &ObligationCause<'tcx>, - augment_error: &mut FnMut(&mut DiagnosticBuilder), + augment_error: &mut dyn FnMut(&mut DiagnosticBuilder), label_unit_as_expected: bool) { self.coerce_inner(fcx, @@ -1090,7 +1090,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> cause: &ObligationCause<'tcx>, expression: Option<&'gcx hir::Expr>, mut expression_ty: Ty<'tcx>, - augment_error: Option<&mut FnMut(&mut DiagnosticBuilder)>, + augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder)>, label_expression_as_expected: bool) { // Incorporate whatever type inference information we have diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 2445cae98607..b7233217d5f3 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -526,7 +526,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } } - fn resolve(&self, x: &T, span: &Locatable) -> T::Lifted + fn resolve(&self, x: &T, span: &dyn Locatable) -> T::Lifted where T: TypeFoldable<'tcx> + ty::Lift<'gcx>, { @@ -580,14 +580,14 @@ impl Locatable for hir::HirId { struct Resolver<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { tcx: TyCtxt<'cx, 'gcx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - span: &'cx Locatable, + span: &'cx dyn Locatable, body: &'gcx hir::Body, } impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> { fn new( fcx: &'cx FnCtxt<'cx, 'gcx, 'tcx>, - span: &'cx Locatable, + span: &'cx dyn Locatable, body: &'gcx hir::Body, ) -> Resolver<'cx, 'gcx, 'tcx> { Resolver { diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index dde136802606..393904583ca4 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -212,7 +212,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, let cause = ObligationCause::misc(span, impl_node_id); let check_mutbl = |mt_a: ty::TypeAndMut<'gcx>, mt_b: ty::TypeAndMut<'gcx>, - mk_ptr: &Fn(Ty<'gcx>) -> Ty<'gcx>| { + mk_ptr: &dyn Fn(Ty<'gcx>) -> Ty<'gcx>| { if (mt_a.mutbl, mt_b.mutbl) == (hir::MutImmutable, hir::MutMutable) { infcx.report_mismatched_types(&cause, mk_ptr(mt_b.ty), diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index fa2f9885964d..5fa98e3ebe69 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1244,7 +1244,7 @@ fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } // Is it marked with ?Sized -fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>, +fn is_unsized<'gcx: 'tcx, 'tcx>(astconv: &dyn AstConv<'gcx, 'tcx>, ast_bounds: &[hir::GenericBound], span: Span) -> bool { @@ -1598,7 +1598,7 @@ pub enum SizedByDefault { Yes, No, } /// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or /// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the /// built-in trait (formerly known as kind): Send. -pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>, +pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &dyn AstConv<'gcx, 'tcx>, param_ty: Ty<'tcx>, ast_bounds: &[hir::GenericBound], sized_by_default: SizedByDefault, @@ -1646,7 +1646,7 @@ pub fn compute_bounds<'gcx: 'tcx, 'tcx>(astconv: &AstConv<'gcx, 'tcx>, /// because this can be anywhere from 0 predicates (`T:?Sized` adds no /// predicates) to 1 (`T:Foo`) to many (`T:Bar` adds `T:Bar` /// and `::X == i32`). -fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>, +fn predicates_from_bound<'tcx>(astconv: &dyn AstConv<'tcx, 'tcx>, param_ty: Ty<'tcx>, bound: &hir::GenericBound) -> Vec> diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index dd09bf96da59..4d957c9aa452 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2338,7 +2338,7 @@ Rust does not currently support this. A simple example that causes this error: ```compile_fail,E0225 fn main() { - let _: Box; + let _: Box; } ``` @@ -2348,7 +2348,7 @@ auto traits. For example, the following compiles correctly: ``` fn main() { - let _: Box; + let _: Box; } ``` "##, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index b18e5ca54ff4..b50f55effad4 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -70,6 +70,7 @@ This API is completely unstable and subject to change. html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(non_camel_case_types)] +#![deny(bare_trait_objects)] #![feature(box_patterns)] #![feature(box_syntax)] From 0878453119ebced0182128f5661bdc3722279fae Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 12:49:29 +0200 Subject: [PATCH 09/19] Deny bare trait objects in src/libserialize --- src/libserialize/json.rs | 16 ++++++++-------- src/libserialize/lib.rs | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 9959d5ce40d2..88cc93731131 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -371,7 +371,7 @@ impl From for EncoderError { pub type EncodeResult = Result<(), EncoderError>; pub type DecodeResult = Result; -fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult { +fn escape_str(wr: &mut dyn fmt::Write, v: &str) -> EncodeResult { wr.write_str("\"")?; let mut start = 0; @@ -433,11 +433,11 @@ fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult { Ok(()) } -fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult { +fn escape_char(writer: &mut dyn fmt::Write, v: char) -> EncodeResult { escape_str(writer, v.encode_utf8(&mut [0; 4])) } -fn spaces(wr: &mut fmt::Write, mut n: usize) -> EncodeResult { +fn spaces(wr: &mut dyn fmt::Write, mut n: usize) -> EncodeResult { const BUF: &'static str = " "; while n >= BUF.len() { @@ -461,14 +461,14 @@ fn fmt_number_or_null(v: f64) -> string::String { /// A structure for implementing serialization to JSON. pub struct Encoder<'a> { - writer: &'a mut (fmt::Write+'a), + writer: &'a mut (dyn fmt::Write+'a), is_emitting_map_key: bool, } impl<'a> Encoder<'a> { /// Creates a new JSON encoder whose output will be written to the writer /// specified. - pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> { + pub fn new(writer: &'a mut dyn fmt::Write) -> Encoder<'a> { Encoder { writer: writer, is_emitting_map_key: false, } } } @@ -707,7 +707,7 @@ impl<'a> ::Encoder for Encoder<'a> { /// Another encoder for JSON, but prints out human-readable JSON instead of /// compact data pub struct PrettyEncoder<'a> { - writer: &'a mut (fmt::Write+'a), + writer: &'a mut (dyn fmt::Write+'a), curr_indent: usize, indent: usize, is_emitting_map_key: bool, @@ -715,7 +715,7 @@ pub struct PrettyEncoder<'a> { impl<'a> PrettyEncoder<'a> { /// Creates a new encoder whose output will be written to the specified writer - pub fn new(writer: &'a mut fmt::Write) -> PrettyEncoder<'a> { + pub fn new(writer: &'a mut dyn fmt::Write) -> PrettyEncoder<'a> { PrettyEncoder { writer, curr_indent: 0, @@ -2053,7 +2053,7 @@ impl> Builder { } /// Decodes a json value from an `&mut io::Read` -pub fn from_reader(rdr: &mut Read) -> Result { +pub fn from_reader(rdr: &mut dyn Read) -> Result { let mut contents = Vec::new(); match rdr.read_to_end(&mut contents) { Ok(c) => c, diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index a5f4b32b329e..7c1bb69434d5 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -14,6 +14,8 @@ Core encoding and decoding interfaces. */ +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", From 21d9ac1d04cd59044fa96a3064dd0b56c648655a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 13:26:29 +0200 Subject: [PATCH 10/19] Deny bare trait objects in librustc_target and libtest --- src/librustc_target/lib.rs | 2 ++ src/librustc_target/spec/mod.rs | 2 +- src/libtest/lib.rs | 15 +++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 8f4911574398..e611d26da56d 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -21,6 +21,8 @@ //! one that doesn't; the one that doesn't might get decent parallel //! build speedups. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 19e353c6a942..484563aa3024 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -229,7 +229,7 @@ macro_rules! supported_targets { } } - pub fn get_targets() -> Box> { + pub fn get_targets() -> Box> { Box::new(TARGETS.iter().filter_map(|t| -> Option { load_specific(t) .and(Ok(t.to_string())) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index a4d1797c3ec5..6b547dff9120 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -26,6 +26,9 @@ // NB: this is also specified in this crate's Cargo.toml, but libsyntax contains logic specific to // this crate, which relies on this attribute (rather than the value of `--crate-name` passed by // cargo) to detect this crate. + +#![deny(bare_trait_objects)] + #![crate_name = "test"] #![unstable(feature = "test", issue = "27812")] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -165,8 +168,8 @@ pub trait TDynBenchFn: Send { pub enum TestFn { StaticTestFn(fn()), StaticBenchFn(fn(&mut Bencher)), - DynTestFn(Box), - DynBenchFn(Box), + DynTestFn(Box), + DynBenchFn(Box), } impl TestFn { @@ -840,7 +843,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu fn callback( event: &TestEvent, st: &mut ConsoleTestState, - out: &mut OutputFormatter, + out: &mut dyn OutputFormatter, ) -> io::Result<()> { match (*event).clone() { TeFiltered(ref filtered_tests) => { @@ -897,7 +900,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu let is_multithreaded = opts.test_threads.unwrap_or_else(get_concurrency) > 1; - let mut out: Box = match opts.format { + let mut out: Box = match opts.format { OutputFormat::Pretty => Box::new(PrettyFormatter::new( output, use_color(opts), @@ -1386,7 +1389,7 @@ pub fn run_test( desc: TestDesc, monitor_ch: Sender, nocapture: bool, - testfn: Box, + testfn: Box, ) { // Buffer for capturing standard I/O let data = Arc::new(Mutex::new(Vec::new())); @@ -1459,7 +1462,7 @@ fn __rust_begin_short_backtrace(f: F) { f() } -fn calc_result(desc: &TestDesc, task_result: Result<(), Box>) -> TestResult { +fn calc_result(desc: &TestDesc, task_result: Result<(), Box>) -> TestResult { match (&desc.should_panic, task_result) { (&ShouldPanic::No, Ok(())) | (&ShouldPanic::Yes, Err(_)) => TrOk, (&ShouldPanic::YesWithMessage(msg), Err(ref err)) => { From 5058af70039d4cf417f6cc94617da7b5d647182a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 13:50:22 +0200 Subject: [PATCH 11/19] Deny bare trait objects in the rest of rust --- src/build_helper/lib.rs | 2 ++ src/liballoc_jemalloc/lib.rs | 1 + src/liballoc_system/lib.rs | 1 + src/libarena/lib.rs | 1 + src/libfmt_macros/lib.rs | 2 ++ src/libgraphviz/lib.rs | 2 ++ src/libpanic_abort/lib.rs | 1 + src/libproc_macro/lib.rs | 1 + src/libprofiler_builtins/lib.rs | 1 + src/librustc_apfloat/lib.rs | 2 ++ src/librustc_asan/lib.rs | 2 ++ src/librustc_borrowck/lib.rs | 1 + src/librustc_incremental/lib.rs | 2 ++ src/librustc_lint/lib.rs | 2 ++ src/librustc_llvm/lib.rs | 1 + src/librustc_lsan/lib.rs | 2 ++ src/librustc_mir/lib.rs | 2 ++ src/librustc_msan/lib.rs | 2 ++ src/librustc_passes/lib.rs | 2 ++ src/librustc_platform_intrinsics/lib.rs | 1 + src/librustc_plugin/lib.rs | 2 ++ src/librustc_privacy/lib.rs | 2 ++ src/librustc_traits/lib.rs | 2 ++ src/librustc_tsan/lib.rs | 2 ++ src/libsyntax_pos/lib.rs | 2 ++ src/libunwind/lib.rs | 2 ++ 26 files changed, 43 insertions(+) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 2f9953330f42..4d767f096897 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + use std::fs::File; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index b3b20715511a..413b212281b7 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -10,6 +10,7 @@ #![no_std] #![allow(unused_attributes)] +#![deny(bare_trait_objects)] #![unstable(feature = "alloc_jemalloc", reason = "implementation detail of std, does not provide any public API", issue = "0")] diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 64348e05de7d..c6c0abefbab2 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -10,6 +10,7 @@ #![no_std] #![allow(unused_attributes)] +#![deny(bare_trait_objects)] #![unstable(feature = "alloc_system", reason = "this library is unlikely to be stabilized in its current \ form or name", diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 0f4a5d16e175..6f692923c853 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -30,6 +30,7 @@ #![cfg_attr(test, feature(test))] #![allow(deprecated)] +#![deny(bare_trait_objects)] extern crate alloc; extern crate rustc_data_structures; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index a77751d65d08..51c3efb41ad9 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -14,6 +14,8 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 158d01015158..9e71ed4063e8 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -283,6 +283,8 @@ //! //! * [DOT language](http://www.graphviz.org/doc/info/lang.html) +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 392bf17968fb..02ab28507d7d 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -21,6 +21,7 @@ issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![panic_runtime] #![allow(unused_features)] +#![deny(bare_trait_objects)] #![feature(core_intrinsics)] #![feature(libc)] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 876cf295acc1..7c0cf9eaddeb 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -22,6 +22,7 @@ //! See [the book](../book/first-edition/procedural-macros.html) for more. #![stable(feature = "proc_macro_lib", since = "1.15.0")] +#![deny(bare_trait_objects)] #![deny(missing_docs)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs index 6d0d6d115b71..3d91505cd772 100644 --- a/src/libprofiler_builtins/lib.rs +++ b/src/libprofiler_builtins/lib.rs @@ -15,4 +15,5 @@ reason = "internal implementation detail of rustc right now", issue = "0")] #![allow(unused_features)] +#![deny(bare_trait_objects)] #![feature(staged_api)] diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 08438805a703..c7cd958016dc 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -40,6 +40,8 @@ //! //! This API is completely unstable and subject to change. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs index 0c78fd74a234..7bd1e98f85dc 100644 --- a/src/librustc_asan/lib.rs +++ b/src/librustc_asan/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![sanitizer_runtime] #![feature(alloc_system)] #![feature(sanitizer_runtime)] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index a5a20af0e4e4..d583a32c4319 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -13,6 +13,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![allow(non_camel_case_types)] +#![deny(bare_trait_objects)] #![feature(from_ref)] #![feature(quote)] diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 3839c133a6eb..2ef88041d338 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -10,6 +10,8 @@ //! Support for serializing the dep-graph and reloading it. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 359b056b5a2d..9f8ef6ef4324 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -19,6 +19,8 @@ //! //! This API is completely unstable and subject to change. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 741758cb954b..c60016cde0d1 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -12,6 +12,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] +#![deny(bare_trait_objects)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs index 0c78fd74a234..7bd1e98f85dc 100644 --- a/src/librustc_lsan/lib.rs +++ b/src/librustc_lsan/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![sanitizer_runtime] #![feature(alloc_system)] #![feature(sanitizer_runtime)] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index dc0d0b244633..c042c68d40bc 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -14,6 +14,8 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ +#![deny(bare_trait_objects)] + #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] #![feature(from_ref)] diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs index 0c78fd74a234..7bd1e98f85dc 100644 --- a/src/librustc_msan/lib.rs +++ b/src/librustc_msan/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![sanitizer_runtime] #![feature(alloc_system)] #![feature(sanitizer_runtime)] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 41f1e7829658..15d7c0fdaa33 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -14,6 +14,8 @@ //! //! This API is completely unstable and subject to change. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index b57debdd9948..92e83fd70fa3 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -9,6 +9,7 @@ // except according to those terms. #![allow(bad_style)] +#![deny(bare_trait_objects)] pub struct Intrinsic { pub inputs: &'static [&'static Type], diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 348aa6a7cef4..b2c492f204f3 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -60,6 +60,8 @@ //! See the [`plugin` feature](../unstable-book/language-features/plugin.html) of //! the Unstable Book for more examples. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 3919ba13076f..f69e664ea46b 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index 1da3907915a0..cd55b5ddc5bf 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -11,6 +11,8 @@ //! New recursive solver modeled on Chalk's recursive solver. Most of //! the guts are broken up into modules; see the comments in those modules. +#![deny(bare_trait_objects)] + #![feature(crate_in_paths)] #![feature(crate_visibility_modifier)] #![feature(extern_prelude)] diff --git a/src/librustc_tsan/lib.rs b/src/librustc_tsan/lib.rs index 0c78fd74a234..7bd1e98f85dc 100644 --- a/src/librustc_tsan/lib.rs +++ b/src/librustc_tsan/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![sanitizer_runtime] #![feature(alloc_system)] #![feature(sanitizer_runtime)] diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 61af70af47d8..cc09a944e4cc 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -14,6 +14,8 @@ //! //! This API is completely unstable and subject to change. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 2b3c19c067ed..ea5eee3cc7d4 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(bare_trait_objects)] + #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] From 4c340a28adf4ecd48e17da9fc3d1d73f696bf0c6 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 12 Jul 2018 09:23:00 -0600 Subject: [PATCH 12/19] Backport 1.27.1 release notes to master --- RELEASES.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index cf80c166759b..503ce7ede0d7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -140,6 +140,29 @@ Compatibility Notes [`{Any + Send + Sync}::downcast_ref`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref-2 [`{Any + Send + Sync}::is`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.is-2 +Version 1.27.1 (2018-07-10) +=========================== + +Security Notes +-------------- + +- rustdoc would execute plugins in the /tmp/rustdoc/plugins directory + when running, which enabled executing code as some other user on a + given machine. This release fixes that vulnerability; you can read + more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622]. + + Thank you to Red Hat for responsibily disclosing this vulnerability to us. + +Compatibility Notes +------------------- + +- The borrow checker was fixed to avoid an additional potential unsoundness when using + match ergonomics: [#51415][51415], [#49534][49534]. + +[51415]: https://github.com/rust-lang/rust/issues/51415 +[49534]: https://github.com/rust-lang/rust/issues/49534 +[rustdoc-sec]: https://blog.rust-lang.org/2018/07/06/security-advisory-for-rustdoc.html +[CVE-2018-1000622]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=%20CVE-2018-1000622 Version 1.27.0 (2018-06-21) ========================== From 72f096b6288f00d14a47d7fc1dff7c4939ad2e2a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 18:59:56 +0200 Subject: [PATCH 13/19] Resolve FIXME(#27942) --- src/librustc/infer/error_reporting/mod.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 1377176bc7fb..c1849c63a7df 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -193,32 +193,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let scope = region.free_region_binding_scope(self); let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); - let unknown; let tag = match self.hir.find(node) { Some(hir_map::NodeBlock(_)) | Some(hir_map::NodeExpr(_)) => "body", Some(hir_map::NodeItem(it)) => Self::item_scope_tag(&it), Some(hir_map::NodeTraitItem(it)) => Self::trait_item_scope_tag(&it), Some(hir_map::NodeImplItem(it)) => Self::impl_item_scope_tag(&it), - - // this really should not happen, but it does: - // FIXME(#27942) - Some(_) => { - unknown = format!( - "unexpected node ({}) for scope {:?}. \ - Please report a bug.", - self.hir.node_to_string(node), - scope - ); - &unknown - } - None => { - unknown = format!( - "unknown node for scope {:?}. \ - Please report a bug.", - scope - ); - &unknown - } + _ => unreachable!() }; let (prefix, span) = match *region { ty::ReEarlyBound(ref br) => { From 9ead0d82e119a2281ad38ab80562c0f22af57a8b Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 12 Jul 2018 12:32:35 -0700 Subject: [PATCH 14/19] Update llvm-rebuild-trigger in light of LLVM 7 upgrade --- src/rustllvm/llvm-rebuild-trigger | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustllvm/llvm-rebuild-trigger b/src/rustllvm/llvm-rebuild-trigger index 5a0292bb6a16..1722211c9e89 100644 --- a/src/rustllvm/llvm-rebuild-trigger +++ b/src/rustllvm/llvm-rebuild-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be (optionally) cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2018-05-18 \ No newline at end of file +2018-07-12 \ No newline at end of file From 4f4e91a69d75b5de66d53399027cc1835387a423 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 12 Jul 2018 15:43:57 -0700 Subject: [PATCH 15/19] task: remove wrong comments about non-existent LocalWake trait --- src/libcore/task/wake.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 418d5af006f7..d3df8b50ee2e 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -113,8 +113,8 @@ impl LocalWaker { /// but you otherwise shouldn't call it directly. /// /// If you're working with the standard library then it's recommended to - /// use the `LocalWaker::from` function instead which works with the safe - /// `Rc` type and the safe `LocalWake` trait. + /// use the `local_waker_from_nonlocal` or `local_waker` to convert a `Waker` + /// into a `LocalWaker`. /// /// For this function to be used safely, it must be sound to call `inner.wake_local()` /// on the current thread. @@ -197,9 +197,7 @@ impl Drop for LocalWaker { /// customization. /// /// When using `std`, a default implementation of the `UnsafeWake` trait is provided for -/// `Arc` where `T: Wake` and `Rc` where `T: LocalWake`. -/// -/// Although the methods on `UnsafeWake` take pointers rather than references, +/// `Arc` where `T: Wake`. pub unsafe trait UnsafeWake: Send + Sync { /// Creates a clone of this `UnsafeWake` and stores it behind a `Waker`. /// From 1e1b800c2eb81418613520f9ede321e9d97e1707 Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 13 Jul 2018 01:56:17 +0800 Subject: [PATCH 16/19] Enabled core dump on Linux, and print stack trace on failure. --- .travis.yml | 26 +++++++++++++++++++++++++- src/ci/docker/run.sh | 1 + src/ci/run.sh | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2cf10d760980..0228fdc994dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,10 @@ sudo: required dist: trusty services: - docker +addons: + apt: + packages: + - gdb git: depth: 2 @@ -249,6 +253,8 @@ before_script: export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh"; else export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE"; + # Enable core dump on Linux. + sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern'; fi # Log time information from this machine and an external machine for insight into possible @@ -274,6 +280,8 @@ after_failure: # Random attempt at debugging currently. Just poking around in here to see if # anything shows up. + + # Dump backtrace for macOS - ls -lat $HOME/Library/Logs/DiagnosticReports/ - find $HOME/Library/Logs/DiagnosticReports -type f @@ -284,8 +292,24 @@ after_failure: -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true + # Dump backtrace for Linux + - ln -s . checkout && + for CORE in obj/cores/core.*; do + EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); + if [ -f "$EXE" ]; then + printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; + gdb -q -c "$CORE" "$EXE" + -iex 'set auto-load off' + -iex 'dir src/' + -iex 'set sysroot .' + -ex bt + -ex q; + echo travis_fold":"end:crashlog; + fi; + done || true + # see #50887 - - head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true + - cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true # attempt to debug anything killed by the oom killer on linux, just to see if # it happened diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 8913fdaa888e..931c28f1ca98 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -99,6 +99,7 @@ objdir=$root_dir/obj mkdir -p $HOME/.cargo mkdir -p $objdir/tmp +mkdir $objdir/cores args= if [ "$SCCACHE_BUCKET" != "" ]; then diff --git a/src/ci/run.sh b/src/ci/run.sh index 5b1fb676187b..09a0cf3541d8 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -24,6 +24,11 @@ if [ "$NO_CHANGE_USER" = "" ]; then fi fi +# only enable core dump on Linux +if [ -f /proc/sys/kernel/core_pattern ]; then + ulimit -c unlimited +fi + ci_dir=`cd $(dirname $0) && pwd` source "$ci_dir/shared.sh" From e20f1d159e805cb941f06c6277337a228c69a86c Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Fri, 13 Jul 2018 15:51:25 +0200 Subject: [PATCH 17/19] Fix typo in improper_ctypes suggestion closes #52345 --- src/librustc_lint/types.rs | 2 +- src/test/ui/lint-ctypes.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 50492ae07372..e5bd6a7f610f 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -673,7 +673,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { return FfiUnsafe { ty: ty, reason: "this function pointer has Rust-specific calling convention", - help: Some("consider using an `fn \"extern\"(...) -> ...` \ + help: Some("consider using an `extern fn(...) -> ...` \ function pointer instead"), } } diff --git a/src/test/ui/lint-ctypes.stderr b/src/test/ui/lint-ctypes.stderr index d1ef3a7a19c2..b97e4662660f 100644 --- a/src/test/ui/lint-ctypes.stderr +++ b/src/test/ui/lint-ctypes.stderr @@ -126,7 +126,7 @@ error: `extern` block uses type `fn()` which is not FFI-safe: this function poin LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific | ^^^^^^ | - = help: consider using an `fn "extern"(...) -> ...` function pointer instead + = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention --> $DIR/lint-ctypes.rs:70:24 @@ -134,7 +134,7 @@ error: `extern` block uses type `fn()` which is not FFI-safe: this function poin LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific | ^^^^ | - = help: consider using an `fn "extern"(...) -> ...` function pointer instead + = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout --> $DIR/lint-ctypes.rs:71:28 From 488472d754a70d6b1c98e4d901dff438257ab06d Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Fri, 13 Jul 2018 10:14:16 -0700 Subject: [PATCH 18/19] Don't silently ignore invalid data in target spec --- src/librustc_target/spec/mod.rs | 24 +++++++++++-------- .../my-x86_64-unknown-linux-gnu-platform.json | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 19e353c6a942..07c3ae697396 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -861,23 +861,27 @@ impl Target { } ); ($key_name:ident, link_args) => ( { let name = (stringify!($key_name)).replace("_", "-"); - if let Some(obj) = obj.find(&name[..]).and_then(|o| o.as_object()) { + if let Some(val) = obj.find(&name[..]) { + let obj = val.as_object().ok_or_else(|| format!("{}: expected a \ + JSON object with fields per linker-flavor.", name))?; let mut args = LinkArgs::new(); for (k, v) in obj { - let k = LinkerFlavor::from_str(&k).ok_or_else(|| { + let flavor = LinkerFlavor::from_str(&k).ok_or_else(|| { format!("{}: '{}' is not a valid value for linker-flavor. \ Use 'em', 'gcc', 'ld' or 'msvc'", name, k) })?; - let v = v.as_array().map(|a| { - a - .iter() - .filter_map(|o| o.as_string()) - .map(|s| s.to_owned()) - .collect::>() - }).unwrap_or(vec![]); + let v = v.as_array().ok_or_else(|| + format!("{}.{}: expected a JSON array", name, k) + )?.iter().enumerate() + .map(|(i,s)| { + let s = s.as_string().ok_or_else(|| + format!("{}.{}[{}]: expected a JSON string", name, k, i))?; + Ok(s.to_owned()) + }) + .collect::, String>>()?; - args.insert(k, v); + args.insert(flavor, v); } base.options.$key_name = args; } diff --git a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json index 3ae01d72fcc1..48040ae3da0e 100644 --- a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json +++ b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json @@ -1,5 +1,5 @@ { - "pre-link-args": ["-m64"], + "pre-link-args": {"gcc": ["-m64"]}, "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", "linker-flavor": "gcc", "llvm-target": "x86_64-unknown-linux-gnu", From 04d31df71d4dc45f4475b9b546238f3e638b850e Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Fri, 13 Jul 2018 19:33:48 +0200 Subject: [PATCH 19/19] Bump bootstrap compiler to 1.28.0-beta.10 --- src/stage0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stage0.txt b/src/stage0.txt index 538f3a851763..f2c0e9e3b2aa 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2018-06-30 +date: 2018-07-13 rustc: beta cargo: beta