← Back to all releases

Rust 1.28.0

Released on August 2, 2018

What's Changed

  • [The #[repr(transparent)] attribute is now stable.][51562] This attribute
  • [The keywords pure, sizeof, alignof, and offsetof have been unreserved
  • [The GlobalAlloc trait and #[global_allocator] attribute are now
  • [Unit test functions marked with the #[test] attribute can now return
  • [The lifetime specifier for macro_rules! is now stable.][50385] This

  • [The s and z optimisation levels are now stable.][50265] These optimisations
  • [The short error format is now stable.][49546] Specified with
  • [Added a lint warning when you have duplicated macro_exports.][50143]
  • [Reduced the number of allocations in the macro parser.][50855] This can

  • [Implemented Default for &mut str.][51306]
  • [Implemented From for all integer and unsigned number types.][50554]
  • [Implemented Extend for ().][50234]
  • [The Debug implementation of time::Duration should now be more easily
  • [Implemented From<&String> for Cow, From<&Vec> for Cow<[T]>,
  • [Implemented Shl and Shr for Wrapping
  • [DirEntry::metadata now uses fstatat instead of lstat when
  • [Improved error messages when using format!.][50610]
  • [Iterator::step_by]
  • [Path::ancestors]
  • [SystemTime::UNIX_EPOCH]
  • [alloc::GlobalAlloc]
  • [alloc::Layout]
  • [alloc::LayoutErr]
  • [alloc::System]
  • [alloc::alloc]
  • [alloc::alloc_zeroed]
  • [alloc::dealloc]
  • [alloc::realloc]
  • [alloc::handle_alloc_error]
  • [btree_map::Entry::or_default]
  • [fmt::Alignment]
  • [hash_map::Entry::or_default]
  • [iter::repeat_with]
  • [num::NonZeroUsize]
  • [num::NonZeroU128]
  • [num::NonZeroU16]
  • [num::NonZeroU32]
  • [num::NonZeroU64]
  • [num::NonZeroU8]
  • [ops::RangeBounds]
  • [slice::SliceIndex]
  • [slice::from_mut]
  • [slice::from_ref]
  • [{Any + Send + Sync}::downcast_mut]
  • [{Any + Send + Sync}::downcast_ref]
  • [{Any + Send + Sync}::is]

  • [Cargo will now no longer allow you to publish crates with build scripts that

  • [Rust will consider trait objects with duplicated constraints to be the same

  • [The suggestion_applicability field in rustc's json output is now
Full Changelog

Language

--------

- [The #[repr(transparent)] attribute is now stable.][51562] This attribute

allows a Rust newtype wrapper (struct NewType(T);) to be represented as

the inner type across Foreign Function Interface (FFI) boundaries.

- [The keywords pure, sizeof, alignof, and offsetof have been unreserved

and can now be used as identifiers.][51196]

- [The GlobalAlloc trait and #[global_allocator] attribute are now

stable.][51241] This will allow users to specify a global allocator for

their program.

- [Unit test functions marked with the #[test] attribute can now return

Result<(), E: Debug> in addition to ().][51298]

- [The lifetime specifier for macro_rules! is now stable.][50385] This

allows macros to easily target lifetimes.

Compiler

--------

- [The s and z optimisation levels are now stable.][50265] These optimisations

prioritise making smaller binary sizes. z is the same as s with the

exception that it does not vectorise loops, which typically results in an even

smaller binary.

- [The short error format is now stable.][49546] Specified with

--error-format=short this option will provide a more compressed output of

rust error messages.

- [Added a lint warning when you have duplicated macro_exports.][50143]

- [Reduced the number of allocations in the macro parser.][50855] This can

improve compile times of macro heavy crates on average by 5%.

Libraries

---------

- [Implemented Default for &mut str.][51306]

- [Implemented From for all integer and unsigned number types.][50554]

- [Implemented Extend for ().][50234]

- [The Debug implementation of time::Duration should now be more easily

human readable.][50364] Previously a Duration of one second would printed as

Duration { secs: 1, nanos: 0 } and will now be printed as 1s.

- [Implemented From<&String> for Cow, From<&Vec> for Cow<[T]>,

From> for CString, From, From, From<&CString>

for Cow, From, From, From<&OsString> for

Cow, From<&PathBuf> for Cow, and From>

for PathBuf.][50170]

- [Implemented Shl and Shr for Wrapping

and Wrapping.][50465]

- [DirEntry::metadata now uses fstatat instead of lstat when

possible.][51050] This can provide up to a 40% speed increase.

- [Improved error messages when using format!.][50610]

Stabilized APIs

---------------

- [Iterator::step_by]

- [Path::ancestors]

- [SystemTime::UNIX_EPOCH]

- [alloc::GlobalAlloc]

- [alloc::Layout]

- [alloc::LayoutErr]

- [alloc::System]

- [alloc::alloc]

- [alloc::alloc_zeroed]

- [alloc::dealloc]

- [alloc::realloc]

- [alloc::handle_alloc_error]

- [btree_map::Entry::or_default]

- [fmt::Alignment]

- [hash_map::Entry::or_default]

- [iter::repeat_with]

- [num::NonZeroUsize]

- [num::NonZeroU128]

- [num::NonZeroU16]

- [num::NonZeroU32]

- [num::NonZeroU64]

- [num::NonZeroU8]

- [ops::RangeBounds]

- [slice::SliceIndex]

- [slice::from_mut]

- [slice::from_ref]

- [{Any + Send + Sync}::downcast_mut]

- [{Any + Send + Sync}::downcast_ref]

- [{Any + Send + Sync}::is]

Cargo

-----

- [Cargo will now no longer allow you to publish crates with build scripts that

modify the src directory.][cargo/5584] The src directory in a crate should be

considered to be immutable.

Misc

----

- [The suggestion_applicability field in rustc's json output is now

stable.][50486] This will allow dev tools to check whether a code suggestion

would apply to them.

Compatibility Notes

-------------------

- [Rust will consider trait objects with duplicated constraints to be the same

type as without the duplicated constraint.][51276] For example the below code will

now fail to compile.

  trait Trait {}

impl Trait + Send {

fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name test

}

impl Trait + Send + Send {

fn test(&self) { println!("two"); }

}

[49546]: https://github.com/rust-lang/rust/pull/49546/

[50143]: https://github.com/rust-lang/rust/pull/50143/

[50170]: https://github.com/rust-lang/rust/pull/50170/

[50234]: https://github.com/rust-lang/rust/pull/50234/

[50265]: https://github.com/rust-lang/rust/pull/50265/

[50364]: https://github.com/rust-lang/rust/pull/50364/

[50385]: https://github.com/rust-lang/rust/pull/50385/

[50465]: https://github.com/rust-lang/rust/pull/50465/

[50486]: https://github.com/rust-lang/rust/pull/50486/

[50554]: https://github.com/rust-lang/rust/pull/50554/

[50610]: https://github.com/rust-lang/rust/pull/50610/

[50855]: https://github.com/rust-lang/rust/pull/50855/

[51050]: https://github.com/rust-lang/rust/pull/51050/

[51196]: https://github.com/rust-lang/rust/pull/51196/

[51241]: https://github.com/rust-lang/rust/pull/51241/

[51276]: https://github.com/rust-lang/rust/pull/51276/

[51298]: https://github.com/rust-lang/rust/pull/51298/

[51306]: https://github.com/rust-lang/rust/pull/51306/

[51562]: https://github.com/rust-lang/rust/pull/51562/

[cargo/5584]: https://github.com/rust-lang/cargo/pull/5584/

[Iterator::step_by]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.step_by

[Path::ancestors]: https://doc.rust-lang.org/std/path/struct.Path.html#method.ancestors

[SystemTime::UNIX_EPOCH]: https://doc.rust-lang.org/std/time/struct.SystemTime.html#associatedconstant.UNIX_EPOCH

[alloc::GlobalAlloc]: https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html

[alloc::Layout]: https://doc.rust-lang.org/std/alloc/struct.Layout.html

[alloc::LayoutErr]: https://doc.rust-lang.org/std/alloc/struct.LayoutErr.html

[alloc::System]: https://doc.rust-lang.org/std/alloc/struct.System.html

[alloc::alloc]: https://doc.rust-lang.org/std/alloc/fn.alloc.html

[alloc::alloc_zeroed]: https://doc.rust-lang.org/std/alloc/fn.alloc_zeroed.html

[alloc::dealloc]: https://doc.rust-lang.org/std/alloc/fn.dealloc.html

[alloc::realloc]: https://doc.rust-lang.org/std/alloc/fn.realloc.html

[alloc::handle_alloc_error]: https://doc.rust-lang.org/std/alloc/fn.handle_alloc_error.html

[btree_map::Entry::or_default]: https://doc.rust-lang.org/std/collections/btree_map/enum.Entry.html#method.or_default

[fmt::Alignment]: https://doc.rust-lang.org/std/fmt/enum.Alignment.html

[hash_map::Entry::or_default]: https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_default

[iter::repeat_with]: https://doc.rust-lang.org/std/iter/fn.repeat_with.html

[num::NonZeroUsize]: https://doc.rust-lang.org/std/num/struct.NonZeroUsize.html

[num::NonZeroU128]: https://doc.rust-lang.org/std/num/struct.NonZeroU128.html

[num::NonZeroU16]: https://doc.rust-lang.org/std/num/struct.NonZeroU16.html

[num::NonZeroU32]: https://doc.rust-lang.org/std/num/struct.NonZeroU32.html

[num::NonZeroU64]: https://doc.rust-lang.org/std/num/struct.NonZeroU64.html

[num::NonZeroU8]: https://doc.rust-lang.org/std/num/struct.NonZeroU8.html

[ops::RangeBounds]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html

[slice::SliceIndex]: https://doc.rust-lang.org/std/slice/trait.SliceIndex.html

[slice::from_mut]: https://doc.rust-lang.org/std/slice/fn.from_mut.html

[slice::from_ref]: https://doc.rust-lang.org/std/slice/fn.from_ref.html

[{Any + Send + Sync}::downcast_mut]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_mut-2

[{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