mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
Auto merge of #110648 - Dylan-DPC:rollup-em3ovcq, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #110333 (rustc_metadata: Split `children` into multiple tables) - #110501 (rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence) - #110608 (Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and `&[u8]`) - #110632 (Panic instead of truncating if the incremental on-disk cache is too big) - #110633 (More `mem::take` in `library`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
fec9adcdbc
@ -876,16 +876,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
variant_did,
|
||||
ctor,
|
||||
data.discr,
|
||||
self.root
|
||||
.tables
|
||||
.children
|
||||
.get(self, index)
|
||||
.expect("fields are not encoded for a variant")
|
||||
.decode(self)
|
||||
.map(|index| ty::FieldDef {
|
||||
did: self.local_def_id(index),
|
||||
name: self.item_name(index),
|
||||
vis: self.get_visibility(index),
|
||||
self.get_associated_item_or_field_def_ids(index)
|
||||
.map(|did| ty::FieldDef {
|
||||
did,
|
||||
name: self.item_name(did.index),
|
||||
vis: self.get_visibility(did.index),
|
||||
})
|
||||
.collect(),
|
||||
adt_kind,
|
||||
@ -910,7 +905,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
let variants = if let ty::AdtKind::Enum = adt_kind {
|
||||
self.root
|
||||
.tables
|
||||
.children
|
||||
.module_children_non_reexports
|
||||
.get(self, item_id)
|
||||
.expect("variants are not encoded for an enum")
|
||||
.decode(self)
|
||||
@ -1022,11 +1017,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
}
|
||||
} else {
|
||||
// Iterate over all children.
|
||||
for child_index in self.root.tables.children.get(self, id).unwrap().decode(self) {
|
||||
// FIXME: Do not encode RPITITs as a part of this list.
|
||||
if self.root.tables.opt_rpitit_info.get(self, child_index).is_none() {
|
||||
yield self.get_mod_child(child_index, sess);
|
||||
}
|
||||
let non_reexports = self.root.tables.module_children_non_reexports.get(self, id);
|
||||
for child_index in non_reexports.unwrap().decode(self) {
|
||||
yield self.get_mod_child(child_index, sess);
|
||||
}
|
||||
|
||||
let reexports = self.root.tables.module_children_reexports.get(self, id);
|
||||
@ -1058,17 +1051,16 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
.map_or(false, |ident| ident.name == kw::SelfLower)
|
||||
}
|
||||
|
||||
fn get_associated_item_def_ids(
|
||||
fn get_associated_item_or_field_def_ids(
|
||||
self,
|
||||
id: DefIndex,
|
||||
sess: &'a Session,
|
||||
) -> impl Iterator<Item = DefId> + 'a {
|
||||
self.root
|
||||
.tables
|
||||
.children
|
||||
.associated_item_or_field_def_ids
|
||||
.get(self, id)
|
||||
.expect("associated items not encoded for an item")
|
||||
.decode((self, sess))
|
||||
.unwrap_or_else(|| self.missing("associated_item_or_field_def_ids", id))
|
||||
.decode(self)
|
||||
.map(move |child_index| self.local_def_id(child_index))
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ provide! { tcx, def_id, other, cdata,
|
||||
tcx.calculate_dtor(def_id, |_,_| Ok(()))
|
||||
}
|
||||
associated_item_def_ids => {
|
||||
tcx.arena.alloc_from_iter(cdata.get_associated_item_def_ids(def_id.index, tcx.sess))
|
||||
tcx.arena.alloc_from_iter(cdata.get_associated_item_or_field_def_ids(def_id.index))
|
||||
}
|
||||
associated_item => { cdata.get_associated_item(def_id.index, tcx.sess) }
|
||||
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
|
||||
|
@ -1367,7 +1367,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
|
||||
if adt_def.is_enum() {
|
||||
let module_children = tcx.module_children_non_reexports(local_def_id);
|
||||
record_array!(self.tables.children[def_id] <-
|
||||
record_array!(self.tables.module_children_non_reexports[def_id] <-
|
||||
module_children.iter().map(|def_id| def_id.local_def_index));
|
||||
} else {
|
||||
// For non-enum, there is only one variant, and its def_id is the adt's.
|
||||
@ -1385,7 +1385,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
record!(self.tables.variant_data[variant.def_id] <- data);
|
||||
|
||||
self.tables.constness.set_some(variant.def_id.index, hir::Constness::Const);
|
||||
record_array!(self.tables.children[variant.def_id] <- variant.fields.iter().map(|f| {
|
||||
record_array!(self.tables.associated_item_or_field_def_ids[variant.def_id] <- variant.fields.iter().map(|f| {
|
||||
assert!(f.did.is_local());
|
||||
f.did.index
|
||||
}));
|
||||
@ -1415,7 +1415,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
record!(self.tables.expn_that_defined[def_id] <- tcx.expn_that_defined(local_def_id));
|
||||
} else {
|
||||
let non_reexports = tcx.module_children_non_reexports(local_def_id);
|
||||
record_array!(self.tables.children[def_id] <-
|
||||
record_array!(self.tables.module_children_non_reexports[def_id] <-
|
||||
non_reexports.iter().map(|def_id| def_id.local_def_index));
|
||||
|
||||
record_defaulted_array!(self.tables.module_children_reexports[def_id] <-
|
||||
@ -1617,7 +1617,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
debug!("EncodeContext::encode_info_for_item({:?})", def_id);
|
||||
|
||||
let record_associated_item_def_ids = |this: &mut Self, def_ids: &[DefId]| {
|
||||
record_array!(this.tables.children[def_id] <- def_ids.iter().map(|&def_id| {
|
||||
record_array!(this.tables.associated_item_or_field_def_ids[def_id] <- def_ids.iter().map(|&def_id| {
|
||||
assert!(def_id.is_local());
|
||||
def_id.index
|
||||
}))
|
||||
@ -1678,6 +1678,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
hir::ItemKind::Trait(..) => {
|
||||
record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id));
|
||||
|
||||
let module_children = tcx.module_children_non_reexports(item.owner_id.def_id);
|
||||
record_array!(self.tables.module_children_non_reexports[def_id] <-
|
||||
module_children.iter().map(|def_id| def_id.local_def_index));
|
||||
|
||||
let associated_item_def_ids = self.tcx.associated_item_def_ids(def_id);
|
||||
record_associated_item_def_ids(self, associated_item_def_ids);
|
||||
for &item_def_id in associated_item_def_ids {
|
||||
|
@ -361,7 +361,8 @@ define_tables! {
|
||||
|
||||
- optional:
|
||||
attributes: Table<DefIndex, LazyArray<ast::Attribute>>,
|
||||
children: Table<DefIndex, LazyArray<DefIndex>>,
|
||||
module_children_non_reexports: Table<DefIndex, LazyArray<DefIndex>>,
|
||||
associated_item_or_field_def_ids: Table<DefIndex, LazyArray<DefIndex>>,
|
||||
opt_def_kind: Table<DefIndex, DefKind>,
|
||||
visibility: Table<DefIndex, LazyValue<ty::Visibility<DefIndex>>>,
|
||||
def_span: Table<DefIndex, LazyValue<Span>>,
|
||||
|
@ -670,9 +670,10 @@ rustc_queries! {
|
||||
desc { "computing the inferred outlives predicates for items in this crate" }
|
||||
}
|
||||
|
||||
/// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
|
||||
/// Maps from an impl/trait or struct/variant `DefId`
|
||||
/// to a list of the `DefId`s of its associated items or fields.
|
||||
query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
|
||||
desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
|
||||
desc { |tcx| "collecting associated items or fields of `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { key.is_local() }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
||||
interpret_alloc_index.reserve(new_n - n);
|
||||
for idx in n..new_n {
|
||||
let id = encoder.interpret_allocs[idx];
|
||||
let pos = encoder.position() as u32;
|
||||
let pos: u32 = encoder.position().try_into().unwrap();
|
||||
interpret_alloc_index.push(pos);
|
||||
interpret::specialized_encode_alloc_id(&mut encoder, tcx, id);
|
||||
}
|
||||
|
@ -367,6 +367,7 @@ fn preprocess_link(link: &str) -> Box<str> {
|
||||
let link = link.strip_suffix("{}").unwrap_or(link);
|
||||
let link = link.strip_suffix("[]").unwrap_or(link);
|
||||
let link = if link != "!" { link.strip_suffix('!').unwrap_or(link) } else { link };
|
||||
let link = link.trim();
|
||||
strip_generics_from_path(link).unwrap_or_else(|_| link.into())
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
|
||||
}
|
||||
}
|
||||
|
||||
let iter = mem::replace(&mut self.iter, (&mut []).iter());
|
||||
let iter = mem::take(&mut self.iter);
|
||||
let drop_len = iter.len();
|
||||
|
||||
let mut vec = self.vec;
|
||||
|
@ -685,7 +685,7 @@ where
|
||||
None
|
||||
} else {
|
||||
self.finished = true;
|
||||
Some(mem::replace(&mut self.v, &mut []))
|
||||
Some(mem::take(&mut self.v))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -749,7 +749,7 @@ where
|
||||
match idx_opt {
|
||||
None => self.finish(),
|
||||
Some(idx) => {
|
||||
let tmp = mem::replace(&mut self.v, &mut []);
|
||||
let tmp = mem::take(&mut self.v);
|
||||
let (head, tail) = tmp.split_at_mut(idx);
|
||||
self.v = head;
|
||||
Some(&mut tail[1..])
|
||||
@ -830,7 +830,7 @@ where
|
||||
if idx == self.v.len() {
|
||||
self.finished = true;
|
||||
}
|
||||
let tmp = mem::replace(&mut self.v, &mut []);
|
||||
let tmp = mem::take(&mut self.v);
|
||||
let (head, tail) = tmp.split_at_mut(idx);
|
||||
self.v = tail;
|
||||
Some(head)
|
||||
@ -876,7 +876,7 @@ where
|
||||
if idx == 0 {
|
||||
self.finished = true;
|
||||
}
|
||||
let tmp = mem::replace(&mut self.v, &mut []);
|
||||
let tmp = mem::take(&mut self.v);
|
||||
let (head, tail) = tmp.split_at_mut(idx);
|
||||
self.v = head;
|
||||
Some(tail)
|
||||
|
@ -9,6 +9,7 @@ use crate::io::{
|
||||
self, BorrowedCursor, BufRead, ErrorKind, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write,
|
||||
};
|
||||
use crate::mem;
|
||||
use crate::str;
|
||||
|
||||
// =============================================================================
|
||||
// Forwarding implementations
|
||||
@ -307,6 +308,17 @@ impl Read for &[u8] {
|
||||
*self = &self[len..];
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||
let content = str::from_utf8(self).map_err(|_| {
|
||||
io::const_io_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8")
|
||||
})?;
|
||||
buf.push_str(content);
|
||||
let len = self.len();
|
||||
*self = &self[len..];
|
||||
Ok(len)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -336,7 +348,7 @@ impl Write for &mut [u8] {
|
||||
#[inline]
|
||||
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
|
||||
let amt = cmp::min(data.len(), self.len());
|
||||
let (a, b) = mem::replace(self, &mut []).split_at_mut(amt);
|
||||
let (a, b) = mem::take(self).split_at_mut(amt);
|
||||
a.copy_from_slice(&data[..amt]);
|
||||
*self = b;
|
||||
Ok(amt)
|
||||
@ -434,6 +446,33 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
|
||||
self.drain(..n);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
|
||||
// The total len is known upfront so we can reserve it in a single call.
|
||||
let len = self.len();
|
||||
buf.reserve(len);
|
||||
|
||||
let (front, back) = self.as_slices();
|
||||
buf.extend_from_slice(front);
|
||||
buf.extend_from_slice(back);
|
||||
self.clear();
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||
// We have to use a single contiguous slice because the `VecDequeue` might be split in the
|
||||
// middle of an UTF-8 character.
|
||||
let len = self.len();
|
||||
let content = self.make_contiguous();
|
||||
let string = str::from_utf8(content).map_err(|_| {
|
||||
io::const_io_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8")
|
||||
})?;
|
||||
buf.push_str(string);
|
||||
self.clear();
|
||||
Ok(len)
|
||||
}
|
||||
}
|
||||
|
||||
/// Write is implemented for `VecDeque<u8>` by appending to the `VecDeque`, growing it as needed.
|
||||
@ -445,6 +484,21 @@ impl<A: Allocator> Write for VecDeque<u8, A> {
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
let len = bufs.iter().map(|b| b.len()).sum();
|
||||
self.reserve(len);
|
||||
for buf in bufs {
|
||||
self.extend(&**buf);
|
||||
}
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_write_vectored(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||
self.extend(buf);
|
||||
|
@ -253,7 +253,7 @@ mod tests;
|
||||
|
||||
use crate::cmp;
|
||||
use crate::fmt;
|
||||
use crate::mem::replace;
|
||||
use crate::mem::take;
|
||||
use crate::ops::{Deref, DerefMut};
|
||||
use crate::slice;
|
||||
use crate::str;
|
||||
@ -1186,7 +1186,7 @@ impl<'a> IoSliceMut<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
*bufs = &mut replace(bufs, &mut [])[remove..];
|
||||
*bufs = &mut take(bufs)[remove..];
|
||||
if bufs.is_empty() {
|
||||
assert!(n == accumulated_len, "advancing io slices beyond their length");
|
||||
} else {
|
||||
@ -1329,7 +1329,7 @@ impl<'a> IoSlice<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
*bufs = &mut replace(bufs, &mut [])[remove..];
|
||||
*bufs = &mut take(bufs)[remove..];
|
||||
if bufs.is_empty() {
|
||||
assert!(n == accumulated_len, "advancing io slices beyond their length");
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@ impl<'a> IoSliceMut<'a> {
|
||||
|
||||
#[inline]
|
||||
pub fn advance(&mut self, n: usize) {
|
||||
let slice = mem::replace(&mut self.0, &mut []);
|
||||
let slice = mem::take(&mut self.0);
|
||||
let (_, remaining) = slice.split_at_mut(n);
|
||||
self.0 = remaining;
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
// this test used to ICE
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
//! [Clone ()]. //~ ERROR unresolved
|
||||
//! [Clone !]. //~ ERROR incompatible
|
||||
//! [`Clone ()`]. //~ ERROR unresolved
|
||||
//! [`Clone !`]. //~ ERROR incompatible
|
@ -0,0 +1,54 @@
|
||||
error: unresolved link to `Clone`
|
||||
--> $DIR/issue-110495-suffix-with-space.rs:3:6
|
||||
|
|
||||
LL | //! [Clone ()].
|
||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-110495-suffix-with-space.rs:2:9
|
||||
|
|
||||
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: to link to the trait, prefix with `trait@`
|
||||
|
|
||||
LL - //! [Clone ()].
|
||||
LL + //! [trait@Clone ].
|
||||
|
|
||||
|
||||
error: incompatible link kind for `Clone`
|
||||
--> $DIR/issue-110495-suffix-with-space.rs:4:6
|
||||
|
|
||||
LL | //! [Clone !].
|
||||
| ^^^^^^^ this link resolved to a derive macro, which is not a macro
|
||||
|
|
||||
help: to link to the derive macro, prefix with `derive@`
|
||||
|
|
||||
LL - //! [Clone !].
|
||||
LL + //! [derive@Clone ].
|
||||
|
|
||||
|
||||
error: unresolved link to `Clone`
|
||||
--> $DIR/issue-110495-suffix-with-space.rs:5:7
|
||||
|
|
||||
LL | //! [`Clone ()`].
|
||||
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
|
||||
|
|
||||
help: to link to the trait, prefix with `trait@`
|
||||
|
|
||||
LL - //! [`Clone ()`].
|
||||
LL + //! [`trait@Clone (`].
|
||||
|
|
||||
|
||||
error: incompatible link kind for `Clone`
|
||||
--> $DIR/issue-110495-suffix-with-space.rs:6:7
|
||||
|
|
||||
LL | //! [`Clone !`].
|
||||
| ^^^^^^^ this link resolved to a derive macro, which is not a macro
|
||||
|
|
||||
help: to link to the derive macro, prefix with `derive@`
|
||||
|
|
||||
LL | //! [`derive@Clone !`].
|
||||
| +++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user