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 16 pull requests #58361

Merged
merged 36 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7cdcdb5
Update reference of rlibc crate to compiler-builtins crate
king6cong Jan 2, 2019
5581207
Remove outdated comment
king6cong Jan 9, 2019
87f5a98
Use `to_ne_bytes` for converting IPv4Address to octets
JakubOnderka Jan 18, 2019
b4d3c87
Tiny improvement to docs for `core::convert`.
icefoxen Jan 26, 2019
bd4df0c
Add Cargo.lock automatically adding message
h-michael Feb 4, 2019
4deb595
display sugared return types for async functions
euclio Feb 5, 2019
1d05f81
Add #[must_use] message to Fn* traits
taiki-e Feb 7, 2019
541503a
std::sys::unix::stdio: explain why we do into_raw
RalfJung Feb 8, 2019
b962ecc
Cleanup JS a bit
GuillaumeGomez Feb 8, 2019
caf7126
Some writing improvement, conciseness of intro
hayekr Feb 9, 2019
66adf52
miri: give non-generic functions a stable address
RalfJung Feb 9, 2019
a01efbc
operand-to-place copies should never be overlapping
RalfJung Feb 9, 2019
3a3691f
when there are multiple filenames, print what got interpreted as 2nd …
RalfJung Feb 10, 2019
adb3300
rpath computation: explain why we pop()
RalfJung Feb 10, 2019
55f90c7
Fix failing tidy (line endings on Windows)
petrochenkov Feb 10, 2019
74e97f3
Add trait alias support in rustdoc
GuillaumeGomez Feb 5, 2019
29354dd
Add style for trait aliases
GuillaumeGomez Feb 7, 2019
c20357a
Add trait aliases to js types
GuillaumeGomez Feb 7, 2019
eaf81c2
miri value visitor: use in macro
RalfJung Feb 10, 2019
b1d82ac
Remove spotlight for trait aliases and fix nits
GuillaumeGomez Feb 10, 2019
e917f8b
Rollup merge of #57259 - king6cong:master, r=alexcrichton
GuillaumeGomez Feb 10, 2019
d9f9780
Rollup merge of #57740 - JakubOnderka:ipv4addr-to_ne_bytes, r=scottmcm
GuillaumeGomez Feb 10, 2019
82e051b
Rollup merge of #57926 - icefoxen:test-doc-pr, r=frewsxcv
GuillaumeGomez Feb 10, 2019
a74e4f7
Rollup merge of #58157 - h-michael:cargo-lock, r=alexcrichton
GuillaumeGomez Feb 10, 2019
cdbd07c
Rollup merge of #58203 - euclio:rustdoc-async, r=GuillaumeGomez
GuillaumeGomez Feb 10, 2019
adf516b
Rollup merge of #58243 - GuillaumeGomez:trait-alias-docs, r=Manishearth
GuillaumeGomez Feb 10, 2019
112629b
Rollup merge of #58262 - taiki-e:must_use, r=estebank
GuillaumeGomez Feb 10, 2019
d59ca59
Rollup merge of #58295 - RalfJung:stdio, r=alexcrichton
GuillaumeGomez Feb 10, 2019
d5a8b24
Rollup merge of #58297 - GuillaumeGomez:cleanup-js, r=QuietMisdreavus
GuillaumeGomez Feb 10, 2019
f4e7bc5
Rollup merge of #58317 - hayekr:patch-1, r=frewsxcv
GuillaumeGomez Feb 10, 2019
a09aa0f
Rollup merge of #58324 - RalfJung:fn-ptr-eq, r=oli-obk
GuillaumeGomez Feb 10, 2019
c3aa847
Rollup merge of #58332 - RalfJung:miri-copy-nonoverlapping, r=oli-obk
GuillaumeGomez Feb 10, 2019
53e9a65
Rollup merge of #58345 - RalfJung:2nd-filename, r=matthewjasper
GuillaumeGomez Feb 10, 2019
9ccfb74
Rollup merge of #58346 - RalfJung:rpath-pop, r=Mark-Simulacrum
GuillaumeGomez Feb 10, 2019
585f9a7
Rollup merge of #58350 - petrochenkov:embed, r=frewsxcv
GuillaumeGomez Feb 10, 2019
d792cef
Rollup merge of #58352 - RalfJung:macro, r=oli-obk
GuillaumeGomez Feb 10, 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
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
7 changes: 3 additions & 4 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Unstable features

