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:
commit
d55f3e9f1d
16 changed files with 203 additions and 41 deletions
|
@ -806,13 +806,42 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
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
|
||||
K: Borrow<Q>,
|
||||
Q: Ord,
|
||||
{
|
||||
match search::search_tree(self.root.as_mut(), key) {
|
||||
Found(handle) => Some(
|
||||
OccupiedEntry { handle, length: &mut self.length, _marker: PhantomData }.remove(),
|
||||
OccupiedEntry { handle, length: &mut self.length, _marker: PhantomData }
|
||||
.remove_entry(),
|
||||
),
|
||||
GoDown(_) => None,
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ use crate::raw_vec::RawVec;
|
|||
/// ```
|
||||
///
|
||||
/// 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`].
|
||||
///
|
||||
/// # Capacity and reallocation
|
||||
|
|
|
@ -6,6 +6,7 @@ use rustc_data_structures::sharded::{self, Sharded};
|
|||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -677,18 +678,33 @@ impl DepGraph {
|
|||
} else {
|
||||
match dep_dep_node.kind {
|
||||
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
|
||||
// just fail to mark green.
|
||||
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
|
||||
/// incremental directory for later re-use. The primary example are
|
||||
/// the object files that we save for each partition at code
|
||||
|
|
|
@ -4,7 +4,7 @@ use super::*;
|
|||
|
||||
/// 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
|
||||
///
|
||||
/// ```text
|
||||
|
@ -82,7 +82,7 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
|
|||
|
||||
/// 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
|
||||
///
|
||||
///
|
||||
|
|
|
@ -397,6 +397,7 @@ E0718: include_str!("./error_codes/E0718.md"),
|
|||
E0720: include_str!("./error_codes/E0720.md"),
|
||||
E0723: include_str!("./error_codes/E0723.md"),
|
||||
E0725: include_str!("./error_codes/E0725.md"),
|
||||
E0727: include_str!("./error_codes/E0727.md"),
|
||||
E0728: include_str!("./error_codes/E0728.md"),
|
||||
E0729: include_str!("./error_codes/E0729.md"),
|
||||
E0730: include_str!("./error_codes/E0730.md"),
|
||||
|
@ -607,6 +608,5 @@ E0746: include_str!("./error_codes/E0746.md"),
|
|||
E0722, // Malformed `#[optimize]` attribute
|
||||
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
|
||||
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
|
||||
E0727, // `async` generators are not yet supported
|
||||
E0739, // invalid track_caller application/syntax
|
||||
}
|
||||
|
|
26
src/librustc_error_codes/error_codes/E0727.md
Normal file
26
src/librustc_error_codes/error_codes/E0727.md
Normal 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;
|
||||
};
|
||||
```
|
|
@ -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
|
||||
// visit each node at most once.
|
||||
for &item in cx.tcx.item_children(did).iter() {
|
||||
let def_id = item.res.def_id();
|
||||
if item.vis == ty::Visibility::Public {
|
||||
if did == def_id || !visited.insert(def_id) {
|
||||
continue;
|
||||
if let Some(def_id) = item.res.mod_def_id() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
pub enum Visibility {
|
||||
Public,
|
||||
|
|
|
@ -570,14 +570,7 @@ pub fn resolve_type(cx: &DocContext<'_>, path: Path, id: hir::HirId) -> Type {
|
|||
}
|
||||
|
||||
let is_generic = match path.res {
|
||||
Res::PrimTy(p) => match 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::PrimTy(p) => return Primitive(PrimitiveType::from(p)),
|
||||
Res::SelfTy(..) if path.segments.len() == 1 => {
|
||||
return Generic(kw::SelfUpper.to_string());
|
||||
}
|
||||
|
|
|
@ -1171,11 +1171,14 @@ impl clean::ImportSource {
|
|||
display_fn(move |f| match self.did {
|
||||
Some(did) => resolved_path(f, did, &self.path, true, false),
|
||||
_ => {
|
||||
for (i, seg) in self.path.segments.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, "::")?
|
||||
}
|
||||
write!(f, "{}", seg.name)?;
|
||||
for seg in &self.path.segments[..self.path.segments.len() - 1] {
|
||||
write!(f, "{}::", seg.name)?;
|
||||
}
|
||||
let name = self.path.last_name();
|
||||
if let hir::def::Res::PrimTy(p) = self.path.res {
|
||||
primitive_link(f, PrimitiveType::from(p), name)?;
|
||||
} else {
|
||||
write!(f, "{}", name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use syntax::token::{self, Token};
|
|||
pub fn render_with_highlighting(
|
||||
src: &str,
|
||||
class: Option<&str>,
|
||||
extension: Option<&str>,
|
||||
playground_button: Option<&str>,
|
||||
tooltip: Option<(&str, &str)>,
|
||||
) -> String {
|
||||
debug!("highlighting: ================\n{}\n==============", src);
|
||||
|
@ -58,10 +58,7 @@ pub fn render_with_highlighting(
|
|||
Ok(highlighted_source) => {
|
||||
write_header(class, &mut out).unwrap();
|
||||
write!(out, "{}", highlighted_source).unwrap();
|
||||
if let Some(extension) = extension {
|
||||
write!(out, "{}", extension).unwrap();
|
||||
}
|
||||
write_footer(&mut out).unwrap();
|
||||
write_footer(&mut out, playground_button).unwrap();
|
||||
}
|
||||
Err(()) => {
|
||||
// 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(""))
|
||||
}
|
||||
|
||||
fn write_footer(out: &mut dyn Write) -> io::Result<()> {
|
||||
write!(out, "</pre></div>\n")
|
||||
fn write_footer(out: &mut dyn Write, playground_button: Option<&str>) -> io::Result<()> {
|
||||
write!(out, "</pre>{}</div>\n", if let Some(button) = playground_button { button } else { "" })
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ summary {
|
|||
outline: none;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
code, pre, a.test-arrow {
|
||||
font-family: "Source Code Pro", monospace;
|
||||
}
|
||||
.docblock code, .docblock-short code {
|
||||
|
@ -305,6 +305,7 @@ nav.sub {
|
|||
.rustdoc:not(.source) .example-wrap {
|
||||
display: inline-flex;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.example-wrap {
|
||||
|
@ -878,6 +879,7 @@ a.test-arrow {
|
|||
font-size: 130%;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
z-index: 1;
|
||||
}
|
||||
a.test-arrow:hover{
|
||||
text-decoration: none;
|
||||
|
|
|
@ -76,7 +76,7 @@ pub use core::time::Duration;
|
|||
/// [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
|
||||
/// [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
|
||||
/// [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
|
||||
|
@ -157,7 +157,7 @@ pub struct Instant(time::Instant);
|
|||
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
|
||||
/// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html
|
||||
/// [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
|
||||
///
|
||||
/// **Disclaimer:** These system calls might change over time.
|
||||
|
|
13
src/test/incremental/issue-62649-path-collisions-happen.rs
Normal file
13
src/test/incremental/issue-62649-path-collisions-happen.rs
Normal 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() {}
|
8
src/test/rustdoc/auxiliary/primitive-reexport.rs
Normal file
8
src/test/rustdoc/auxiliary/primitive-reexport.rs
Normal 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;
|
||||
}
|
28
src/test/rustdoc/primitive-reexport.rs
Normal file
28
src/test/rustdoc/primitive-reexport.rs
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue