Skip to content

Commit 9eb0bab

Browse files
committed
Rollup merge of rust-lang#23867 - nikomatsakis:issue-23086-take-3, r=pnkfelix
This PR implements rust-lang/rfcs#1023. In the process it fixes rust-lang#23086 and rust-lang#23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence. I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable). Fixes rust-lang#23918.
2 parents abd747c + 15b58fe commit 9eb0bab

40 files changed

+808
-227
lines changed

src/liballoc/boxed.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub static HEAP: () = ();
8686
/// See the [module-level documentation](../../std/boxed/index.html) for more.
8787
#[lang = "owned_box"]
8888
#[stable(feature = "rust1", since = "1.0.0")]
89+
#[fundamental]
8990
pub struct Box<T>(Unique<T>);
9091

9192
impl<T> Box<T> {
@@ -277,13 +278,6 @@ impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> {
277278
}
278279
}
279280

280-
#[stable(feature = "rust1", since = "1.0.0")]
281-
impl fmt::Debug for Box<Any> {
282-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
283-
f.pad("Box<Any>")
284-
}
285-
}
286-
287281
#[stable(feature = "rust1", since = "1.0.0")]
288282
impl<T: ?Sized> Deref for Box<T> {
289283
type Target = T;

src/liballoc/boxed_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ fn test_show() {
5555
let b = Box::new(Test) as Box<Any>;
5656
let a_str = format!("{:?}", a);
5757
let b_str = format!("{:?}", b);
58-
assert_eq!(a_str, "Box<Any>");
59-
assert_eq!(b_str, "Box<Any>");
58+
assert_eq!(a_str, "Any");
59+
assert_eq!(b_str, "Any");
6060

6161
static EIGHT: usize = 8;
6262
static TEST: Test = Test;
6363
let a = &EIGHT as &Any;
6464
let b = &TEST as &Any;
6565
let s = format!("{:?}", a);
66-
assert_eq!(s, "&Any");
66+
assert_eq!(s, "Any");
6767
let s = format!("{:?}", b);
68-
assert_eq!(s, "&Any");
68+
assert_eq!(s, "Any");
6969
}
7070

7171
#[test]

src/liballoc/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
#![feature(no_std)]
7272
#![no_std]
7373
#![feature(allocator)]
74+
#![feature(custom_attribute)]
75+
#![feature(fundamental)]
7476
#![feature(lang_items, unsafe_destructor)]
7577
#![feature(box_syntax)]
7678
#![feature(optin_builtin_traits)]

src/libcore/any.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
7272
#![stable(feature = "rust1", since = "1.0.0")]
7373

74+
use fmt;
7475
use marker::Send;
7576
use mem::transmute;
7677
use option::Option::{self, Some, None};
@@ -105,6 +106,13 @@ impl<T> Any for T
105106
// Extension methods for Any trait objects.
106107
///////////////////////////////////////////////////////////////////////////////
107108

109+
#[stable(feature = "rust1", since = "1.0.0")]
110+
impl fmt::Debug for Any {
111+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
112+
f.pad("Any")
113+
}
114+
}
115+
108116
impl Any {
109117
/// Returns true if the boxed type is the same as `T`
110118
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/fmt/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use any;
1615
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
1716
use char::CharExt;
1817
use iter::Iterator;
@@ -997,11 +996,6 @@ macro_rules! tuple {
997996

998997
tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
999998

1000-
#[stable(feature = "rust1", since = "1.0.0")]
1001-
impl<'a> Debug for &'a (any::Any+'a) {
1002-
fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
1003-
}
1004-
1005999
#[stable(feature = "rust1", since = "1.0.0")]
10061000
impl<T: Debug> Debug for [T] {
10071001
fn fmt(&self, f: &mut Formatter) -> Result {

src/libcore/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@
7070
#![feature(unboxed_closures)]
7171
#![feature(rustc_attrs)]
7272
#![feature(optin_builtin_traits)]
73+
#![feature(fundamental)]
7374
#![feature(concat_idents)]
7475
#![feature(reflect)]
76+
#![feature(custom_attribute)]
7577

7678
#[macro_use]
7779
mod macros;

src/libcore/marker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl !Send for Managed { }
4949
#[stable(feature = "rust1", since = "1.0.0")]
5050
#[lang="sized"]
5151
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
52+
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
5253
pub trait Sized : MarkerTrait {
5354
// Empty.
5455
}

src/libcore/ops.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T {
11171117
#[lang="fn"]
11181118
#[stable(feature = "rust1", since = "1.0.0")]
11191119
#[rustc_paren_sugar]
1120+
#[fundamental] // so that regex can rely that `&str: !FnMut`
11201121
pub trait Fn<Args> : FnMut<Args> {
11211122
/// This is called when the call operator is used.
11221123
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
@@ -1126,6 +1127,7 @@ pub trait Fn<Args> : FnMut<Args> {
11261127
#[lang="fn_mut"]
11271128
#[stable(feature = "rust1", since = "1.0.0")]
11281129
#[rustc_paren_sugar]
1130+
#[fundamental] // so that regex can rely that `&str: !FnMut`
11291131
pub trait FnMut<Args> : FnOnce<Args> {
11301132
/// This is called when the call operator is used.
11311133
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
@@ -1135,6 +1137,7 @@ pub trait FnMut<Args> : FnOnce<Args> {
11351137
#[lang="fn_once"]
11361138
#[stable(feature = "rust1", since = "1.0.0")]
11371139
#[rustc_paren_sugar]
1140+
#[fundamental] // so that regex can rely that `&str: !FnMut`
11381141
pub trait FnOnce<Args> {
11391142
/// The returned type after the call operator is used.
11401143
type Output;

src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use std::io::prelude::*;
3434
use std::io::{Cursor, SeekFrom};
3535
use syntax::abi;
3636
use syntax::ast::{self, DefId, NodeId};
37-
use syntax::ast_map::{PathElem, PathElems};
38-
use syntax::ast_map;
37+
use syntax::ast_map::{self, LinkedPath, PathElem, PathElems};
3938
use syntax::ast_util::*;
4039
use syntax::ast_util;
4140
use syntax::attr;
@@ -1513,7 +1512,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
15131512
&krate.module,
15141513
&[],
15151514
ast::CRATE_NODE_ID,
1516-
[].iter().cloned().chain(None),
1515+
[].iter().cloned().chain(LinkedPath::empty()),
15171516
syntax::parse::token::special_idents::invalid,
15181517
ast::Public);
15191518

@@ -1874,7 +1873,7 @@ fn encode_misc_info(ecx: &EncodeContext,
18741873
}
18751874

18761875
// Encode reexports for the root module.
1877-
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None));
1876+
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(LinkedPath::empty()));
18781877

18791878
rbml_w.end_tag();
18801879
rbml_w.end_tag();

0 commit comments

Comments
 (0)