Skip to content
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b79a83b
Suggestion for print
csmoe Jun 17, 2018
c999b25
add span note
csmoe Jul 4, 2018
88f475c
suggests with whole macro call
csmoe Jul 4, 2018
01b6d7c
libsyntax_pos: Tweak some visibilities
petrochenkov Jun 30, 2018
94ef9f5
hygiene: Decouple transparencies from expansion IDs
petrochenkov Jun 30, 2018
fc74e35
Remove fallback to parent modules from lexical resolution
petrochenkov Jul 7, 2018
39fcfa8
step_by: leave time of item skip unspecified
Emerentius Jul 9, 2018
f511c5e
improve error message shown for unsafe operations: explain why undefi…
RalfJung Jul 10, 2018
296e72f
Deny bare trait objects in in src/liballoc
ljedrz Jul 10, 2018
e28e487
Deny bare trait objects in in src/libsyntax
ljedrz Jul 10, 2018
84dadb6
Pacify tidy
ljedrz Jul 10, 2018
cd44b3d
Add missing dyn in liballoc
ljedrz Jul 10, 2018
0f3f292
remove sync::Once::call_once 'static
CAD97 Jul 11, 2018
217f8fb
Revert borked changes in last commit.
ljedrz Jul 11, 2018
f68323b
fix typo
RalfJung Jul 11, 2018
48e501f
Deny bare trait objects in in src/librustc
ljedrz Jul 11, 2018
5ccaaa8
Deny bare trait objects in in src/librustc_allocator
ljedrz Jul 11, 2018
ea47350
Deny bare trait objects in in src/librustc_codegen_llvm
ljedrz Jul 11, 2018
790c09e
suggest on new snippet
csmoe Jul 11, 2018
ff65bbe
Deny bare trait objects in in src/librustc_data_structures
ljedrz Jul 11, 2018
bbaf45d
Enforce #![deny(bare_trait_objects)] in src/librustc_data_structures …
ljedrz Jul 11, 2018
9cffe90
Deny bare trait objects in in src/librustc_metadata
ljedrz Jul 11, 2018
6cfd49e
add a missing `dyn`
ljedrz Jul 11, 2018
dbab06d
Deny bare trait objects in in src/libpanic_unwind
ljedrz Jul 11, 2018
715b885
Deny bare trait objects in in src/librustc_codegen_utils
ljedrz Jul 11, 2018
d2a8a2b
Rollup merge of #51614 - csmoe:lit_sugg, r=estebank
Mark-Simulacrum Jul 11, 2018
322632a
Rollup merge of #51952 - petrochenkov:transmark, r=alexcrichton
Mark-Simulacrum Jul 11, 2018
74cc821
Rollup merge of #52193 - Emerentius:step_by_note, r=alexcrichton
Mark-Simulacrum Jul 11, 2018
7897ee4
Rollup merge of #52207 - RalfJung:unsafety-errors, r=estebank
Mark-Simulacrum Jul 11, 2018
d096f6a
Rollup merge of #52223 - ljedrz:dyn_liballoc, r=cramertj
Mark-Simulacrum Jul 11, 2018
2d49909
Rollup merge of #52224 - ljedrz:dyn_libsyntax, r=oli-obk
Mark-Simulacrum Jul 11, 2018
b41105b
Rollup merge of #52239 - CAD97:patch-1, r=alexcrichton
Mark-Simulacrum Jul 11, 2018
2774179
Rollup merge of #52247 - ljedrz:dyn_librustc, r=oli-obk
Mark-Simulacrum Jul 11, 2018
8d9a6a7
Rollup merge of #52248 - ljedrz:dyn_librustc_allocator, r=oli-obk
Mark-Simulacrum Jul 11, 2018
dcc536f
Rollup merge of #52252 - ljedrz:dyn_librustc_codegen_llvm, r=varkor
Mark-Simulacrum Jul 11, 2018
59fb178
Rollup merge of #52253 - ljedrz:dyn_librustc_data_structures, r=cramertj
Mark-Simulacrum Jul 11, 2018
e6f6608
Rollup merge of #52254 - ljedrz:dyn_librustc_metadata, r=cramertj
Mark-Simulacrum Jul 11, 2018
7585bd5
Rollup merge of #52261 - ljedrz:dyn_libpanic_unwind, r=alexcrichton
Mark-Simulacrum Jul 11, 2018
a0b288e
Rollup merge of #52265 - ljedrz:dyn_librustc_codegen_utils, r=oli-obk
Mark-Simulacrum Jul 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
@@ -446,7 +446,7 @@ impl From<Box<str>> for Box<[u8]> {
}
}

