1
Fork 0

Auto merge of #68625 - JohnTitor:rollup-20pfcru, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #68289 (Don't ICE on path-collision in dep-graph)
 - #68378 (Add BTreeMap::remove_entry)
 - #68553 (Fix run button positionning in case of scrolling)
 - #68556 (rustdoc: Fix re-exporting primitive types)
 - #68582 (Add E0727 long explanation)
 - #68592 (fix: typo in vec.rs)
 - #68619 (Fix a few spelling mistakes)
 - #68620 (Update links to WASI docs in time.rs module)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-01-29 01:28:55 +00:00
commit d55f3e9f1d
16 changed files with 203 additions and 41 deletions

View file

@ -806,13 +806,42 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
where
K: Borrow<Q>,
Q: Ord,
{
self.remove_entry(key).map(|(_, v)| v)
}
/// Removes a key from the map, returning the stored key and value if the key
/// was previously in the map.
///
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(btreemap_remove_entry)]
/// use std::collections::BTreeMap;
///
/// let mut map = BTreeMap::new();
/// map.insert(1, "a");
/// assert_eq!(map.remove_entry(&1), Some((1, "a")));
/// assert_eq!(map.remove_entry(&1), None);
/// ```
#[unstable(feature = "btreemap_remove_entry", issue = "66714")]
pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
where where
K: Borrow<Q>, K: Borrow<Q>,
Q: Ord, Q: Ord,
{ {
match search::search_tree(self.root.as_mut(), key) { match search::search_tree(self.root.as_mut(), key) {
Found(handle) => Some( Found(handle) => Some(
OccupiedEntry { handle, length: &mut self.length, _marker: PhantomData }.remove(), OccupiedEntry { handle, length: &mut self.length, _marker: PhantomData }
.remove_entry(),
), ),
GoDown(_) => None, GoDown(_) => None,
} }

View file

@ -176,7 +176,7 @@ use crate::raw_vec::RawVec;
/// ``` /// ```
/// ///
/// In Rust, it's more common to pass slices as arguments rather than vectors /// In Rust, it's more common to pass slices as arguments rather than vectors
/// when you just want to provide a read access. The same goes for [`String`] and /// when you just want to provide read access. The same goes for [`String`] and
/// [`&str`]. /// [`&str`].
/// ///
/// # Capacity and reallocation /// # Capacity and reallocation

View file

@ -6,6 +6,7 @@ use rustc_data_structures::sharded::{self, Sharded};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering}; use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
use rustc_errors::Diagnostic; use rustc_errors::Diagnostic;
use rustc_hir::def_id::DefId;
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
@ -677,18 +678,33 @@ impl DepGraph {
} else { } else {
match dep_dep_node.kind { match dep_dep_node.kind {
DepKind::Hir | DepKind::HirBody | DepKind::CrateMetadata => { DepKind::Hir | DepKind::HirBody | DepKind::CrateMetadata => {
if dep_dep_node.extract_def_id(tcx).is_none() { if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {
// The `DefPath` has corresponding node,
// and that node should have been marked
// either red or green in `data.colors`.
bug!(
"DepNode {:?} should have been \
pre-marked as red or green but wasn't.",
dep_dep_node
);
} else {
// This `DefPath` does not have a
// corresponding `DepNode` (e.g. a
// struct field), and the ` DefPath`
// collided with the `DefPath` of a
// proper item that existed in the
// previous compilation session.
//
// Since the given `DefPath` does not
// denote the item that previously
// existed, we just fail to mark green.
return None;
}
} else {
// If the node does not exist anymore, we // If the node does not exist anymore, we
// just fail to mark green. // just fail to mark green.
return None; return None;
} else {
// If the node does exist, it should have
// been pre-allocated.
bug!(
"DepNode {:?} should have been \
pre-allocated but wasn't.",
dep_dep_node
)
} }
} }
_ => { _ => {
@ -899,6 +915,11 @@ impl DepGraph {
} }
} }
fn def_id_corresponds_to_hir_dep_node(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
def_id.index == hir_id.owner
}
/// A "work product" is an intermediate result that we save into the /// A "work product" is an intermediate result that we save into the
/// incremental directory for later re-use. The primary example are /// incremental directory for later re-use. The primary example are
/// the object files that we save for each partition at code /// the object files that we save for each partition at code

View file

@ -4,7 +4,7 @@ use super::*;
/// Preorder traversal of a graph. /// Preorder traversal of a graph.
/// ///
/// Preorder traversal is when each node is visited before an of it's /// Preorder traversal is when each node is visited before any of its
/// successors /// successors
/// ///
/// ```text /// ```text
@ -82,7 +82,7 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
/// Postorder traversal of a graph. /// Postorder traversal of a graph.
/// ///
/// Postorder traversal is when each node is visited after all of it's /// Postorder traversal is when each node is visited after all of its
/// successors, except when the successor is only reachable by a back-edge /// successors, except when the successor is only reachable by a back-edge
/// ///
/// ///

View file

@ -397,6 +397,7 @@ E0718: include_str!("./error_codes/E0718.md"),
E0720: include_str!("./error_codes/E0720.md"), E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"), E0723: include_str!("./error_codes/E0723.md"),
E0725: include_str!("./error_codes/E0725.md"), E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"),
E0728: include_str!("./error_codes/E0728.md"), E0728: include_str!("./error_codes/E0728.md"),
E0729: include_str!("./error_codes/E0729.md"), E0729: include_str!("./error_codes/E0729.md"),
E0730: include_str!("./error_codes/E0730.md"), E0730: include_str!("./error_codes/E0730.md"),
@ -607,6 +608,5 @@ E0746: include_str!("./error_codes/E0746.md"),
E0722, // Malformed `#[optimize]` attribute E0722, // Malformed `#[optimize]` attribute
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
E0727, // `async` generators are not yet supported
E0739, // invalid track_caller application/syntax E0739, // invalid track_caller application/syntax
} }