Rustdoc is under active development, and like the Rust compiler, some features are only available
on the nightly releases. Some of these are new and need some more testing before they're able to get
released to the world at large, and some of them are tied to features in the Rust compiler that are
themselves unstable. Several features here require a matching `#![feature(...)]` attribute to
on nightly releases. Some of these features are new and need some more testing before they're able to be
released to the world at large, and some of them are tied to features in the Rust compiler that are unstable. Several features here require a matching `#![feature(...)]` attribute to
enable, and thus are more fully documented in the [Unstable Book]. Those sections will link over
there as necessary.

Expand Down Expand Up @@ -428,4 +427,4 @@ $ rustdoc src/lib.rs --test -Z unstable-options --persist-doctests target/rustdo

This flag allows you to keep doctest executables around after they're compiled or run.
Usually, rustdoc will immediately discard a compiled doctest after it's been tested, but
with this option, you can keep those binaries around for farther testing.
with this option, you can keep those binaries around for farther testing.
5 changes: 4 additions & 1 deletion src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
//! [`TryFrom<T>`][`TryFrom`] rather than [`Into<U>`][`Into`] or [`TryInto<U>`][`TryInto`],
//! as [`From`] and [`TryFrom`] provide greater flexibility and offer
//! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a
//! blanket implementation in the standard library.
//! blanket implementation in the standard library. However, there are some cases
//! where this is not possible, such as creating conversions into a type defined
//! outside your library, so implementing [`Into`] instead of [`From`] is
//! sometimes necessary.
//!
//! # Generic Implementations
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! often generated by LLVM. Additionally, this library can make explicit
//! calls to these functions. Their signatures are the same as found in C.
//! These functions are often provided by the system libc, but can also be
//! provided by the [rlibc crate](https://crates.io/crates/rlibc).
//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
//!
//! * `rust_begin_panic` - This function takes four arguments, a
//! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/ops/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
label="expected an `Fn<{Args}>` closure, found `{Self}`",
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use]
#[must_use = "closures are lazy and do nothing unless called"]
pub trait Fn<Args> : FnMut<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait Fn<Args> : FnMut<Args> {
label="expected an `FnMut<{Args}>` closure, found `{Self}`",
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use]
#[must_use = "closures are lazy and do nothing unless called"]
pub trait FnMut<Args> : FnOnce<Args> {
/// Performs the call operation.
#[unstable(feature = "fn_traits", issue = "29625")]
Expand Down Expand Up @@ -220,7 +220,7 @@ pub trait FnMut<Args> : FnOnce<Args> {
label="expected an `FnOnce<{Args}>` closure, found `{Self}`",
)]
#[fundamental] // so that regex can rely that `&str: !FnMut`
#[must_use]
#[must_use = "closures are lazy and do nothing unless called"]
pub trait FnOnce<Args> {
/// The returned type after the call operator is used.
#[stable(feature = "fn_once_output", since = "1.12.0")]
Expand Down
31 changes: 23 additions & 8 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use self::pointer::{Pointer, PointerArithmetic};
use std::fmt;
use crate::mir;
use crate::hir::def_id::DefId;
use crate::ty::{self, TyCtxt, Instance};
use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind};
use crate::ty::layout::{self, Size};
use std::io;
use crate::rustc_serialize::{Encoder, Decodable, Encodable};
Expand Down Expand Up @@ -318,14 +318,29 @@ impl<'tcx> AllocMap<'tcx> {
id
}

/// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
/// by the linker and functions can be duplicated across crates.
/// We thus generate a new `AllocId` for every mention of a function. This means that
/// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
let id = self.reserve();
self.id_to_kind.insert(id, AllocKind::Function(instance));
id
// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
// by the linker (we set the "unnamed_addr" attribute for LLVM) and functions can be
// duplicated across crates.
// We thus generate a new `AllocId` for every mention of a function. This means that
// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
// However, formatting code relies on function identity (see #58320), so we only do
// this for generic functions. Lifetime parameters are ignored.
let is_generic = instance.substs.into_iter().any(|kind| {
match kind.unpack() {
UnpackedKind::Lifetime(_) => false,
_ => true,
}
});
if is_generic {
// Get a fresh ID
let id = self.reserve();
self.id_to_kind.insert(id, AllocKind::Function(instance));
id
} else {
// Deduplicate
self.intern(AllocKind::Function(instance))
}
}