impl Box<Any> {
impl Box<dyn Any> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type.
@@ -468,10 +468,10 @@ impl Box<Any> {
/// print_if_string(Box::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> {
if self.is::<T>() {
unsafe {
let raw: *mut Any = Box::into_raw(self);
let raw: *mut dyn Any = Box::into_raw(self);
Ok(Box::from_raw(raw as *mut T))
}
} else {
@@ -480,7 +480,7 @@ impl Box<Any> {
}
}

impl Box<Any + Send> {
impl Box<dyn Any + Send> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type.
@@ -502,10 +502,10 @@ impl Box<Any + Send> {
/// print_if_string(Box::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
<Box<Any>>::downcast(self).map_err(|s| unsafe {
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any + Send>> {
<Box<dyn Any>>::downcast(self).map_err(|s| unsafe {
// reapply the Send marker
Box::from_raw(Box::into_raw(s) as *mut (Any + Send))
Box::from_raw(Box::into_raw(s) as *mut (dyn Any + Send))
})
}
}
@@ -643,7 +643,7 @@ impl<A, F> FnBox<A> for F

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + 'a> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
@@ -653,7 +653,7 @@ impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {

#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + 'a> {
type Output = R;

extern "rust-call" fn call_once(self, args: A) -> R {
20 changes: 10 additions & 10 deletions src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
@@ -31,8 +31,8 @@ struct Test;

#[test]
fn any_move() {
let a = Box::new(8) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
let a = Box::new(8) as Box<dyn Any>;
let b = Box::new(Test) as Box<dyn Any>;

match a.downcast::<i32>() {
Ok(a) => {
@@ -47,26 +47,26 @@ fn any_move() {
Err(..) => panic!(),
}

let a = Box::new(8) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
let a = Box::new(8) as Box<dyn Any>;
let b = Box::new(Test) as Box<dyn Any>;

assert!(a.downcast::<Box<Test>>().is_err());
assert!(b.downcast::<Box<i32>>().is_err());
}

#[test]
fn test_show() {
let a = Box::new(8) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
let a = Box::new(8) as Box<dyn Any>;
let b = Box::new(Test) as Box<dyn Any>;
let a_str = format!("{:?}", a);
let b_str = format!("{:?}", b);
assert_eq!(a_str, "Any");
assert_eq!(b_str, "Any");

static EIGHT: usize = 8;
static TEST: Test = Test;
let a = &EIGHT as &Any;
let b = &TEST as &Any;
let a = &EIGHT as &dyn Any;
let b = &TEST as &dyn Any;
let s = format!("{:?}", a);
assert_eq!(s, "Any");
let s = format!("{:?}", b);
@@ -110,12 +110,12 @@ fn raw_trait() {
}
}

let x: Box<Foo> = Box::new(Bar(17));
let x: Box<dyn Foo> = Box::new(Bar(17));
let p = Box::into_raw(x);
unsafe {
assert_eq!(17, (*p).get());
(*p).set(19);
let y: Box<Foo> = Box::from_raw(p);
let y: Box<dyn Foo> = Box::from_raw(p);
assert_eq!(19, y.get());
}
}
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std]
#![needs_allocator]
#![deny(bare_trait_objects)]
#![deny(missing_debug_implementations)]

#![cfg_attr(test, allow(deprecated))] // rand
18 changes: 9 additions & 9 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
@@ -618,7 +618,7 @@ impl<T: Clone> Rc<T> {
}
}

impl Rc<Any> {
impl Rc<dyn Any> {
#[inline]
#[stable(feature = "rc_downcast", since = "1.29.0")]
/// Attempt to downcast the `Rc<Any>` to a concrete type.
@@ -641,7 +641,7 @@ impl Rc<Any> {
/// print_if_string(Rc::new(0i8));
/// }
/// ```
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<Any>> {
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<dyn Any>> {
if (*self).is::<T>() {
let ptr = self.ptr.cast::<RcBox<T>>();
forget(self);
@@ -1554,7 +1554,7 @@ mod tests {
assert_eq!(unsafe { &*ptr }, "foo");
assert_eq!(rc, rc2);

let rc: Rc<Display> = Rc::new(123);
let rc: Rc<dyn Display> = Rc::new(123);

let ptr = Rc::into_raw(rc.clone());
let rc2 = unsafe { Rc::from_raw(ptr) };
@@ -1755,8 +1755,8 @@ mod tests {
use std::fmt::Display;
use std::string::ToString;

let b: Box<Display> = box 123;
let r: Rc<Display> = Rc::from(b);
let b: Box<dyn Display> = box 123;
let r: Rc<dyn Display> = Rc::from(b);

assert_eq!(r.to_string(), "123");
}
@@ -1765,8 +1765,8 @@ mod tests {
fn test_from_box_trait_zero_sized() {
use std::fmt::Debug;

let b: Box<Debug> = box ();
let r: Rc<Debug> = Rc::from(b);
let b: Box<dyn Debug> = box ();
let r: Rc<dyn Debug> = Rc::from(b);

assert_eq!(format!("{:?}", r), "()");
}
@@ -1783,8 +1783,8 @@ mod tests {
fn test_downcast() {
use std::any::Any;

let r1: Rc<Any> = Rc::new(i32::max_value());
let r2: Rc<Any> = Rc::new("abc");
let r1: Rc<dyn Any> = Rc::new(i32::max_value());
let r2: Rc<dyn Any> = Rc::new("abc");

assert!(r1.clone().downcast::<u32>().is_err());

20 changes: 10 additions & 10 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
@@ -978,18 +978,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
}
}

impl Arc<Any + Send + Sync> {
impl Arc<dyn Any + Send + Sync> {
#[inline]
#[stable(feature = "rc_downcast", since = "1.29.0")]
/// Attempt to downcast the `Arc<Any + Send + Sync>` to a concrete type.
/// Attempt to downcast the `Arc<dyn Any + Send + Sync>` to a concrete type.
///
/// # Examples
///
/// ```
/// use std::any::Any;
/// use std::sync::Arc;
///
/// fn print_if_string(value: Arc<Any + Send + Sync>) {
/// fn print_if_string(value: Arc<dyn Any + Send + Sync>) {
/// if let Ok(string) = value.downcast::<String>() {
/// println!("String ({}): {}", string.len(), string);
/// }
@@ -1574,7 +1574,7 @@ mod tests {
assert_eq!(unsafe { &*ptr }, "foo");
assert_eq!(arc, arc2);

let arc: Arc<Display> = Arc::new(123);
let arc: Arc<dyn Display> = Arc::new(123);

let ptr = Arc::into_raw(arc.clone());
let arc2 = unsafe { Arc::from_raw(ptr) };
@@ -1879,8 +1879,8 @@ mod tests {
use std::fmt::Display;
use std::string::ToString;

let b: Box<Display> = box 123;
let r: Arc<Display> = Arc::from(b);
let b: Box<dyn Display> = box 123;
let r: Arc<dyn Display> = Arc::from(b);

assert_eq!(r.to_string(), "123");
}
@@ -1889,8 +1889,8 @@ mod tests {
fn test_from_box_trait_zero_sized() {
use std::fmt::Debug;

let b: Box<Debug> = box ();
let r: Arc<Debug> = Arc::from(b);
let b: Box<dyn Debug> = box ();
let r: Arc<dyn Debug> = Arc::from(b);

assert_eq!(format!("{:?}", r), "()");
}
@@ -1907,8 +1907,8 @@ mod tests {
fn test_downcast() {
use std::any::Any;

let r1: Arc<Any + Send + Sync> = Arc::new(i32::max_value());
let r2: Arc<Any + Send + Sync> = Arc::new("abc");
let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::max_value());
let r2: Arc<dyn Any + Send + Sync> = Arc::new("abc");

assert!(r1.clone().downcast::<u32>().is_err());

23 changes: 22 additions & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
@@ -271,9 +271,30 @@ pub trait Iterator {
/// Creates an iterator starting at the same point, but stepping by
/// the given amount at each iteration.
///
/// Note that it will always return the first element of the iterator,
/// Note 1: The first element of the iterator will always be returned,
/// regardless of the step given.
///
/// Note 2: The time at which ignored elements are pulled is not fixed.
/// `StepBy` behaves like the sequence `next(), nth(step-1), nth(step-1), …`,
/// but is also free to behave like the sequence
/// `advance_n_and_return_first(step), advance_n_and_return_first(step), …`
/// Which way is used may change for some iterators for performance reasons.
/// The second way will advance the iterator earlier and may consume more items.
///
/// `advance_n_and_return_first` is the equivalent of:
/// ```
/// fn advance_n_and_return_first<I>(iter: &mut I, total_step: usize) -> Option<I::Item>
/// where
/// I: Iterator,
/// {
/// let next = iter.next();
/// if total_step > 1 {
/// iter.nth(total_step-2);
/// }
/// next
/// }
/// ```
///
/// # Panics
///
/// The method will panic if the given step is `0`.
4 changes: 2 additions & 2 deletions src/libpanic_unwind/dwarf/eh.rs
Original file line number Diff line number Diff line change
@@ -48,8 +48,8 @@ pub const DW_EH_PE_indirect: u8 = 0x80;
pub struct EHContext<'a> {
pub ip: usize, // Current instruction pointer
pub func_start: usize, // Address of the current function
pub get_text_start: &'a Fn() -> usize, // Get address of the code section
pub get_data_start: &'a Fn() -> usize, // Get address of the data section
pub get_text_start: &'a dyn Fn() -> usize, // Get address of the code section
pub get_data_start: &'a dyn Fn() -> usize, // Get address of the data section
}

pub enum EHAction {
6 changes: 3 additions & 3 deletions src/libpanic_unwind/emcc.rs
Original file line number Diff line number Diff line change
@@ -29,20 +29,20 @@ pub fn payload() -> *mut u8 {
ptr::null_mut()
}

pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
assert!(!ptr.is_null());
let ex = ptr::read(ptr as *mut _);
__cxa_free_exception(ptr as *mut _);
ex
}

pub unsafe fn panic(data: Box<Any + Send>) -> u32 {
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
let sz = mem::size_of_val(&data);
let exception = __cxa_allocate_exception(sz);
if exception == ptr::null_mut() {
return uw::_URC_FATAL_PHASE1_ERROR as u32;
}
let exception = exception as *mut Box<Any + Send>;
let exception = exception as *mut Box<dyn Any + Send>;
ptr::write(exception, data);
__cxa_throw(exception as *mut _, ptr::null_mut(), ptr::null_mut());

6 changes: 3 additions & 3 deletions src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
@@ -67,10 +67,10 @@ use dwarf::eh::{self, EHContext, EHAction};
#[repr(C)]
struct Exception {
_uwe: uw::_Unwind_Exception,
cause: Option<Box<Any + Send>>,
cause: Option<Box<dyn Any + Send>>,
}

pub unsafe fn panic(data: Box<Any + Send>) -> u32 {
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
let exception = Box::new(Exception {
_uwe: uw::_Unwind_Exception {
exception_class: rust_exception_class(),
@@ -94,7 +94,7 @@ pub fn payload() -> *mut u8 {
ptr::null_mut()
}

pub unsafe fn cleanup(ptr: *mut u8) -> Box<Any + Send> {
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
let my_ep = ptr as *mut Exception;
let cause = (*my_ep).cause.take();
uw::_Unwind_DeleteException(ptr as *mut _);
3 changes: 2 additions & 1 deletion src/libpanic_unwind/lib.rs
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
//! More documentation about each implementation can be found in the respective
//! module.
#![deny(bare_trait_objects)]
#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -117,6 +118,6 @@ pub unsafe extern "C" fn __rust_maybe_catch_panic(f: fn(*mut u8),
#[no_mangle]
#[unwind(allowed)]
pub unsafe extern "C" fn __rust_start_panic(payload: usize) -> u32 {
let payload = payload as *mut &mut BoxMeUp;
let payload = payload as *mut &mut dyn BoxMeUp;
imp::panic(Box::from_raw((*payload).box_me_up()))
}
6 changes: 3 additions & 3 deletions src/libpanic_unwind/seh.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
//! throwing. Note that throwing an exception into Rust is undefined behavior
//! anyway, so this should be fine.
//! * We've got some data to transmit across the unwinding boundary,
//! specifically a `Box<Any + Send>`. Like with Dwarf exceptions
//! specifically a `Box<dyn Any + Send>`. Like with Dwarf exceptions
//! these two pointers are stored as a payload in the exception itself. On
//! MSVC, however, there's no need for an extra heap allocation because the
//! call stack is preserved while filter functions are being executed. This
@@ -243,7 +243,7 @@ static mut TYPE_DESCRIPTOR2: _TypeDescriptor = _TypeDescriptor {
name: imp::NAME2,
};

pub unsafe fn panic(data: Box<Any + Send>) -> u32 {
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
use core::intrinsics::atomic_store;

// _CxxThrowException executes entirely on this stack frame, so there's no
@@ -297,7 +297,7 @@ pub fn payload() -> [u64; 2] {
[0; 2]
}

pub unsafe fn cleanup(payload: [u64; 2]) -> Box<Any + Send> {
pub unsafe fn cleanup(payload: [u64; 2]) -> Box<dyn Any + Send> {
mem::transmute(raw::TraitObject {
data: payload[0] as *mut _,
vtable: payload[1] as *mut _,
Loading