View file

@ -0,0 +1,26 @@
A `yield` clause was used in an `async` context.
Example of erroneous code:
```compile_fail
#![feature(generators)]
let generator = || {
async {
yield;
}
};
```
Here, the `yield` keyword is used in an `async` block,
which is not yet supported.
To fix this error, you have to move `yield` out of the `async` block:
```
#![feature(generators)]
let generator = || {
yield;
};
```

View file

@ -445,12 +445,41 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
// two namespaces, so the target may be listed twice. Make sure we only // two namespaces, so the target may be listed twice. Make sure we only
// visit each node at most once. // visit each node at most once.
for &item in cx.tcx.item_children(did).iter() { for &item in cx.tcx.item_children(did).iter() {
let def_id = item.res.def_id();
if item.vis == ty::Visibility::Public { if item.vis == ty::Visibility::Public {
if did == def_id || !visited.insert(def_id) { if let Some(def_id) = item.res.mod_def_id() {
continue; if did == def_id || !visited.insert(def_id) {
continue;
}
} }
if let Some(i) = try_inline(cx, item.res, item.ident.name, None, visited) { if let Res::PrimTy(p) = item.res {
// Primitive types can't be inlined so generate an import instead.
items.push(clean::Item {
name: None,
attrs: clean::Attributes::default(),
source: clean::Span::empty(),
def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
visibility: clean::Public,
stability: None,
deprecation: None,
inner: clean::ImportItem(clean::Import::Simple(
item.ident.to_string(),
clean::ImportSource {
path: clean::Path {
global: false,
res: item.res,
segments: vec![clean::PathSegment {
name: clean::PrimitiveType::from(p).as_str().to_string(),
args: clean::GenericArgs::AngleBracketed {
args: Vec::new(),
bindings: Vec::new(),
},
}],
},
did: None,
},
)),
});
} else if let Some(i) = try_inline(cx, item.res, item.ident.name, None, visited) {
items.extend(i) items.extend(i)
} }
} }

View file

@ -1290,6 +1290,19 @@ impl From<ast::FloatTy> for PrimitiveType {
} }
} }
impl From<hir::PrimTy> for PrimitiveType {
fn from(prim_ty: hir::PrimTy) -> PrimitiveType {
match prim_ty {
hir::PrimTy::Int(int_ty) => int_ty.into(),
hir::PrimTy::Uint(uint_ty) => uint_ty.into(),
hir::PrimTy::Float(float_ty) => float_ty.into(),
hir::PrimTy::Str => PrimitiveType::Str,
hir::PrimTy::Bool => PrimitiveType::Bool,
hir::PrimTy::Char => PrimitiveType::Char,
}
}
}
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub enum Visibility { pub enum Visibility {
Public, Public,

View file

@ -570,14 +570,7 @@ pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
} }
let is_generic = match path.res { let is_generic = match path.res {
Res::PrimTy(p) => match p { Res::PrimTy(p) => return Primitive(PrimitiveType::from(p)),
hir::PrimTy::Str => return Primitive(PrimitiveType::Str),
hir::PrimTy::Bool => return Primitive(PrimitiveType::Bool),
hir::PrimTy::Char => return Primitive(PrimitiveType::Char),
hir::PrimTy::Int(int_ty) => return Primitive(int_ty.into()),
hir::PrimTy::Uint(uint_ty) => return Primitive(uint_ty.into()),
hir::PrimTy::Float(float_ty) => return Primitive(float_ty.into()),
},
Res::SelfTy(..) if path.segments.len() == 1 => { Res::SelfTy(..) if path.segments.len() == 1 => {
return Generic(kw::SelfUpper.to_string()); return Generic(kw::SelfUpper.to_string());
} }

View file

@ -1171,11 +1171,14 @@ impl clean::ImportSource {
display_fn(move |f| match self.did { display_fn(move |f| match self.did {
Some(did) => resolved_path(f, did, &self.path, true, false), Some(did) => resolved_path(f, did, &self.path, true, false),
_ => { _ => {
for (i, seg) in self.path.segments.iter().enumerate() { for seg in &self.path.segments[..self.path.segments.len() - 1] {
if i > 0 { write!(f, "{}::", seg.name)?;
write!(f, "::")? }
} let name = self.path.last_name();
write!(f, "{}", seg.name)?; if let hir::def::Res::PrimTy(p) = self.path.res {
primitive_link(f, PrimitiveType::from(p), name)?;
} else {
write!(f, "{}", name)?;
} }
Ok(()) Ok(())
} }

View file

@ -22,7 +22,7 @@ use syntax::token::{self, Token};
pub fn render_with_highlighting( pub fn render_with_highlighting(
src: &str, src: &str,
class: Option<&str>, class: Option<&str>,
extension: Option<&str>, playground_button: Option<&str>,
tooltip: Option<(&str, &str)>, tooltip: Option<(&str, &str)>,
) -> String { ) -> String {
debug!("highlighting: ================\n{}\n==============", src); debug!("highlighting: ================\n{}\n==============", src);
@ -58,10 +58,7 @@ pub fn render_with_highlighting(
Ok(highlighted_source) => { Ok(highlighted_source) => {
write_header(class, &mut out).unwrap(); write_header(class, &mut out).unwrap();
write!(out, "{}", highlighted_source).unwrap(); write!(out, "{}", highlighted_source).unwrap();
if let Some(extension) = extension { write_footer(&mut out, playground_button).unwrap();
write!(out, "{}", extension).unwrap();
}
write_footer(&mut out).unwrap();
} }
Err(()) => { Err(()) => {
// If errors are encountered while trying to highlight, just emit // If errors are encountered while trying to highlight, just emit
@ -433,6 +430,6 @@ fn write_header(class: Option<&str>, out: &mut dyn Write) -> io::Result<()> {
write!(out, "<div class=\"example-wrap\"><pre class=\"rust {}\">\n", class.unwrap_or("")) write!(out, "<div class=\"example-wrap\"><pre class=\"rust {}\">\n", class.unwrap_or(""))
} }
fn write_footer(out: &mut dyn Write) -> io::Result<()> { fn write_footer(out: &mut dyn Write, playground_button: Option<&str>) -> io::Result<()> {
write!(out, "</pre></div>\n") write!(out, "</pre>{}</div>\n", if let Some(button) = playground_button { button } else { "" })
} }

View file

@ -136,7 +136,7 @@ summary {
outline: none; outline: none;
} }
code, pre { code, pre, a.test-arrow {
font-family: "Source Code Pro", monospace; font-family: "Source Code Pro", monospace;
} }
.docblock code, .docblock-short code { .docblock code, .docblock-short code {
@ -305,6 +305,7 @@ nav.sub {
.rustdoc:not(.source) .example-wrap { .rustdoc:not(.source) .example-wrap {
display: inline-flex; display: inline-flex;
margin-bottom: 10px; margin-bottom: 10px;
position: relative;
} }
.example-wrap { .example-wrap {
@ -878,6 +879,7 @@ a.test-arrow {
font-size: 130%; font-size: 130%;
top: 5px; top: 5px;
right: 5px; right: 5px;
z-index: 1;
} }
a.test-arrow:hover{ a.test-arrow:hover{
text-decoration: none; text-decoration: none;

View file

@ -76,7 +76,7 @@ pub use core::time::Duration;
/// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter
/// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get /// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get
/// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime
/// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html
/// [clock_time_get (Monotonic Clock)]: https://nuxi.nl/cloudabi/#clock_time_get /// [clock_time_get (Monotonic Clock)]: https://nuxi.nl/cloudabi/#clock_time_get
@ -157,7 +157,7 @@ pub struct Instant(time::Instant);
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
/// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html /// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html
/// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime /// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime
/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get /// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get
/// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
/// ///
/// **Disclaimer:** These system calls might change over time. /// **Disclaimer:** These system calls might change over time.

View file

@ -0,0 +1,13 @@
// revisions: rpass1 rpass2
#[cfg(rpass1)]
pub trait Something {
fn foo();
}
#[cfg(rpass2)]
pub struct Something {
pub foo: u8,
}
fn main() {}

View file

@ -0,0 +1,8 @@
// compile-flags: --emit metadata --crate-type lib --edition 2018
#![crate_name = "foo"]
pub mod bar {
pub use bool;
pub use char as my_char;
}

View file

@ -0,0 +1,28 @@
// aux-build: primitive-reexport.rs
// compile-flags:--extern foo --edition 2018
#![crate_name = "bar"]
// @has bar/p/index.html
// @has - '//code' 'pub use bool;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'bool'
// @has - '//code' 'pub use char as my_char;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
pub mod p {
pub use foo::bar::*;
}
// @has bar/baz/index.html
// @has - '//code' 'pub use bool;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'bool'
// @has - '//code' 'pub use char as my_char;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char'
pub use foo::bar as baz;
// @has bar/index.html
// @has - '//code' 'pub use str;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html"]' 'str'
// @has - '//code' 'pub use i32 as my_i32;'
// @has - '//code/a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html"]' 'i32'
pub use str;
pub use i32 as my_i32;