/// Returns `None` in case the `AllocId` is dangling. An `EvalContext` can still have a
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String

let cwd = env::current_dir().unwrap();
let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or_else(|_| cwd.join(lib));
lib.pop();
lib.pop(); // strip filename
let mut output = cwd.join(&config.out_filename);
output.pop();
output.pop(); // strip filename
let output = fs::canonicalize(&output).unwrap_or(output);
let relative = path_relative_from(&lib, &output).unwrap_or_else(||
panic!("couldn't create relative path from {:?} to {:?}", output, lib));
Expand Down
10 changes: 9 additions & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,15 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
early_error(sopts.error_format, "no input filename given");
}
1 => panic!("make_input should have provided valid inputs"),
_ => early_error(sopts.error_format, "multiple input filenames provided"),
_ =>
early_error(
sopts.error_format,
&format!(
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
matches.free[0],
matches.free[1],
),
)
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ where
let src = match self.try_read_immediate(src)? {
Ok(src_val) => {
// Yay, we got a value that we can write directly.
// FIXME: Add a check to make sure that if `src` is indirect,
// it does not overlap with `dest`.
return self.write_immediate_no_validate(src_val, dest);
}
Err(mplace) => mplace,
Expand All @@ -836,7 +838,8 @@ where
self.memory.copy(
src_ptr, src_align,
dest_ptr, dest_align,
dest.layout.size, false
dest.layout.size,
/*nonoverlapping*/ true,
)?;

Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Value<'a, 'mir, 'tcx, M>
}

