Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #57737

Merged
merged 29 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5eafae2
Remove confusing comment about ideally using `!` for `c_void`
sdroege Dec 7, 2018
8de8880
Update code comments of `c_void` to explain the reasoning for its cur…
sdroege Dec 10, 2018
96678df
Cleanup PartialEq docs.
frewsxcv Jan 5, 2019
0d3dfdf
Fix compile error
frewsxcv Jan 6, 2019
319a2c1
add missing derive to fix compile error
frewsxcv Jan 6, 2019
bbbabdf
Update cmp.rs
frewsxcv Jan 6, 2019
6c60662
Use correct tracking issue for c_variadic
eqrion Jan 4, 2019
423a5bb
add comment explaining what the derive does
frewsxcv Jan 12, 2019
1445a06
bring back the example i removed, also add symmetry and simplify impl
frewsxcv Jan 12, 2019
0394dce
whitespace
frewsxcv Jan 12, 2019
ebdd072
resolve: Add a test for issue #57539
petrochenkov Jan 12, 2019
ed717f3
Fix sources sidebar not showing up
GuillaumeGomez Jan 15, 2019
feda604
Fixes text becoming invisible when element targetted
GuillaumeGomez Jan 15, 2019
32b2834
demonstrate symmetry
frewsxcv Jan 16, 2019
bd8ee51
Add some links in std::fs.
ehuss Jan 16, 2019
e4e8885
Document Unpin in std::prelude documentation
KamilaBorowska Jan 16, 2019
22251a8
Enhance `Pin` impl applicability for `PartialEq` and `PartialOrd`.
pthariensflame Jan 17, 2019
fefe1da
Fix tidy errors.
pthariensflame Jan 17, 2019
2518987
Fix non-clickable urls
GuillaumeGomez Jan 17, 2019
9e78bc5
Rollup merge of #56594 - sdroege:c_void-is-not-never, r=TimNN
Centril Jan 18, 2019
76cdccb
Rollup merge of #57340 - eqrion:doc/c_variadic, r=Mark-Simulacrum
Centril Jan 18, 2019
bca4908
Rollup merge of #57357 - frewsxcv:frewsxcv-partial-eq, r=QuietMisdreavus
Centril Jan 18, 2019
4091ca0
Rollup merge of #57551 - petrochenkov:regrtest, r=nikomatsakis
Centril Jan 18, 2019
e264980
Rollup merge of #57636 - GuillaumeGomez:fix-sources-sidebar, r=QuietM…
Centril Jan 18, 2019
b9e940c
Rollup merge of #57646 - GuillaumeGomez:fix-css, r=QuietMisdreavus
Centril Jan 18, 2019
b12397f
Rollup merge of #57654 - ehuss:fs-links, r=alexcrichton
Centril Jan 18, 2019
b0563fd
Rollup merge of #57683 - xfix:patch-15, r=QuietMisdreavus
Centril Jan 18, 2019
25ea20d
Rollup merge of #57685 - pthariensflame:enhancement/pin-impl-applicab…
Centril Jan 18, 2019
ff583ac
Rollup merge of #57710 - GuillaumeGomez:non-clickable, r=QuietMisdreavus
Centril Jan 18, 2019
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
38 changes: 22 additions & 16 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ use self::Ordering::*;
/// For example, let's tweak our previous code a bit:
///
/// ```
/// // The derive implements <BookFormat> == <BookFormat> comparisons
/// #[derive(PartialEq)]
/// enum BookFormat {
/// Paperback,
/// Hardback,
Expand All @@ -102,31 +104,34 @@ use self::Ordering::*;
/// format: BookFormat,
/// }
///
/// // Implement <Book> == <BookFormat> comparisons
/// impl PartialEq<BookFormat> for Book {
/// fn eq(&self, other: &BookFormat) -> bool {
/// match (&self.format, other) {
/// (BookFormat::Paperback, BookFormat::Paperback) => true,
/// (BookFormat::Hardback, BookFormat::Hardback) => true,
/// (BookFormat::Ebook, BookFormat::Ebook) => true,
/// (_, _) => false,
/// }
/// self.format == *other
/// }
/// }
///
/// // Implement <BookFormat> == <Book> comparisons
/// impl PartialEq<Book> for BookFormat {
/// fn eq(&self, other: &Book) -> bool {
/// *self == other.format
/// }
/// }
///
/// let b1 = Book { isbn: 3, format: BookFormat::Paperback };
///
/// assert!(b1 == BookFormat::Paperback);
/// assert!(b1 != BookFormat::Ebook);
/// assert!(BookFormat::Ebook != b1);
/// ```
///
/// By changing `impl PartialEq for Book` to `impl PartialEq<BookFormat> for Book`,
/// we've changed what type we can use on the right side of the `==` operator.
/// This lets us use it in the `assert!` statements at the bottom.
/// we allow `BookFormat`s to be compared with `Book`s.
///
/// You can also combine these implementations to let the `==` operator work with
/// two different types:
///
/// ```
/// #[derive(PartialEq)]
/// enum BookFormat {
/// Paperback,
/// Hardback,
Expand All @@ -140,12 +145,13 @@ use self::Ordering::*;
///
/// impl PartialEq<BookFormat> for Book {
/// fn eq(&self, other: &BookFormat) -> bool {
/// match (&self.format, other) {
/// (&BookFormat::Paperback, &BookFormat::Paperback) => true,
/// (&BookFormat::Hardback, &BookFormat::Hardback) => true,
/// (&BookFormat::Ebook, &BookFormat::Ebook) => true,
/// (_, _) => false,
/// }
/// self.format == *other
/// }
/// }
///
/// impl PartialEq<Book> for BookFormat {
/// fn eq(&self, other: &Book) -> bool {
/// *self == other.format
/// }
/// }
///
Expand All @@ -159,7 +165,7 @@ use self::Ordering::*;
/// let b2 = Book { isbn: 3, format: BookFormat::Ebook };
///
/// assert!(b1 == BookFormat::Paperback);
/// assert!(b1 != BookFormat::Ebook);
/// assert!(BookFormat::Ebook != b1);
/// assert!(b1 == b2);
/// ```
///
Expand Down
39 changes: 21 additions & 18 deletions src/libcore/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ use ::fmt;
/// and `*mut c_void` is equivalent to C's `void*`. That said, this is
/// *not* the same as C's `void` return type, which is Rust's `()` type.
///
/// Ideally, this type would be equivalent to [`!`], but currently it may
/// be more ideal to use `c_void` for FFI purposes.
/// To model pointers to opaque types in FFI, until `extern type` is
/// stabilized, it is recommended to use a newtype wrapper around an empty
/// byte array. See the [Nomicon] for details.
///
/// [`!`]: ../../std/primitive.never.html
/// [pointer]: ../../std/primitive.pointer.html
/// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
// N.B., for LLVM to recognize the void pointer type and by extension
// functions like malloc(), we need to have it represented as i8* in
// LLVM bitcode. The enum used here ensures this and prevents misuse
// of the "raw" type by only having private variants.. We need two
// of the "raw" type by only having private variants. We need two
// variants, because the compiler complains about the repr attribute
// otherwise.
// otherwise and we need at least one variant as otherwise the enum
// would be uninhabited and at least dereferencing such pointers would
// be UB.
#[repr(u8)]
#[stable(feature = "raw_os", since = "1.1.0")]
pub enum c_void {
#[unstable(feature = "c_void_variant", reason = "should not have to exist",
#[unstable(feature = "c_void_variant", reason = "temporary implementation detail",
issue = "0")]
#[doc(hidden)] __variant1,
#[unstable(feature = "c_void_variant", reason = "should not have to exist",
#[unstable(feature = "c_void_variant", reason = "temporary implementation detail",
issue = "0")]
#[doc(hidden)] __variant2,
}
Expand All @@ -49,7 +52,7 @@ impl fmt::Debug for c_void {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
extern {
type VaListImpl;
}
Expand All @@ -74,7 +77,7 @@ impl fmt::Debug for VaListImpl {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
struct VaListImpl {
stack: *mut (),
gr_top: *mut (),
Expand All @@ -90,7 +93,7 @@ struct VaListImpl {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
struct VaListImpl {
gpr: u8,
fpr: u8,
Expand All @@ -106,7 +109,7 @@ struct VaListImpl {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
struct VaListImpl {
gp_offset: i32,
fp_offset: i32,
Expand All @@ -120,7 +123,7 @@ struct VaListImpl {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
#[repr(transparent)]
pub struct VaList<'a>(&'a mut VaListImpl);

Expand All @@ -140,7 +143,7 @@ mod sealed_trait {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
pub trait VaArgSafe {}
}

Expand All @@ -150,7 +153,7 @@ macro_rules! impl_va_arg_safe {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
impl sealed_trait::VaArgSafe for $t {}
)+
}
Expand All @@ -163,20 +166,20 @@ impl_va_arg_safe!{f64}
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
impl<T> sealed_trait::VaArgSafe for *mut T {}
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
impl<T> sealed_trait::VaArgSafe for *const T {}

impl<'a> VaList<'a> {
/// Advance to the next arg.
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
pub unsafe fn arg<T: sealed_trait::VaArgSafe>(&mut self) -> T {
va_arg(self)
}
Expand All @@ -185,7 +188,7 @@ impl<'a> VaList<'a> {
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
pub unsafe fn copy<F, R>(&self, f: F) -> R
where F: for<'copy> FnOnce(VaList<'copy>) -> R {
#[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"),
Expand Down
48 changes: 45 additions & 3 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@

use fmt;
use marker::{Sized, Unpin};
use cmp::{self, PartialEq, PartialOrd};
use ops::{Deref, DerefMut, Receiver, CoerceUnsized, DispatchFromDyn};

/// A pinned pointer.
Expand All @@ -112,16 +113,57 @@ use ops::{Deref, DerefMut, Receiver, CoerceUnsized, DispatchFromDyn};
/// [`Unpin`]: ../../std/marker/trait.Unpin.html
/// [`pin` module]: ../../std/pin/index.html
//
// Note: the derives below are allowed because they all only use `&P`, so they
// cannot move the value behind `pointer`.
// Note: the derives below, and the explicit `PartialEq` and `PartialOrd`
// implementations, are allowed because they all only use `&P`, so they cannot move
// the value behind `pointer`.
#[stable(feature = "pin", since = "1.33.0")]
#[fundamental]
#[repr(transparent)]
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Copy, Clone, Hash, Eq, Ord)]
pub struct Pin<P> {
pointer: P,
}

#[stable(feature = "pin_partialeq_partialord_impl_applicability", since = "1.34.0")]
impl<P, Q> PartialEq<Pin<Q>> for Pin<P>
where
P: PartialEq<Q>,
{
fn eq(&self, other: &Pin<Q>) -> bool {
self.pointer == other.pointer
}

fn ne(&self, other: &Pin<Q>) -> bool {
self.pointer != other.pointer
}
}

#[stable(feature = "pin_partialeq_partialord_impl_applicability", since = "1.34.0")]
impl<P, Q> PartialOrd<Pin<Q>> for Pin<P>
where
P: PartialOrd<Q>,
{
fn partial_cmp(&self, other: &Pin<Q>) -> Option<cmp::Ordering> {
self.pointer.partial_cmp(&other.pointer)
}

fn lt(&self, other: &Pin<Q>) -> bool {
self.pointer < other.pointer
}

fn le(&self, other: &Pin<Q>) -> bool {
self.pointer <= other.pointer
}

fn gt(&self, other: &Pin<Q>) -> bool {
self.pointer > other.pointer
}

fn ge(&self, other: &Pin<Q>) -> bool {
self.pointer >= other.pointer
}
}

impl<P: Deref> Pin<P>
where
P::Target: Unpin,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ themePicker.onblur = handleThemeButtonsBlur;
all_sources.sort();
let mut w = try_err!(File::create(&dst), &dst);
try_err!(writeln!(&mut w,
"var N = null;var sourcesIndex = {{}};\n{}",
"var N = null;var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();",
all_sources.join("\n")),
&dst);
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,6 @@ h4 > code, h3 > code, .invisible > code {
display: block;
}

.in-band, code {
z-index: -5;
}

.invisible {
width: 100%;
display: inline-block;
Expand Down
2 changes: 0 additions & 2 deletions src/librustdoc/html/static/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,3 @@ function createSourceSidebar() {

main.insertBefore(sidebar, main.firstChild);
}

createSourceSidebar();
8 changes: 1 addition & 7 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ pre {
border-bottom-color: #ddd;
}

:target { background: #494a3d; }

:target > .in-band {
background: #494a3d;
}

.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
Expand Down Expand Up @@ -252,7 +246,7 @@ a.test-arrow:hover{
color: #999;
}

:target > code {
:target > code, :target > .in-band {
background-color: #494a3d;
}

Expand Down
8 changes: 1 addition & 7 deletions src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ pre {
border-bottom-color: #ddd;
}

:target { background: #FDFFD3; }

:target > .in-band {
background: #FDFFD3;
}

.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
Expand Down Expand Up @@ -247,7 +241,7 @@ a.test-arrow:hover{
color: #999;
}

:target > code {
:target > code, :target > .in-band {
background: #FDFFD3;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub use core::ffi::c_void;
#[unstable(feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "27745")]
issue = "44930")]
pub use core::ffi::VaList;

mod c_str;
Expand Down
Loading