mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #86399 - JohnTitor:rollup-qlm2dvz, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #85663 (Document Arc::from) - #85802 (Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance) - #85970 (Remove methods under Implementors on trait pages) - #86340 (Use better error message for hard errors in CTFE) - #86343 (Do not emit invalid suggestions on multiple mutable borrow errors) - #86355 (Remove invalid suggestions for assoc consts on placeholder type error) - #86389 (Make `sum()` and `product()` documentation hyperlinks refer to `Iterator` methods.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
4d3ce2e7da
@ -518,4 +518,14 @@ impl InterpError<'_> {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Should this error be reported as a hard error, preventing compilation, or a soft error,
|
||||
/// causing a deny-by-default lint?
|
||||
pub fn is_hard_err(&self) -> bool {
|
||||
use InterpError::*;
|
||||
match *self {
|
||||
MachineStop(ref err) => err.is_hard_err(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,6 +453,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
Some(borrow_span),
|
||||
None,
|
||||
);
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
@ -498,6 +499,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
err
|
||||
}
|
||||
@ -718,6 +720,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
first_borrow_desc,
|
||||
None,
|
||||
Some((issued_span, span)),
|
||||
);
|
||||
|
||||
err
|
||||
@ -1076,6 +1079,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -1093,6 +1097,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1158,6 +1163,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
@ -1236,6 +1242,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let within = if borrow_spans.for_generator() { " by generator" } else { "" };
|
||||
@ -1614,6 +1621,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut err,
|
||||
"",
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
self.explain_deref_coercion(loan, &mut err);
|
||||
|
@ -66,6 +66,7 @@ impl BorrowExplanation {
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
borrow_desc: &str,
|
||||
borrow_span: Option<Span>,
|
||||
multiple_borrow_span: Option<(Span, Span)>,
|
||||
) {
|
||||
match *self {
|
||||
BorrowExplanation::UsedLater(later_use_kind, var_or_use_span, path_span) => {
|
||||
@ -192,14 +193,23 @@ impl BorrowExplanation {
|
||||
|
||||
if let Some(info) = &local_decl.is_block_tail {
|
||||
if info.tail_result_is_ignored {
|
||||
err.span_suggestion_verbose(
|
||||
info.span.shrink_to_hi(),
|
||||
"consider adding semicolon after the expression so its \
|
||||
temporaries are dropped sooner, before the local variables \
|
||||
declared by the block are dropped",
|
||||
";".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
// #85581: If the first mutable borrow's scope contains
|
||||
// the second borrow, this suggestion isn't helpful.
|
||||
if !multiple_borrow_span
|
||||
.map(|(old, new)| {
|
||||
old.to(info.span.shrink_to_hi()).contains(new)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
info.span.shrink_to_hi(),
|
||||
"consider adding semicolon after the expression so its \
|
||||
temporaries are dropped sooner, before the local variables \
|
||||
declared by the block are dropped",
|
||||
";".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
err.note(
|
||||
"the temporary is part of an expression at the end of a \
|
||||
|
@ -157,7 +157,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||
tcx: TyCtxtAt<'tcx>,
|
||||
message: &str,
|
||||
emit: impl FnOnce(DiagnosticBuilder<'_>),
|
||||
mut lint_root: Option<hir::HirId>,
|
||||
lint_root: Option<hir::HirId>,
|
||||
) -> ErrorHandled {
|
||||
let finish = |mut err: DiagnosticBuilder<'_>, span_msg: Option<String>| {
|
||||
trace!("reporting const eval failure at {:?}", self.span);
|
||||
@ -194,12 +194,6 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||
_ => {}
|
||||
};
|
||||
|
||||
// If we have a 'hard error', then set `lint_root` to `None` so that we don't
|
||||
// emit a lint.
|
||||
if matches!(&self.error, InterpError::MachineStop(err) if err.is_hard_err()) {
|
||||
lint_root = None;
|
||||
}
|
||||
|
||||
let err_msg = self.error.to_string();
|
||||
|
||||
// Regular case - emit a lint.
|
||||
|
@ -312,22 +312,17 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
||||
let err = ConstEvalErr::new(&ecx, error, None);
|
||||
// Some CTFE errors raise just a lint, not a hard error; see
|
||||
// <https://github.com/rust-lang/rust/issues/71800>.
|
||||
let emit_as_lint = if let Some(def) = def.as_local() {
|
||||
let is_hard_err = if let Some(def) = def.as_local() {
|
||||
// (Associated) consts only emit a lint, since they might be unused.
|
||||
matches!(tcx.def_kind(def.did.to_def_id()), DefKind::Const | DefKind::AssocConst)
|
||||
!matches!(tcx.def_kind(def.did.to_def_id()), DefKind::Const | DefKind::AssocConst)
|
||||
// check if the inner InterpError is hard
|
||||
|| err.error.is_hard_err()
|
||||
} else {
|
||||
// use of broken constant from other crate: always an error
|
||||
false
|
||||
true
|
||||
};
|
||||
if emit_as_lint {
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def.as_local().unwrap().did);
|
||||
Err(err.report_as_lint(
|
||||
tcx.at(tcx.def_span(def.did)),
|
||||
"any use of this value will cause an error",
|
||||
hir_id,
|
||||
Some(err.span),
|
||||
))
|
||||
} else {
|
||||
|
||||
if is_hard_err {
|
||||
let msg = if is_static {
|
||||
Cow::from("could not evaluate static initializer")
|
||||
} else {
|
||||
@ -345,6 +340,14 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
||||
};
|
||||
|
||||
Err(err.report_as_error(ecx.tcx.at(ecx.cur_span()), &msg))
|
||||
} else {
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def.as_local().unwrap().did);
|
||||
Err(err.report_as_lint(
|
||||
tcx.at(tcx.def_span(def.did)),
|
||||
"any use of this value will cause an error",
|
||||
hir_id,
|
||||
Some(err.span),
|
||||
))
|
||||
}
|
||||
}
|
||||
Ok(mplace) => {
|
||||
|
@ -179,8 +179,7 @@ crate fn placeholder_type_error(
|
||||
// Suggest, but only if it is not a function in const or static
|
||||
if suggest {
|
||||
let mut is_fn = false;
|
||||
let mut is_const = false;
|
||||
let mut is_static = false;
|
||||
let mut is_const_or_static = false;
|
||||
|
||||
if let Some(hir_ty) = hir_ty {
|
||||
if let hir::TyKind::BareFn(_) = hir_ty.kind {
|
||||
@ -190,19 +189,26 @@ crate fn placeholder_type_error(
|
||||
let parent_id = tcx.hir().get_parent_node(hir_ty.hir_id);
|
||||
let parent_node = tcx.hir().get(parent_id);
|
||||
|
||||
if let hir::Node::Item(item) = parent_node {
|
||||
if let hir::ItemKind::Const(_, _) = item.kind {
|
||||
is_const = true;
|
||||
} else if let hir::ItemKind::Static(_, _, _) = item.kind {
|
||||
is_static = true;
|
||||
}
|
||||
}
|
||||
is_const_or_static = match parent_node {
|
||||
Node::Item(&hir::Item {
|
||||
kind: hir::ItemKind::Const(..) | hir::ItemKind::Static(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Const(..), ..
|
||||
}) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// if function is wrapped around a const or static,
|
||||
// then don't show the suggestion
|
||||
if !(is_fn && (is_const || is_static)) {
|
||||
if !(is_fn && is_const_or_static) {
|
||||
err.multipart_suggestion(
|
||||
"use type parameters instead",
|
||||
sugg,
|
||||
|
@ -38,6 +38,7 @@ impl<T> Iterator for IntoIter<T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -103,6 +103,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -89,6 +89,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -2300,6 +2300,20 @@ impl<T: ?Sized + Hash> Hash for Arc<T> {
|
||||
|
||||
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
|
||||
impl<T> From<T> for Arc<T> {
|
||||
/// Converts a `T` into an `Arc<T>`
|
||||
///
|
||||
/// The conversion moves the value into a
|
||||
/// newly allocated `Arc`. It is equivalent to
|
||||
/// calling `Arc::new(t)`.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use std::sync::Arc;
|
||||
/// let x = 5;
|
||||
/// let arc = Arc::new(5);
|
||||
///
|
||||
/// assert_eq!(Arc::from(x), arc);
|
||||
/// ```
|
||||
fn from(t: T) -> Self {
|
||||
Arc::new(t)
|
||||
}
|
||||
|
@ -163,6 +163,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
|
||||
self.len()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -132,6 +132,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -58,6 +58,7 @@ where
|
||||
self.it.map(T::clone).fold(init, f)
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -74,6 +74,7 @@ where
|
||||
self.it.count()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -111,6 +111,7 @@ where
|
||||
}
|
||||
|
||||
#[rustc_inherit_overflow_checks]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <Self as Iterator>::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -114,6 +114,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -122,6 +122,7 @@ where
|
||||
self.iter.fold(init, map_fold(self.f, g))
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> B
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -88,6 +88,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -667,6 +667,7 @@ impl<A: Step> Iterator for ops::Range<A> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
|
||||
where
|
||||
Self: TrustedRandomAccess,
|
||||
|
@ -3,12 +3,11 @@ use crate::num::Wrapping;
|
||||
|
||||
/// Trait to represent types that can be created by summing up an iterator.
|
||||
///
|
||||
/// This trait is used to implement the [`sum()`] method on iterators. Types which
|
||||
/// implement the trait can be generated by the [`sum()`] method. Like
|
||||
/// [`FromIterator`] this trait should rarely be called directly and instead
|
||||
/// interacted with through [`Iterator::sum()`].
|
||||
/// This trait is used to implement [`Iterator::sum()`]. Types which implement
|
||||
/// this trait can be generated by using the [`sum()`] method on an iterator.
|
||||
/// Like [`FromIterator`], this trait should rarely be called directly.
|
||||
///
|
||||
/// [`sum()`]: Sum::sum
|
||||
/// [`sum()`]: Iterator::sum
|
||||
/// [`FromIterator`]: iter::FromIterator
|
||||
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
|
||||
pub trait Sum<A = Self>: Sized {
|
||||
@ -21,12 +20,11 @@ pub trait Sum<A = Self>: Sized {
|
||||
/// Trait to represent types that can be created by multiplying elements of an
|
||||
/// iterator.
|
||||
///
|
||||
/// This trait is used to implement the [`product()`] method on iterators. Types
|
||||
/// which implement the trait can be generated by the [`product()`] method. Like
|
||||
/// [`FromIterator`] this trait should rarely be called directly and instead
|
||||
/// interacted with through [`Iterator::product()`].
|
||||
/// This trait is used to implement [`Iterator::product()`]. Types which implement
|
||||
/// this trait can be generated by using the [`product()`] method on an iterator.
|
||||
/// Like [`FromIterator`], this trait should rarely be called directly.
|
||||
///
|
||||
/// [`product()`]: Product::product
|
||||
/// [`product()`]: Iterator::product
|
||||
/// [`FromIterator`]: iter::FromIterator
|
||||
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
|
||||
pub trait Product<A = Self>: Sized {
|
||||
|
@ -2148,6 +2148,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> {
|
||||
self.iter.last()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a [T; N] {
|
||||
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are
|
||||
// transferred to the caller.
|
||||
@ -2260,6 +2261,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunksMut<'a, T, N> {
|
||||
self.iter.last()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a mut [T; N] {
|
||||
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are transferred to
|
||||
// the caller.
|
||||
|
@ -295,6 +295,7 @@ impl Iterator for Bytes<'_> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> u8 {
|
||||
// SAFETY: the caller must uphold the safety contract
|
||||
// for `Iterator::__iterator_get_unchecked`.
|
||||
|
@ -253,6 +253,7 @@ mod tests;
|
||||
|
||||
use crate::cmp;
|
||||
use crate::fmt;
|
||||
use crate::mem::replace;
|
||||
use crate::ops::{Deref, DerefMut};
|
||||
use crate::ptr;
|
||||
use crate::slice;
|
||||
@ -1044,6 +1045,32 @@ impl<'a> IoSliceMut<'a> {
|
||||
|
||||
/// Advance the internal cursor of the slice.
|
||||
///
|
||||
/// Also see [`IoSliceMut::advance_slices`] to advance the cursors of
|
||||
/// multiple buffers.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(io_slice_advance)]
|
||||
///
|
||||
/// use std::io::IoSliceMut;
|
||||
/// use std::ops::Deref;
|
||||
///
|
||||
/// let mut data = [1; 8];
|
||||
/// let mut buf = IoSliceMut::new(&mut data);
|
||||
///
|
||||
/// // Mark 3 bytes as read.
|
||||
/// buf.advance(3);
|
||||
/// assert_eq!(buf.deref(), [1; 5].as_ref());
|
||||
/// ```
|
||||
#[unstable(feature = "io_slice_advance", issue = "62726")]
|
||||
#[inline]
|
||||
pub fn advance(&mut self, n: usize) {
|
||||
self.0.advance(n)
|
||||
}
|
||||
|
||||
/// Advance the internal cursor of the slices.
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// Elements in the slice may be modified if the cursor is not advanced to
|
||||
@ -1070,13 +1097,13 @@ impl<'a> IoSliceMut<'a> {
|
||||
/// ][..];
|
||||
///
|
||||
/// // Mark 10 bytes as read.
|
||||
/// bufs = IoSliceMut::advance(bufs, 10);
|
||||
/// IoSliceMut::advance_slices(&mut bufs, 10);
|
||||
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
|
||||
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
|
||||
/// ```
|
||||
#[unstable(feature = "io_slice_advance", issue = "62726")]
|
||||
#[inline]
|
||||
pub fn advance<'b>(bufs: &'b mut [IoSliceMut<'a>], n: usize) -> &'b mut [IoSliceMut<'a>] {
|
||||
pub fn advance_slices(bufs: &mut &mut [IoSliceMut<'a>], n: usize) {
|
||||
// Number of buffers to remove.
|
||||
let mut remove = 0;
|
||||
// Total length of all the to be removed buffers.
|
||||
@ -1090,11 +1117,10 @@ impl<'a> IoSliceMut<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let bufs = &mut bufs[remove..];
|
||||
*bufs = &mut replace(bufs, &mut [])[remove..];
|
||||
if !bufs.is_empty() {
|
||||
bufs[0].0.advance(n - accumulated_len)
|
||||
bufs[0].advance(n - accumulated_len)
|
||||
}
|
||||
bufs
|
||||
}
|
||||
}
|
||||
|
||||
@ -1153,6 +1179,32 @@ impl<'a> IoSlice<'a> {
|
||||
|
||||
/// Advance the internal cursor of the slice.
|
||||
///
|
||||
/// Also see [`IoSlice::advance_slices`] to advance the cursors of multiple
|
||||
/// buffers.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(io_slice_advance)]
|
||||
///
|
||||
/// use std::io::IoSlice;
|
||||
/// use std::ops::Deref;
|
||||
///
|
||||
/// let mut data = [1; 8];
|
||||
/// let mut buf = IoSlice::new(&mut data);
|
||||
///
|
||||
/// // Mark 3 bytes as read.
|
||||
/// buf.advance(3);
|
||||
/// assert_eq!(buf.deref(), [1; 5].as_ref());
|
||||
/// ```
|
||||
#[unstable(feature = "io_slice_advance", issue = "62726")]
|
||||
#[inline]
|
||||
pub fn advance(&mut self, n: usize) {
|
||||
self.0.advance(n)
|
||||
}
|
||||
|
||||
/// Advance the internal cursor of the slices.
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// Elements in the slice may be modified if the cursor is not advanced to
|
||||
@ -1179,12 +1231,12 @@ impl<'a> IoSlice<'a> {
|
||||
/// ][..];
|
||||
///
|
||||
/// // Mark 10 bytes as written.
|
||||
/// bufs = IoSlice::advance(bufs, 10);
|
||||
/// IoSlice::advance_slices(&mut bufs, 10);
|
||||
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
|
||||
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
|
||||
#[unstable(feature = "io_slice_advance", issue = "62726")]
|
||||
#[inline]
|
||||
pub fn advance<'b>(bufs: &'b mut [IoSlice<'a>], n: usize) -> &'b mut [IoSlice<'a>] {
|
||||
pub fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize) {
|
||||
// Number of buffers to remove.
|
||||
let mut remove = 0;
|
||||
// Total length of all the to be removed buffers.
|
||||
@ -1198,11 +1250,10 @@ impl<'a> IoSlice<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let bufs = &mut bufs[remove..];
|
||||
*bufs = &mut replace(bufs, &mut [])[remove..];
|
||||
if !bufs.is_empty() {
|
||||
bufs[0].0.advance(n - accumulated_len)
|
||||
bufs[0].advance(n - accumulated_len)
|
||||
}
|
||||
bufs
|
||||
}
|
||||
}
|
||||
|
||||
@ -1511,7 +1562,7 @@ pub trait Write {
|
||||
fn write_all_vectored(&mut self, mut bufs: &mut [IoSlice<'_>]) -> Result<()> {
|
||||
// Guarantee that bufs is empty if it contains no data,
|
||||
// to avoid calling write_vectored if there is no data to be written.
|
||||
bufs = IoSlice::advance(bufs, 0);
|
||||
IoSlice::advance_slices(&mut bufs, 0);
|
||||
while !bufs.is_empty() {
|
||||
match self.write_vectored(bufs) {
|
||||
Ok(0) => {
|
||||
@ -1520,7 +1571,7 @@ pub trait Write {
|
||||
&"failed to write whole buffer",
|
||||
));
|
||||
}
|
||||
Ok(n) => bufs = IoSlice::advance(bufs, n),
|
||||
Ok(n) => IoSlice::advance_slices(&mut bufs, n),
|
||||
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ fn test_read_to_end_capacity() -> io::Result<()> {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_mut_advance() {
|
||||
fn io_slice_mut_advance_slices() {
|
||||
let mut buf1 = [1; 8];
|
||||
let mut buf2 = [2; 16];
|
||||
let mut buf3 = [3; 8];
|
||||
@ -364,75 +364,75 @@ fn io_slice_mut_advance() {
|
||||
][..];
|
||||
|
||||
// Only in a single buffer..
|
||||
bufs = IoSliceMut::advance(bufs, 1);
|
||||
IoSliceMut::advance_slices(&mut bufs, 1);
|
||||
assert_eq!(bufs[0].deref(), [1; 7].as_ref());
|
||||
assert_eq!(bufs[1].deref(), [2; 16].as_ref());
|
||||
assert_eq!(bufs[2].deref(), [3; 8].as_ref());
|
||||
|
||||
// Removing a buffer, leaving others as is.
|
||||
bufs = IoSliceMut::advance(bufs, 7);
|
||||
IoSliceMut::advance_slices(&mut bufs, 7);
|
||||
assert_eq!(bufs[0].deref(), [2; 16].as_ref());
|
||||
assert_eq!(bufs[1].deref(), [3; 8].as_ref());
|
||||
|
||||
// Removing a buffer and removing from the next buffer.
|
||||
bufs = IoSliceMut::advance(bufs, 18);
|
||||
IoSliceMut::advance_slices(&mut bufs, 18);
|
||||
assert_eq!(bufs[0].deref(), [3; 6].as_ref());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_mut_advance_empty_slice() {
|
||||
let empty_bufs = &mut [][..];
|
||||
fn io_slice_mut_advance_slices_empty_slice() {
|
||||
let mut empty_bufs = &mut [][..];
|
||||
// Shouldn't panic.
|
||||
IoSliceMut::advance(empty_bufs, 1);
|
||||
IoSliceMut::advance_slices(&mut empty_bufs, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_mut_advance_beyond_total_length() {
|
||||
fn io_slice_mut_advance_slices_beyond_total_length() {
|
||||
let mut buf1 = [1; 8];
|
||||
let mut bufs = &mut [IoSliceMut::new(&mut buf1)][..];
|
||||
|
||||
// Going beyond the total length should be ok.
|
||||
bufs = IoSliceMut::advance(bufs, 9);
|
||||
IoSliceMut::advance_slices(&mut bufs, 9);
|
||||
assert!(bufs.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_advance() {
|
||||
fn io_slice_advance_slices() {
|
||||
let buf1 = [1; 8];
|
||||
let buf2 = [2; 16];
|
||||
let buf3 = [3; 8];
|
||||
let mut bufs = &mut [IoSlice::new(&buf1), IoSlice::new(&buf2), IoSlice::new(&buf3)][..];
|
||||
|
||||
// Only in a single buffer..
|
||||
bufs = IoSlice::advance(bufs, 1);
|
||||
IoSlice::advance_slices(&mut bufs, 1);
|
||||
assert_eq!(bufs[0].deref(), [1; 7].as_ref());
|
||||
assert_eq!(bufs[1].deref(), [2; 16].as_ref());
|
||||
assert_eq!(bufs[2].deref(), [3; 8].as_ref());
|
||||
|
||||
// Removing a buffer, leaving others as is.
|
||||
bufs = IoSlice::advance(bufs, 7);
|
||||
IoSlice::advance_slices(&mut bufs, 7);
|
||||
assert_eq!(bufs[0].deref(), [2; 16].as_ref());
|
||||
assert_eq!(bufs[1].deref(), [3; 8].as_ref());
|
||||
|
||||
// Removing a buffer and removing from the next buffer.
|
||||
bufs = IoSlice::advance(bufs, 18);
|
||||
IoSlice::advance_slices(&mut bufs, 18);
|
||||
assert_eq!(bufs[0].deref(), [3; 6].as_ref());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_advance_empty_slice() {
|
||||
let empty_bufs = &mut [][..];
|
||||
fn io_slice_advance_slices_empty_slice() {
|
||||
let mut empty_bufs = &mut [][..];
|
||||
// Shouldn't panic.
|
||||
IoSlice::advance(empty_bufs, 1);
|
||||
IoSlice::advance_slices(&mut empty_bufs, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn io_slice_advance_beyond_total_length() {
|
||||
fn io_slice_advance_slices_beyond_total_length() {
|
||||
let buf1 = [1; 8];
|
||||
let mut bufs = &mut [IoSlice::new(&buf1)][..];
|
||||
|
||||
// Going beyond the total length should be ok.
|
||||
bufs = IoSlice::advance(bufs, 9);
|
||||
IoSlice::advance_slices(&mut bufs, 9);
|
||||
assert!(bufs.is_empty());
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,6 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
|
||||
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
|
||||
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", false)
|
||||
.into(),
|
||||
("auto-collapse-implementors", "Auto-hide implementors of a trait", true).into(),
|
||||
("go-to-only-result", "Directly go to item in search if there is only one result", false)
|
||||
.into(),
|
||||
("line-numbers", "Show line numbers on code examples", false).into(),
|
||||
@ -724,6 +723,8 @@ fn short_item_info(
|
||||
extra_info
|
||||
}
|
||||
|
||||
// Render the list of items inside one of the sections "Trait Implementations",
|
||||
// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
|
||||
fn render_impls(
|
||||
cx: &Context<'_>,
|
||||
w: &mut Buffer,
|
||||
@ -746,8 +747,6 @@ fn render_impls(
|
||||
containing_item,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
containing_item.stable_since(tcx).as_deref(),
|
||||
containing_item.const_stable_since(tcx).as_deref(),
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
@ -1025,7 +1024,6 @@ fn render_assoc_items(
|
||||
Some(v) => v,
|
||||
None => return,
|
||||
};
|
||||
let tcx = cx.tcx();
|
||||
let cache = cx.cache();
|
||||
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
|
||||
if !non_trait.is_empty() {
|
||||
@ -1059,8 +1057,6 @@ fn render_assoc_items(
|
||||
containing_item,
|
||||
AssocItemLink::Anchor(None),
|
||||
render_mode,
|
||||
containing_item.stable_since(tcx).as_deref(),
|
||||
containing_item.const_stable_since(tcx).as_deref(),
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
@ -1261,8 +1257,6 @@ fn render_impl(
|
||||
parent: &clean::Item,
|
||||
link: AssocItemLink<'_>,
|
||||
render_mode: RenderMode,
|
||||
outer_version: Option<&str>,
|
||||
outer_const_version: Option<&str>,
|
||||
show_def_docs: bool,
|
||||
use_absolute: Option<bool>,
|
||||
is_on_foreign_type: bool,
|
||||
@ -1279,23 +1273,23 @@ fn render_impl(
|
||||
// For trait implementations, the `interesting` output contains all methods that have doc
|
||||
// comments, and the `boring` output contains all methods that do not. The distinction is
|
||||
// used to allow hiding the boring methods.
|
||||
// `containing_item` is used for rendering stability info. If the parent is a trait impl,
|
||||
// `containing_item` will the grandparent, since trait impls can't have stability attached.
|
||||
fn doc_impl_item(
|
||||
boring: &mut Buffer,
|
||||
interesting: &mut Buffer,
|
||||
cx: &Context<'_>,
|
||||
item: &clean::Item,
|
||||
parent: &clean::Item,
|
||||
containing_item: &clean::Item,
|
||||
link: AssocItemLink<'_>,
|
||||
render_mode: RenderMode,
|
||||
is_default_item: bool,
|
||||
outer_version: Option<&str>,
|
||||
outer_const_version: Option<&str>,
|
||||
trait_: Option<&clean::Trait>,
|
||||
show_def_docs: bool,
|
||||
) {
|
||||
let item_type = item.type_();
|
||||
let name = item.name.as_ref().unwrap();
|
||||
let tcx = cx.tcx();
|
||||
|
||||
let render_method_item = match render_mode {
|
||||
RenderMode::Normal => true,
|
||||
@ -1364,6 +1358,8 @@ fn render_impl(
|
||||
"<div id=\"{}\" class=\"{}{} has-srclink\">",
|
||||
id, item_type, in_trait_class,
|
||||
);
|
||||
render_rightside(w, cx, item, containing_item);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("<code>");
|
||||
render_assoc_item(
|
||||
w,
|
||||
@ -1373,15 +1369,6 @@ fn render_impl(
|
||||
cx,
|
||||
);
|
||||
w.write_str("</code>");
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
item.stable_since(tcx).as_deref(),
|
||||
item.const_stable_since(tcx).as_deref(),
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write_srclink(cx, item, w);
|
||||
w.write_str("</div>");
|
||||
}
|
||||
}
|
||||
@ -1390,9 +1377,11 @@ fn render_impl(
|
||||
let id = cx.derive_id(source_id.clone());
|
||||
write!(
|
||||
w,
|
||||
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
|
||||
"<div id=\"{}\" class=\"{}{} has-srclink\">",
|
||||
id, item_type, in_trait_class
|
||||
);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("<code>");
|
||||
assoc_type(
|
||||
w,
|
||||
item,
|
||||
@ -1403,7 +1392,6 @@ fn render_impl(
|
||||
cx,
|
||||
);
|
||||
w.write_str("</code>");
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("</div>");
|
||||
}
|
||||
clean::AssocConstItem(ref ty, ref default) => {
|
||||
@ -1411,9 +1399,12 @@ fn render_impl(
|
||||
let id = cx.derive_id(source_id.clone());
|
||||
write!(
|
||||
w,
|
||||
"<div id=\"{}\" class=\"{}{} has-srclink\"><code>",
|
||||
"<div id=\"{}\" class=\"{}{} has-srclink\">",
|
||||
id, item_type, in_trait_class
|
||||
);
|
||||
render_rightside(w, cx, item, containing_item);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("<code>");
|
||||
assoc_const(
|
||||
w,
|
||||
item,
|
||||
@ -1424,21 +1415,14 @@ fn render_impl(
|
||||
cx,
|
||||
);
|
||||
w.write_str("</code>");
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
item.stable_since(tcx).as_deref(),
|
||||
item.const_stable_since(tcx).as_deref(),
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write_srclink(cx, item, w);
|
||||
w.write_str("</div>");
|
||||
}
|
||||
clean::AssocTypeItem(ref bounds, ref default) => {
|
||||
let source_id = format!("{}.{}", item_type, name);
|
||||
let id = cx.derive_id(source_id.clone());
|
||||
write!(w, "<div id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class,);
|
||||
write!(w, "<div id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("<code>");
|
||||
assoc_type(
|
||||
w,
|
||||
item,
|
||||
@ -1449,7 +1433,6 @@ fn render_impl(
|
||||
cx,
|
||||
);
|
||||
w.write_str("</code>");
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
w.write_str("</div>");
|
||||
}
|
||||
clean::StrippedItem(..) => return,
|
||||
@ -1474,11 +1457,10 @@ fn render_impl(
|
||||
cx,
|
||||
trait_item,
|
||||
if trait_.is_some() { &i.impl_item } else { parent },
|
||||
parent,
|
||||
link,
|
||||
render_mode,
|
||||
false,
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
trait_.map(|t| &t.trait_),
|
||||
show_def_docs,
|
||||
);
|
||||
@ -1491,9 +1473,8 @@ fn render_impl(
|
||||
t: &clean::Trait,
|
||||
i: &clean::Impl,
|
||||
parent: &clean::Item,
|
||||
containing_item: &clean::Item,
|
||||
render_mode: RenderMode,
|
||||
outer_version: Option<&str>,
|
||||
outer_const_version: Option<&str>,
|
||||
show_def_docs: bool,
|
||||
) {
|
||||
for trait_item in &t.items {
|
||||
@ -1511,11 +1492,10 @@ fn render_impl(
|
||||
cx,
|
||||
trait_item,
|
||||
parent,
|
||||
containing_item,
|
||||
assoc_link,
|
||||
render_mode,
|
||||
true,
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
Some(t),
|
||||
show_def_docs,
|
||||
);
|
||||
@ -1535,28 +1515,25 @@ fn render_impl(
|
||||
&t.trait_,
|
||||
&i.inner_impl(),
|
||||
&i.impl_item,
|
||||
parent,
|
||||
render_mode,
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
show_def_docs,
|
||||
);
|
||||
}
|
||||
}
|
||||
if render_mode == RenderMode::Normal {
|
||||
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
|
||||
let toggled = !(impl_items.is_empty() && default_impl_items.is_empty());
|
||||
if toggled {
|
||||
close_tags.insert_str(0, "</details>");
|
||||
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
|
||||
}
|
||||
if toggled {
|
||||
write!(w, "<summary>")
|
||||
}
|
||||
render_impl_summary(
|
||||
w,
|
||||
cx,
|
||||
i,
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
parent,
|
||||
parent,
|
||||
show_def_docs,
|
||||
use_absolute,
|
||||
is_on_foreign_type,
|
||||
@ -1565,11 +1542,6 @@ fn render_impl(
|
||||
if toggled {
|
||||
write!(w, "</summary>")
|
||||
}
|
||||
if trait_.is_some() {
|
||||
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
|
||||
write!(w, "<div class=\"item-info\">{}</div>", portability);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
|
||||
let mut ids = cx.id_map.borrow_mut();
|
||||
@ -1597,12 +1569,35 @@ fn render_impl(
|
||||
w.write_str(&close_tags);
|
||||
}
|
||||
|
||||
fn render_impl_summary(
|
||||
// Render the items that appear on the right side of methods, impls, and
|
||||
// associated types. For example "1.0.0 (const: 1.39.0) [src]".
|
||||
fn render_rightside(
|
||||
w: &mut Buffer,
|
||||
cx: &Context<'_>,
|
||||
item: &clean::Item,
|
||||
containing_item: &clean::Item,
|
||||
) {
|
||||
let tcx = cx.tcx();
|
||||
|
||||
write!(w, "<div class=\"rightside\">");
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
item.stable_since(tcx).as_deref(),
|
||||
item.const_stable_since(tcx).as_deref(),
|
||||
containing_item.stable_since(tcx).as_deref(),
|
||||
containing_item.const_stable_since(tcx).as_deref(),
|
||||
);
|
||||
|
||||
write_srclink(cx, item, w);
|
||||
w.write_str("</div>");
|
||||
}
|
||||
|
||||
pub(crate) fn render_impl_summary(
|
||||
w: &mut Buffer,
|
||||
cx: &Context<'_>,
|
||||
i: &Impl,
|
||||
outer_version: Option<&str>,
|
||||
outer_const_version: Option<&str>,
|
||||
parent: &clean::Item,
|
||||
containing_item: &clean::Item,
|
||||
show_def_docs: bool,
|
||||
use_absolute: Option<bool>,
|
||||
is_on_foreign_type: bool,
|
||||
@ -1610,7 +1605,6 @@ fn render_impl_summary(
|
||||
// in documentation pages for trait with automatic implementations like "Send" and "Sync".
|
||||
aliases: &[String],
|
||||
) {
|
||||
let tcx = cx.tcx();
|
||||
let id = cx.derive_id(match i.inner_impl().trait_ {
|
||||
Some(ref t) => {
|
||||
if is_on_foreign_type {
|
||||
@ -1626,13 +1620,12 @@ fn render_impl_summary(
|
||||
} else {
|
||||
format!(" data-aliases=\"{}\"", aliases.join(","))
|
||||
};
|
||||
write!(w, "<div id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
|
||||
render_rightside(w, cx, &i.impl_item, containing_item);
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
write!(w, "<code class=\"in-band\">");
|
||||
|
||||
if let Some(use_absolute) = use_absolute {
|
||||
write!(
|
||||
w,
|
||||
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
|
||||
<code class=\"in-band\">",
|
||||
id, aliases
|
||||
);
|
||||
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
|
||||
if show_def_docs {
|
||||
for it in &i.inner_impl().items {
|
||||
@ -1643,26 +1636,18 @@ fn render_impl_summary(
|
||||
}
|
||||
}
|
||||
}
|
||||
w.write_str("</code>");
|
||||
} else {
|
||||
write!(
|
||||
w,
|
||||
"<div id=\"{}\" class=\"impl has-srclink\"{}>\
|
||||
<code class=\"in-band\">{}</code>",
|
||||
id,
|
||||
aliases,
|
||||
i.inner_impl().print(false, cx)
|
||||
);
|
||||
write!(w, "{}", i.inner_impl().print(false, cx));
|
||||
}
|
||||
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
|
||||
render_stability_since_raw(
|
||||
w,
|
||||
i.impl_item.stable_since(tcx).as_deref(),
|
||||
i.impl_item.const_stable_since(tcx).as_deref(),
|
||||
outer_version,
|
||||
outer_const_version,
|
||||
);
|
||||
write_srclink(cx, &i.impl_item, w);
|
||||
write!(w, "</code>");
|
||||
|
||||
let is_trait = i.inner_impl().trait_.is_some();
|
||||
if is_trait {
|
||||
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
|
||||
write!(w, "<div class=\"item-info\">{}</div>", portability);
|
||||
}
|
||||
}
|
||||
|
||||
w.write_str("</div>");
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use super::{
|
||||
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
|
||||
render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
|
||||
render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
|
||||
render_impl, render_impl_summary, render_stability_since_raw, write_srclink, AssocItemLink,
|
||||
Context,
|
||||
};
|
||||
use crate::clean::{self, GetDefId};
|
||||
use crate::formats::item_type::ItemType;
|
||||
@ -585,11 +586,14 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||
if toggled {
|
||||
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
|
||||
}
|
||||
write!(w, "<div id=\"{}\" class=\"method has-srclink\"><code>", id);
|
||||
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
|
||||
w.write_str("</code>");
|
||||
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
|
||||
write!(w, "<div class=\"rightside\">");
|
||||
render_stability_since(w, m, t, cx.tcx());
|
||||
write_srclink(cx, m, w);
|
||||
write!(w, "</div>");
|
||||
write!(w, "<code>");
|
||||
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl, cx);
|
||||
w.write_str("</code>");
|
||||
w.write_str("</div>");
|
||||
if toggled {
|
||||
write!(w, "</summary>");
|
||||
@ -701,8 +705,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||
it,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
implementor.impl_item.stable_since(cx.tcx()).as_deref(),
|
||||
implementor.impl_item.const_stable_since(cx.tcx()).as_deref(),
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
@ -1310,7 +1312,7 @@ fn render_implementor(
|
||||
implementor_dups: &FxHashMap<Symbol, (DefId, bool)>,
|
||||
aliases: &[String],
|
||||
) {
|
||||
// If there's already another implementor that has the same abbridged name, use the
|
||||
// If there's already another implementor that has the same abridged name, use the
|
||||
// full path, for example in `std::iter::ExactSizeIterator`
|
||||
let use_absolute = match implementor.inner_impl().for_ {
|
||||
clean::ResolvedPath { ref path, is_generic: false, .. }
|
||||
@ -1320,19 +1322,15 @@ fn render_implementor(
|
||||
} => implementor_dups[&path.last()].1,
|
||||
_ => false,
|
||||
};
|
||||
render_impl(
|
||||
render_impl_summary(
|
||||
w,
|
||||
cx,
|
||||
implementor,
|
||||
trait_,
|
||||
AssocItemLink::Anchor(None),
|
||||
RenderMode::Normal,
|
||||
trait_.stable_since(cx.tcx()).as_deref(),
|
||||
trait_.const_stable_since(cx.tcx()).as_deref(),
|
||||
trait_,
|
||||
false,
|
||||
Some(use_absolute),
|
||||
false,
|
||||
false,
|
||||
aliases,
|
||||
);
|
||||
}
|
||||
|
@ -778,7 +778,6 @@ function hideThemeButtonState() {
|
||||
}
|
||||
|
||||
var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
|
||||
var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
|
||||
var hideImplementations = getSettingValue("auto-hide-trait-implementations") === "true";
|
||||
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
|
||||
|
||||
@ -796,10 +795,6 @@ function hideThemeButtonState() {
|
||||
setImplementorsTogglesOpen("blanket-implementations-list", false);
|
||||
}
|
||||
|
||||
if (!hideImplementors) {
|
||||
setImplementorsTogglesOpen("implementors-list", true);
|
||||
}
|
||||
|
||||
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
|
||||
if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) {
|
||||
e.open = true;
|
||||
|
@ -581,7 +581,6 @@ nav.sub {
|
||||
.content .item-info {
|
||||
position: relative;
|
||||
margin-left: 33px;
|
||||
margin-top: -13px;
|
||||
}
|
||||
|
||||
.sub-variant > div > .item-info {
|
||||
@ -852,12 +851,12 @@ body.blur > :not(#help) {
|
||||
}
|
||||
|
||||
.stab {
|
||||
display: table;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
padding: 3px;
|
||||
margin-bottom: 5px;
|
||||
font-size: 90%;
|
||||
font-weight: normal;
|
||||
}
|
||||
.stab p {
|
||||
display: inline;
|
||||
@ -900,32 +899,25 @@ body.blur > :not(#help) {
|
||||
.since {
|
||||
font-weight: normal;
|
||||
font-size: initial;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.impl-items .since, .impl .since, .methods .since {
|
||||
flex-grow: 0;
|
||||
padding-left: 12px;
|
||||
padding-right: 2px;
|
||||
position: initial;
|
||||
}
|
||||
|
||||
.impl-items .srclink, .impl .srclink, .methods .srclink {
|
||||
flex-grow: 0;
|
||||
/* Override header settings otherwise it's too bold */
|
||||
font-size: 17px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.impl-items code, .impl code, .methods code {
|
||||
flex-grow: 1;
|
||||
.rightside {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.has-srclink {
|
||||
display: flex;
|
||||
flex-basis: 100%;
|
||||
font-size: 16px;
|
||||
margin-bottom: 12px;
|
||||
/* Push the src link out to the right edge consistently */
|
||||
@ -986,7 +978,6 @@ a.test-arrow:hover{
|
||||
}
|
||||
|
||||
.since + .srclink {
|
||||
display: table-cell;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
@ -1046,6 +1037,10 @@ a.test-arrow:hover{
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
:target {
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
.information {
|
||||
position: absolute;
|
||||
left: -25px;
|
||||
@ -1612,11 +1607,6 @@ details.undocumented[open] > summary::before {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
|
||||
.impl-items > .associatedtype {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.anchor {
|
||||
display: none !important;
|
||||
}
|
||||
|
@ -334,8 +334,11 @@ a.test-arrow:hover {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
:target > code, :target > .in-band {
|
||||
:target, :target * {
|
||||
background: rgba(255, 236, 164, 0.06);
|
||||
}
|
||||
|
||||
:target {
|
||||
border-right: 3px solid rgba(255, 180, 76, 0.85);
|
||||
}
|
||||
|
||||
|
@ -282,8 +282,11 @@ a.test-arrow:hover{
|
||||
color: #999;
|
||||
}
|
||||
|
||||
:target > code, :target > .in-band {
|
||||
:target, :target * {
|
||||
background-color: #494a3d;
|
||||
}
|
||||
|
||||
:target {
|
||||
border-right: 3px solid #bb7410;
|
||||
}
|
||||
|
||||
|
@ -275,8 +275,11 @@ a.test-arrow:hover{
|
||||
color: #999;
|
||||
}
|
||||
|
||||
:target > code, :target > .in-band {
|
||||
:target, :target * {
|
||||
background: #FDFFD3;
|
||||
}
|
||||
|
||||
:target {
|
||||
border-right: 3px solid #ffb44c;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,6 @@
|
||||
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow
|
||||
// In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)".
|
||||
assert: ("#blanket-implementations-list > details:nth-child(2)", "open", "")
|
||||
// Please note the "\" below is needed because otherwise ".borrow" would be interpreted as
|
||||
// a class selector.
|
||||
assert: ("#method\.borrow", {"display": "flex"})
|
||||
// We first check that the impl block is open by default.
|
||||
assert: ("#implementations + details", "open", "")
|
||||
// We collapse it.
|
||||
|
@ -2,5 +2,5 @@
|
||||
|
||||
// This test ensures that the [src] link is present on traits items.
|
||||
|
||||
// @has foo/trait.Iterator.html '//div[@id="method.zip"]/a[@class="srclink"]' "[src]"
|
||||
// @has foo/trait.Iterator.html '//div[@id="method.zip"]//a[@class="srclink"]' "[src]"
|
||||
pub use std::iter::Iterator;
|
||||
|
@ -1,20 +0,0 @@
|
||||
// @has issue_19055/trait.Any.html
|
||||
pub trait Any {}
|
||||
|
||||
impl<'any> Any + 'any {
|
||||
// @has - '//*[@id="method.is"]' 'fn is'
|
||||
pub fn is<T: 'static>(&self) -> bool { loop {} }
|
||||
|
||||
// @has - '//*[@id="method.downcast_ref"]' 'fn downcast_ref'
|
||||
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> { loop {} }
|
||||
|
||||
// @has - '//*[@id="method.downcast_mut"]' 'fn downcast_mut'
|
||||
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> { loop {} }
|
||||
}
|
||||
|
||||
pub trait Foo {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
|
||||
// @has - '//*[@id="method.foo"]' 'fn foo'
|
||||
impl Foo for Any {}
|
@ -2,11 +2,11 @@
|
||||
|
||||
// @has foo/struct.Unsized.html
|
||||
// @has - '//div[@id="impl-Sized"]/code' 'impl !Sized for Unsized'
|
||||
// @!has - '//div[@id="impl-Sized"]/a[@class="srclink"]' '[src]'
|
||||
// @!has - '//div[@id="impl-Sized"]//a[@class="srclink"]' '[src]'
|
||||
// @has - '//div[@id="impl-Sync"]/code' 'impl Sync for Unsized'
|
||||
// @!has - '//div[@id="impl-Sync"]/a[@class="srclink"]' '[src]'
|
||||
// @!has - '//div[@id="impl-Sync"]//a[@class="srclink"]' '[src]'
|
||||
// @has - '//div[@id="impl-Any"]/code' 'impl<T> Any for T'
|
||||
// @has - '//div[@id="impl-Any"]/a[@class="srclink"]' '[src]'
|
||||
// @has - '//div[@id="impl-Any"]//a[@class="srclink"]' '[src]'
|
||||
pub struct Unsized {
|
||||
data: [u8],
|
||||
}
|
||||
|
@ -38,23 +38,15 @@ impl MyTrait for Vec<u8> {
|
||||
}
|
||||
|
||||
impl MyTrait for MyStruct {
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="type"]/@href' #associatedtype.Assoc
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc
|
||||
type Assoc = bool;
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="constant"]/@href' #associatedconstant.VALUE
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE
|
||||
const VALUE: u32 = 20;
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="fnname"]/@href' #tymethod.trait_function
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.trait_function-2"]//a[@class="anchor"]/@href' #method.trait_function-2
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="fnname"]/@href' trait.MyTrait.html#tymethod.trait_function
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function
|
||||
fn trait_function(&self) {}
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="fnname"]/@href' #method.defaulted_override
|
||||
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="method.defaulted_override-3"]//a[@class="anchor"]/@href' #method.defaulted_override-3
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="fnname"]/@href' trait.MyTrait.html#method.defaulted_override
|
||||
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override
|
||||
fn defaulted_override(&self) {}
|
||||
|
15
src/test/ui/borrowck/issue-85581.rs
Normal file
15
src/test/ui/borrowck/issue-85581.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Regression test of #85581.
|
||||
// Checks not to suggest to add `;` when the second mutable borrow
|
||||
// is in the first's scope.
|
||||
|
||||
use std::collections::BinaryHeap;
|
||||
|
||||
fn foo(heap: &mut BinaryHeap<i32>) {
|
||||
match heap.peek_mut() {
|
||||
Some(_) => { heap.pop(); },
|
||||
//~^ ERROR: cannot borrow `*heap` as mutable more than once at a time
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
17
src/test/ui/borrowck/issue-85581.stderr
Normal file
17
src/test/ui/borrowck/issue-85581.stderr
Normal file
@ -0,0 +1,17 @@
|
||||
error[E0499]: cannot borrow `*heap` as mutable more than once at a time
|
||||
--> $DIR/issue-85581.rs:9:22
|
||||
|
|
||||
LL | match heap.peek_mut() {
|
||||
| ---------------
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
| a temporary with access to the first borrow is created here ...
|
||||
LL | Some(_) => { heap.pop(); },
|
||||
| ^^^^ second mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<PeekMut<'_, i32>>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
@ -5,31 +5,31 @@
|
||||
const MSG: &str = "hello";
|
||||
|
||||
const Z: () = std::panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Z2: () = std::panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y: () = std::unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X: () = std::unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//
|
||||
const W: () = std::panic!(MSG);
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Z_CORE: () = core::panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Z2_CORE: () = core::panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y_CORE: () = core::unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X_CORE: () = core::unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const W_CORE: () = core::panic!(MSG);
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
@ -1,100 +1,80 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:7:15
|
||||
|
|
||||
LL | const Z: () = std::panic!("cheese");
|
||||
| --------------^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:10:16
|
||||
|
|
||||
LL | const Z2: () = std::panic!();
|
||||
| ---------------^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
|
||||
| ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:13:15
|
||||
|
|
||||
LL | const Y: () = std::unreachable!();
|
||||
| --------------^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
|
||||
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:16:15
|
||||
|
|
||||
LL | const X: () = std::unimplemented!();
|
||||
| --------------^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:19:15
|
||||
|
|
||||
LL | const W: () = std::panic!(MSG);
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
|
||||
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:22:20
|
||||
|
|
||||
LL | const Z_CORE: () = core::panic!("cheese");
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:25:21
|
||||
|
|
||||
LL | const Z2_CORE: () = core::panic!();
|
||||
| --------------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
|
||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:28:20
|
||||
|
|
||||
LL | const Y_CORE: () = core::unreachable!();
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:31:20
|
||||
|
|
||||
LL | const X_CORE: () = core::unimplemented!();
|
||||
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic.rs:34:20
|
||||
|
|
||||
LL | const W_CORE: () = core::panic!(MSG);
|
||||
| -------------------^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
|
||||
| ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
const Z: () = panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y: () = unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X: () = unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn eh() {}
|
||||
|
@ -1,30 +1,24 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic_libcore_bin.rs:9:15
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
|
||||
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic_libcore_bin.rs:12:15
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
| --------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
|
||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_panic_libcore_bin.rs:15:15
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
| --------------^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
|
||||
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -9,7 +9,7 @@ struct PrintName;
|
||||
|
||||
impl PrintName {
|
||||
const VOID: ! = panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/panic-assoc-never-type.rs:11:21
|
||||
|
|
||||
LL | const VOID: ! = panic!();
|
||||
| ----------------^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![feature(never_type)]
|
||||
|
||||
const VOID: ! = panic!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
fn main() {
|
||||
let _ = VOID;
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/panic-never-type.rs:6:17
|
||||
|
|
||||
LL | const VOID: ! = panic!();
|
||||
| ----------------^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17
|
||||
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#[unwind(aborts)]
|
||||
const fn foo() {
|
||||
panic!() //~ ERROR any use of this value will cause an error
|
||||
panic!() //~ ERROR evaluation of constant value failed
|
||||
}
|
||||
|
||||
const _: () = foo();
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/unwind-abort.rs:5:5
|
||||
|
|
||||
LL | panic!()
|
||||
@ -6,10 +6,9 @@ LL | panic!()
|
||||
| |
|
||||
| the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5
|
||||
| inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL
|
||||
| inside `_` at $DIR/unwind-abort.rs:8:15
|
||||
...
|
||||
LL | const _: () = foo();
|
||||
| --------------------
|
||||
| ----- inside `_` at $DIR/unwind-abort.rs:8:15
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/option.rs:LL:COL
|
||||
|
|
||||
LL | None => panic!("called `Option::unwrap()` on a `None` value"),
|
||||
@ -6,12 +6,11 @@ LL | None => panic!("called `Option::unwrap()` on a `None` value"),
|
||||
| |
|
||||
| the evaluated program panicked at 'called `Option::unwrap()` on a `None` value', $DIR/const-unwrap.rs:9:38
|
||||
| inside `Option::<i32>::unwrap` at $SRC_DIR/core/src/panic.rs:LL:COL
|
||||
| inside `BAR` at $DIR/const-unwrap.rs:9:18
|
||||
|
|
||||
::: $DIR/const-unwrap.rs:9:1
|
||||
::: $DIR/const-unwrap.rs:9:18
|
||||
|
|
||||
LL | const BAR: i32 = Option::<i32>::None.unwrap();
|
||||
| ----------------------------------------------
|
||||
| ---------------------------- inside `BAR` at $DIR/const-unwrap.rs:9:18
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0080]: any use of this value will cause an error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/assert.rs:10:15
|
||||
|
|
||||
LL | const _: () = assert!(false);
|
||||
| --------------^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15
|
||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15
|
||||
|
|
||||
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -9,6 +9,6 @@ const _: () = assert!(true);
|
||||
|
||||
const _: () = assert!(false);
|
||||
//[stock]~^ ERROR panicking in constants is unstable
|
||||
//[const_panic]~^^ ERROR any use of this value will cause an error
|
||||
//[const_panic]~^^ ERROR evaluation of constant value failed
|
||||
|
||||
fn main() {}
|
||||
|
14
src/test/ui/typeck/type-placeholder-fn-in-const.rs
Normal file
14
src/test/ui/typeck/type-placeholder-fn-in-const.rs
Normal file
@ -0,0 +1,14 @@
|
||||
struct MyStruct;
|
||||
|
||||
trait Test {
|
||||
const TEST: fn() -> _;
|
||||
//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures [E0121]
|
||||
//~| ERROR: the type placeholder `_` is not allowed within types on item signatures [E0121]
|
||||
}
|
||||
|
||||
impl Test for MyStruct {
|
||||
const TEST: fn() -> _ = 42;
|
||||
//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures [E0121]
|
||||
}
|
||||
|
||||
fn main() {}
|
21
src/test/ui/typeck/type-placeholder-fn-in-const.stderr
Normal file
21
src/test/ui/typeck/type-placeholder-fn-in-const.stderr
Normal file
@ -0,0 +1,21 @@
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/type-placeholder-fn-in-const.rs:4:25
|
||||
|
|
||||
LL | const TEST: fn() -> _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/type-placeholder-fn-in-const.rs:4:25
|
||||
|
|
||||
LL | const TEST: fn() -> _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/type-placeholder-fn-in-const.rs:10:25
|
||||
|
|
||||
LL | const TEST: fn() -> _ = 42;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0121`.
|
Loading…
Reference in New Issue
Block a user