macro_rules! make_value_visitor {
($visitor_trait_name:ident, $($mutability:ident)*) => {
($visitor_trait_name:ident, $($mutability:ident)?) => {
// How to traverse a value and what to do when we are at the leaves.
pub trait $visitor_trait_name<'a, 'mir, 'tcx: 'mir+'a, M: Machine<'a, 'mir, 'tcx>>: Sized {
type V: Value<'a, 'mir, 'tcx, M>;

/// The visitor must have an `EvalContext` in it.
fn ecx(&$($mutability)* self)
-> &$($mutability)* EvalContext<'a, 'mir, 'tcx, M>;
fn ecx(&$($mutability)? self)
-> &$($mutability)? EvalContext<'a, 'mir, 'tcx, M>;

// Recursive actions, ready to be overloaded.
/// Visit the given value, dispatching as appropriate to more specialized visitors.
Expand Down
75 changes: 71 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ pub enum ItemEnum {
StaticItem(Static),
ConstantItem(Constant),
TraitItem(Trait),
TraitAliasItem(TraitAlias),
ImplItem(Impl),
/// A method signature only. Used for required methods in traits (ie,
/// non-default-methods).
Expand Down Expand Up @@ -554,6 +555,7 @@ impl ItemEnum {
ItemEnum::TyMethodItem(ref i) => &i.generics,
ItemEnum::MethodItem(ref i) => &i.generics,
ItemEnum::ForeignFunctionItem(ref f) => &f.generics,
ItemEnum::TraitAliasItem(ref ta) => &ta.generics,
_ => return None,
})
}
Expand Down Expand Up @@ -603,6 +605,7 @@ impl Clean<Item> for doctree::Module {
items.extend(self.impls.iter().flat_map(|x| x.clean(cx)));
items.extend(self.macros.iter().map(|x| x.clean(cx)));
items.extend(self.proc_macros.iter().map(|x| x.clean(cx)));
items.extend(self.trait_aliases.iter().map(|x| x.clean(cx)));

// determine if we should display the inner contents or
// the outer `mod` item for the source code.
Expand Down Expand Up @@ -1724,6 +1727,30 @@ impl FnDecl {
pub fn self_type(&self) -> Option<SelfTy> {
self.inputs.values.get(0).and_then(|v| v.to_self())
}

/// Returns the sugared return type for an async function.
///
/// For example, if the return type is `impl std::future::Future<Output = i32>`, this function
/// will return `i32`.
///
/// # Panics
///
/// This function will panic if the return type does not match the expected sugaring for async
/// functions.
pub fn sugared_async_return_type(&self) -> FunctionRetTy {
match &self.output {
FunctionRetTy::Return(Type::ImplTrait(bounds)) => {
match &bounds[0] {
GenericBound::TraitBound(PolyTrait { trait_, .. }, ..) => {
let bindings = trait_.bindings().unwrap();
FunctionRetTy::Return(bindings[0].ty.clone())
}
_ => panic!("unexpected desugaring of async function"),
}
}
_ => panic!("unexpected desugaring of async function"),
}
}
}

#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)]
Expand Down Expand Up @@ -1885,13 +1912,38 @@ impl Clean<Item> for doctree::Trait {
items: self.items.clean(cx),
generics: self.generics.clean(cx),
bounds: self.bounds.clean(cx),
is_spotlight: is_spotlight,
is_spotlight,
is_auto: self.is_auto.clean(cx),
}),
}
}
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitAlias {
pub generics: Generics,
pub bounds: Vec<GenericBound>,
}

impl Clean<Item> for doctree::TraitAlias {
fn clean(&self, cx: &DocContext) -> Item {
let attrs = self.attrs.clean(cx);
Item {
name: Some(self.name.clean(cx)),
attrs,
source: self.whence.clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
inner: TraitAliasItem(TraitAlias {
generics: self.generics.clean(cx),
bounds: self.bounds.clean(cx),
}),
}
}
}

impl Clean<bool> for hir::IsAuto {
fn clean(&self, _: &DocContext) -> bool {
match *self {
Expand Down Expand Up @@ -2223,6 +2275,7 @@ pub enum TypeKind {
Macro,
Attr,
Derive,
TraitAlias,
}

pub trait GetDefId {
Expand Down Expand Up @@ -2282,6 +2335,21 @@ impl Type {
_ => None,
}
}

pub fn bindings(&self) -> Option<&[TypeBinding]> {
match *self {
ResolvedPath { ref path, .. } => {
path.segments.last().and_then(|seg| {
if let GenericArgs::AngleBracketed { ref bindings, .. } = seg.args {
Some(&**bindings)
} else {
None
}
})
}
_ => None
}
}
}

impl GetDefId for Type {
Expand Down Expand Up @@ -3819,10 +3887,9 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
MacroKind::Derive => (i, TypeKind::Derive),
MacroKind::ProcMacroStub => unreachable!(),
},
Def::TraitAlias(i) => (i, TypeKind::TraitAlias),
Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
Def::SelfTy(_, Some(impl_def_id)) => {
return impl_def_id
}
Def::SelfTy(_, Some(impl_def_id)) => return impl_def_id,
_ => return def.def_id()
};
if did.is_local() { return did }
Expand Down
44 changes: 29 additions & 15 deletions src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Module {
pub foreigns: Vec<hir::ForeignMod>,
pub macros: Vec<Macro>,
pub proc_macros: Vec<ProcMacro>,
pub trait_aliases: Vec<TraitAlias>,
pub is_crate: bool,
}

Expand All @@ -53,21 +54,22 @@ impl Module {
where_inner: syntax_pos::DUMMY_SP,
attrs : hir::HirVec::new(),
extern_crates: Vec::new(),
imports : Vec::new(),
structs : Vec::new(),
unions : Vec::new(),
enums : Vec::new(),
fns : Vec::new(),
mods : Vec::new(),
typedefs : Vec::new(),
existentials: Vec::new(),
statics : Vec::new(),
constants : Vec::new(),
traits : Vec::new(),
impls : Vec::new(),
foreigns : Vec::new(),
macros : Vec::new(),
proc_macros: Vec::new(),
imports : Vec::new(),
structs : Vec::new(),
unions : Vec::new(),
enums : Vec::new(),
fns : Vec::new(),
mods : Vec::new(),
typedefs : Vec::new(),
existentials: Vec::new(),
statics : Vec::new(),
constants : Vec::new(),
traits : Vec::new(),
impls : Vec::new(),
foreigns : Vec::new(),
macros : Vec::new(),
proc_macros: Vec::new(),
trait_aliases: Vec::new(),
is_crate : false,
}
}
Expand Down Expand Up @@ -208,6 +210,18 @@ pub struct Trait {
pub depr: Option<attr::Deprecation>,
}

pub struct TraitAlias {
pub name: Name,
pub generics: hir::Generics,
pub bounds: hir::HirVec<hir::GenericBound>,
pub attrs: hir::HirVec<ast::Attribute>,
pub id: ast::NodeId,
pub whence: Span,
pub vis: hir::Visibility,
pub stab: Option<attr::Stability>,
pub depr: Option<attr::Deprecation>,
}

#[derive(Debug)]
pub struct Impl {
pub unsafety: hir::Unsafety,
Expand Down
Loading