Auto merge of #122803 - jhpratt:rollup-nmgs79k, r=jhpratt
Rollup of 8 pull requests Successful merges: - #122545 (Ignore paths from expansion in `unused_qualifications`) - #122729 (Relax SeqCst ordering in standard library.) - #122740 (use more accurate terminology) - #122749 (make `type_flags(ReError) & HAS_ERROR`) - #122764 (coverage: Remove incorrect assertions from counter allocation) - #122765 (Add `usize::MAX` arg tests for Vec) - #122776 (Rename `hir::Let` into `hir::LetExpr`) - #122786 (compiletest: Introduce `remove_and_create_dir_all()` helper) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
6a6cd6517d
90 changed files with 410 additions and 759 deletions
|
@ -157,7 +157,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
hir::ExprKind::AddrOf(*k, *m, ohs)
|
||||
}
|
||||
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
|
||||
hir::ExprKind::Let(self.arena.alloc(hir::Let {
|
||||
hir::ExprKind::Let(self.arena.alloc(hir::LetExpr {
|
||||
span: self.lower_span(*span),
|
||||
pat: self.lower_pat(pat),
|
||||
ty: None,
|
||||
|
|
|
@ -434,10 +434,6 @@ fn check_opaque_type_parameter_valid(
|
|||
// Only check the parent generics, which will ignore any of the
|
||||
// duplicated lifetime args that come from reifying late-bounds.
|
||||
for (i, arg) in opaque_type_key.args.iter().take(parent_generics.count()).enumerate() {
|
||||
if let Err(guar) = arg.error_reported() {
|
||||
return Err(guar);
|
||||
}
|
||||
|
||||
let arg_is_param = match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
|
||||
GenericArgKind::Lifetime(lt) if is_ty_alias => {
|
||||
|
|
|
@ -1259,7 +1259,7 @@ pub struct Arm<'hir> {
|
|||
/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
|
||||
/// the desugaring to if-let. Only let-else supports the type annotation at present.
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub struct Let<'hir> {
|
||||
pub struct LetExpr<'hir> {
|
||||
pub span: Span,
|
||||
pub pat: &'hir Pat<'hir>,
|
||||
pub ty: Option<&'hir Ty<'hir>>,
|
||||
|
@ -1852,7 +1852,7 @@ pub enum ExprKind<'hir> {
|
|||
///
|
||||
/// These are not `Local` and only occur as expressions.
|
||||
/// The `let Some(x) = foo()` in `if let Some(x) = foo()` is an example of `Let(..)`.
|
||||
Let(&'hir Let<'hir>),
|
||||
Let(&'hir LetExpr<'hir>),
|
||||
/// An `if` block, with an optional else block.
|
||||
///
|
||||
/// I.e., `if <expr> { <expr> } else { <expr> }`.
|
||||
|
|
|
@ -753,7 +753,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
|||
ExprKind::DropTemps(ref subexpression) => {
|
||||
try_visit!(visitor.visit_expr(subexpression));
|
||||
}
|
||||
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
|
||||
ExprKind::Let(LetExpr { span: _, pat, ty, init, is_recovered: _ }) => {
|
||||
// match the visit order in walk_local
|
||||
try_visit!(visitor.visit_expr(init));
|
||||
try_visit!(visitor.visit_pat(pat));
|
||||
|
|
|
@ -1387,7 +1387,7 @@ impl<'a> State<'a> {
|
|||
// Print `}`:
|
||||
self.bclose_maybe_open(expr.span, true);
|
||||
}
|
||||
hir::ExprKind::Let(&hir::Let { pat, ty, init, .. }) => {
|
||||
hir::ExprKind::Let(&hir::LetExpr { pat, ty, init, .. }) => {
|
||||
self.print_let(pat, ty, init);
|
||||
}
|
||||
hir::ExprKind::If(test, blk, elseopt) => {
|
||||
|
|
|
@ -317,7 +317,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err.note("`if` expressions without `else` evaluate to `()`");
|
||||
err.help("consider adding an `else` block that evaluates to the expected type");
|
||||
*error = true;
|
||||
if let ExprKind::Let(hir::Let { span, pat, init, .. }) = cond_expr.kind
|
||||
if let ExprKind::Let(hir::LetExpr { span, pat, init, .. }) = cond_expr.kind
|
||||
&& let ExprKind::Block(block, _) = then_expr.kind
|
||||
// Refutability checks occur on the MIR, so we approximate it here by checking
|
||||
// if we have an enum with a single variant or a struct in the pattern.
|
||||
|
|
|
@ -1261,7 +1261,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
|
||||
pub(super) fn check_expr_let(
|
||||
&self,
|
||||
let_expr: &'tcx hir::LetExpr<'tcx>,
|
||||
hir_id: HirId,
|
||||
) -> Ty<'tcx> {
|
||||
// for let statements, this is done in check_stmt
|
||||
let init = let_expr.init;
|
||||
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");
|
||||
|
|
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
hir::ExprKind::Let(hir::Let { pat, init, .. }) => {
|
||||
hir::ExprKind::Let(hir::LetExpr { pat, init, .. }) => {
|
||||
self.walk_local(init, pat, None, |t| t.borrow_expr(init, ty::ImmBorrow))
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ impl<'a> DeclOrigin<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A declaration is an abstraction of [hir::Local] and [hir::Let].
|
||||
/// A declaration is an abstraction of [hir::Local] and [hir::LetExpr].
|
||||
///
|
||||
/// It must have a hir_id, as this is how we connect gather_locals to the check functions.
|
||||
pub(super) struct Declaration<'a> {
|
||||
|
@ -48,9 +48,9 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<(&'a hir::Let<'a>, hir::HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::Let<'a>, hir::HirId)) -> Self {
|
||||
let hir::Let { pat, ty, span, init, is_recovered: _ } = *let_expr;
|
||||
impl<'a> From<(&'a hir::LetExpr<'a>, hir::HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, hir::HirId)) -> Self {
|
||||
let hir::LetExpr { pat, ty, span, init, is_recovered: _ } = *let_expr;
|
||||
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
cause: &ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> InferResult<'tcx, ()> {
|
||||
if a.references_error() || b.references_error() {
|
||||
return Ok(InferOk { value: (), obligations: vec![] });
|
||||
}
|
||||
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
|
||||
let def_id = def_id.expect_local();
|
||||
|
|
|
@ -251,6 +251,7 @@ impl<'tcx> Region<'tcx> {
|
|||
}
|
||||
ty::ReError(_) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::fmt::{self, Debug};
|
||||
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::graph::WithNumNodes;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::mir::coverage::*;
|
||||
use rustc_middle::mir::coverage::{CounterId, CovTerm, Expression, ExpressionId, Op};
|
||||
|
||||
use super::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverageGraphWithLoops};
|
||||
|
||||
use std::fmt::{self, Debug};
|
||||
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverageGraphWithLoops};
|
||||
|
||||
/// The coverage counter or counter expression associated with a particular
|
||||
/// BCB node or BCB edge.
|
||||
|
@ -18,10 +17,6 @@ pub(super) enum BcbCounter {
|
|||
}
|
||||
|
||||
impl BcbCounter {
|
||||
fn is_expression(&self) -> bool {
|
||||
matches!(self, Self::Expression { .. })
|
||||
}
|
||||
|
||||
pub(super) fn as_term(&self) -> CovTerm {
|
||||
match *self {
|
||||
BcbCounter::Counter { id, .. } => CovTerm::Counter(id),
|
||||
|
@ -60,10 +55,6 @@ pub(super) struct CoverageCounters {
|
|||
/// We currently don't iterate over this map, but if we do in the future,
|
||||
/// switch it back to `FxIndexMap` to avoid query stability hazards.
|
||||
bcb_edge_counters: FxHashMap<(BasicCoverageBlock, BasicCoverageBlock), BcbCounter>,
|
||||
/// Tracks which BCBs have a counter associated with some incoming edge.
|
||||
/// Only used by assertions, to verify that BCBs with incoming edge
|
||||
/// counters do not have their own physical counters (expressions are allowed).
|
||||
bcb_has_incoming_edge_counters: BitSet<BasicCoverageBlock>,
|
||||
/// Table of expression data, associating each expression ID with its
|
||||
/// corresponding operator (+ or -) and its LHS/RHS operands.
|
||||
expressions: IndexVec<ExpressionId, Expression>,
|
||||
|
@ -83,7 +74,6 @@ impl CoverageCounters {
|
|||
counter_increment_sites: IndexVec::new(),
|
||||
bcb_counters: IndexVec::from_elem_n(None, num_bcbs),
|
||||
bcb_edge_counters: FxHashMap::default(),
|
||||
bcb_has_incoming_edge_counters: BitSet::new_empty(num_bcbs),
|
||||
expressions: IndexVec::new(),
|
||||
};
|
||||
|
||||
|
@ -122,14 +112,6 @@ impl CoverageCounters {
|
|||
}
|
||||
|
||||
fn set_bcb_counter(&mut self, bcb: BasicCoverageBlock, counter_kind: BcbCounter) -> BcbCounter {
|
||||
assert!(
|
||||
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
|
||||
// have an expression (to be injected into an existing `BasicBlock` represented by this
|
||||
// `BasicCoverageBlock`).
|
||||
counter_kind.is_expression() || !self.bcb_has_incoming_edge_counters.contains(bcb),
|
||||
"attempt to add a `Counter` to a BCB target with existing incoming edge counters"
|
||||
);
|
||||
|
||||
if let Some(replaced) = self.bcb_counters[bcb].replace(counter_kind) {
|
||||
bug!(
|
||||
"attempt to set a BasicCoverageBlock coverage counter more than once; \
|
||||
|
@ -146,19 +128,6 @@ impl CoverageCounters {
|
|||
to_bcb: BasicCoverageBlock,
|
||||
counter_kind: BcbCounter,
|
||||
) -> BcbCounter {
|
||||
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
|
||||
// have an expression (to be injected into an existing `BasicBlock` represented by this
|
||||
// `BasicCoverageBlock`).
|
||||
if let Some(node_counter) = self.bcb_counter(to_bcb)
|
||||
&& !node_counter.is_expression()
|
||||
{
|
||||
bug!(
|
||||
"attempt to add an incoming edge counter from {from_bcb:?} \
|
||||
when the target BCB already has {node_counter:?}"
|
||||
);
|
||||
}
|
||||
|
||||
self.bcb_has_incoming_edge_counters.insert(to_bcb);
|
||||
if let Some(replaced) = self.bcb_edge_counters.insert((from_bcb, to_bcb), counter_kind) {
|
||||
bug!(
|
||||
"attempt to set an edge counter more than once; from_bcb: \
|
||||
|
|
|
@ -4672,7 +4672,9 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
if path.iter().any(|seg| seg.ident.span.from_expansion()) {
|
||||
if finalize.path_span.from_expansion()
|
||||
|| path.iter().any(|seg| seg.ident.span.from_expansion())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ bitflags! {
|
|||
| TypeFlags::HAS_TY_INHERENT.bits()
|
||||
| TypeFlags::HAS_CT_PROJECTION.bits();
|
||||
|
||||
/// Is an error type/const reachable?
|
||||
/// Is an error type/lifetime/const reachable?
|
||||
const HAS_ERROR = 1 << 15;
|
||||
|
||||
/// Does this have any region that "appears free" in the type?
|
||||
|
|
|
@ -915,6 +915,6 @@
|
|||
# Available options: fast, balanced, best
|
||||
#compression-profile = "fast"
|
||||
|
||||
# Copy the linker, DLLs, and various libraries from MinGW into the rustc toolchain.
|
||||
# Copy the linker, DLLs, and various libraries from MinGW into the Rust toolchain.
|
||||
# Only applies when the host or target is pc-windows-gnu.
|
||||
#include-mingw-linker = true
|
||||
|
|
|
@ -233,7 +233,7 @@ macro_rules! acquire {
|
|||
/// let val = Arc::clone(&val);
|
||||
///
|
||||
/// thread::spawn(move || {
|
||||
/// let v = val.fetch_add(1, Ordering::SeqCst);
|
||||
/// let v = val.fetch_add(1, Ordering::Relaxed);
|
||||
/// println!("{v:?}");
|
||||
/// });
|
||||
/// }
|
||||
|
|
|
@ -2643,3 +2643,44 @@ fn test_vec_from_array_ref() {
|
|||
fn test_vec_from_array_mut_ref() {
|
||||
assert_eq!(Vec::from(&mut [1, 2, 3]), vec![1, 2, 3]);
|
||||
}
|
||||
|
||||
/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments
|
||||
/// in the stdlib. Draining and extending the allocation are fairly well-tested earlier, but
|
||||
/// `vec.insert(usize::MAX, val)` once slipped by!
|
||||
///
|
||||
/// All code that manipulates the collection types should be tested with "trivially wrong" args.
|
||||
#[test]
|
||||
fn max_dont_panic() {
|
||||
let mut v = vec![0];
|
||||
let _ = v.get(usize::MAX);
|
||||
v.shrink_to(usize::MAX);
|
||||
v.truncate(usize::MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn max_insert() {
|
||||
let mut v = vec![0];
|
||||
v.insert(usize::MAX, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn max_remove() {
|
||||
let mut v = vec![0];
|
||||
v.remove(usize::MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn max_splice() {
|
||||
let mut v = vec![0];
|
||||
v.splice(usize::MAX.., core::iter::once(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn max_swap_remove() {
|
||||
let mut v = vec![0];
|
||||
v.swap_remove(usize::MAX);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,7 @@ use crate::ptr;
|
|||
/// use std::alloc::{GlobalAlloc, Layout};
|
||||
/// use std::cell::UnsafeCell;
|
||||
/// use std::ptr::null_mut;
|
||||
/// use std::sync::atomic::{
|
||||
/// AtomicUsize,
|
||||
/// Ordering::{Acquire, SeqCst},
|
||||
/// };
|
||||
/// use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
///
|
||||
/// const ARENA_SIZE: usize = 128 * 1024;
|
||||
/// const MAX_SUPPORTED_ALIGN: usize = 4096;
|
||||
|
@ -61,7 +58,7 @@ use crate::ptr;
|
|||
/// let mut allocated = 0;
|
||||
/// if self
|
||||
/// .remaining
|
||||
/// .fetch_update(SeqCst, SeqCst, |mut remaining| {
|
||||
/// .fetch_update(Relaxed, Relaxed, |mut remaining| {
|
||||
/// if size > remaining {
|
||||
/// return None;
|
||||
/// }
|
||||
|
@ -81,7 +78,7 @@ use crate::ptr;
|
|||
///
|
||||
/// fn main() {
|
||||
/// let _s = format!("allocating a string!");
|
||||
/// let currently = ALLOCATOR.remaining.load(Acquire);
|
||||
/// let currently = ALLOCATOR.remaining.load(Relaxed);
|
||||
/// println!("allocated so far: {}", ARENA_SIZE - currently);
|
||||
/// }
|
||||
/// ```
|
||||
|
|
|
@ -84,7 +84,7 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
|
|||
super::__rust_foreign_exception();
|
||||
}
|
||||
|
||||
let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::SeqCst);
|
||||
let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed);
|
||||
if was_caught {
|
||||
// Since cleanup() isn't allowed to panic, we just abort instead.
|
||||
intrinsics::abort();
|
||||
|
|
|
@ -21,7 +21,7 @@ impl<T> OwnedStore<T> {
|
|||
pub(super) fn new(counter: &'static AtomicU32) -> Self {
|
||||
// Ensure the handle counter isn't 0, which would panic later,
|
||||
// when `NonZero::new` (aka `Handle::new`) is called in `alloc`.
|
||||
assert_ne!(counter.load(Ordering::SeqCst), 0);
|
||||
assert_ne!(counter.load(Ordering::Relaxed), 0);
|
||||
|
||||
OwnedStore { counter, data: BTreeMap::new() }
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ impl<T> OwnedStore<T> {
|
|||
|
||||
impl<T> OwnedStore<T> {
|
||||
pub(super) fn alloc(&mut self, x: T) -> Handle {
|
||||
let counter = self.counter.fetch_add(1, Ordering::SeqCst);
|
||||
let counter = self.counter.fetch_add(1, Ordering::Relaxed);
|
||||
let handle = Handle::new(counter).expect("`proc_macro` handle counter overflowed");
|
||||
assert!(self.data.insert(handle, x).is_none());
|
||||
handle
|
||||
|
|
|
@ -329,7 +329,7 @@ static HOOK: AtomicPtr<()> = AtomicPtr::new(ptr::null_mut());
|
|||
/// ```
|
||||
#[unstable(feature = "alloc_error_hook", issue = "51245")]
|
||||
pub fn set_alloc_error_hook(hook: fn(Layout)) {
|
||||
HOOK.store(hook as *mut (), Ordering::SeqCst);
|
||||
HOOK.store(hook as *mut (), Ordering::Release);
|
||||
}
|
||||
|
||||
/// Unregisters the current allocation error hook, returning it.
|
||||
|
@ -339,7 +339,7 @@ pub fn set_alloc_error_hook(hook: fn(Layout)) {
|
|||
/// If no custom hook is registered, the default hook will be returned.
|
||||
#[unstable(feature = "alloc_error_hook", issue = "51245")]
|
||||
pub fn take_alloc_error_hook() -> fn(Layout) {
|
||||
let hook = HOOK.swap(ptr::null_mut(), Ordering::SeqCst);
|
||||
let hook = HOOK.swap(ptr::null_mut(), Ordering::Acquire);
|
||||
if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } }
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ fn default_alloc_error_hook(layout: Layout) {
|
|||
#[alloc_error_handler]
|
||||
#[unstable(feature = "alloc_internals", issue = "none")]
|
||||
pub fn rust_oom(layout: Layout) -> ! {
|
||||
let hook = HOOK.load(Ordering::SeqCst);
|
||||
let hook = HOOK.load(Ordering::Acquire);
|
||||
let hook: fn(Layout) =
|
||||
if hook.is_null() { default_alloc_error_hook } else { unsafe { mem::transmute(hook) } };
|
||||
hook(layout);
|
||||
|
|
|
@ -7,12 +7,12 @@ use crate::sync::atomic::{AtomicUsize, Ordering};
|
|||
static PORT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn next_test_ip4() -> SocketAddr {
|
||||
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
|
||||
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
|
||||
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port))
|
||||
}
|
||||
|
||||
pub fn next_test_ip6() -> SocketAddr {
|
||||
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
|
||||
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
|
||||
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), port, 0, 0))
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ fn default_hook(info: &PanicInfo<'_>) {
|
|||
drop(backtrace::print(err, crate::backtrace_rs::PrintFmt::Full))
|
||||
}
|
||||
Some(BacktraceStyle::Off) => {
|
||||
if FIRST_PANIC.swap(false, Ordering::SeqCst) {
|
||||
if FIRST_PANIC.swap(false, Ordering::Relaxed) {
|
||||
let _ = writeln!(
|
||||
err,
|
||||
"note: run with `RUST_BACKTRACE=1` environment variable to display a \
|
||||
|
|
|
@ -170,14 +170,14 @@ fn wait_timeout_wake() {
|
|||
let t = thread::spawn(move || {
|
||||
let _g = m2.lock().unwrap();
|
||||
thread::sleep(Duration::from_millis(1));
|
||||
notified_copy.store(true, Ordering::SeqCst);
|
||||
notified_copy.store(true, Ordering::Relaxed);
|
||||
c2.notify_one();
|
||||
});
|
||||
let (g, timeout_res) = c.wait_timeout(g, Duration::from_millis(u64::MAX)).unwrap();
|
||||
assert!(!timeout_res.timed_out());
|
||||
// spurious wakeups mean this isn't necessarily true
|
||||
// so execute test again, if not notified
|
||||
if !notified.load(Ordering::SeqCst) {
|
||||
if !notified.load(Ordering::Relaxed) {
|
||||
t.join().unwrap();
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::marker::PhantomPinned;
|
|||
use crate::pin::Pin;
|
||||
use crate::ptr::addr_of_mut;
|
||||
use crate::sync::atomic::AtomicUsize;
|
||||
use crate::sync::atomic::Ordering::SeqCst;
|
||||
use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
|
||||
#[cfg(not(target_os = "nto"))]
|
||||
use crate::sys::time::TIMESPEC_MAX;
|
||||
#[cfg(target_os = "nto")]
|
||||
|
@ -150,16 +150,18 @@ impl Parker {
|
|||
|
||||
// This implementation doesn't require `unsafe`, but other implementations
|
||||
// may assume this is only called by the thread that owns the Parker.
|
||||
//
|
||||
// For memory ordering, see std/src/sys_common/thread_parking/futex.rs
|
||||
pub unsafe fn park(self: Pin<&Self>) {
|
||||
// If we were previously notified then we consume this notification and
|
||||
// return quickly.
|
||||
if self.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst).is_ok() {
|
||||
if self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Relaxed).is_ok() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise we need to coordinate going to sleep
|
||||
lock(self.lock.get());
|
||||
match self.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) {
|
||||
match self.state.compare_exchange(EMPTY, PARKED, Relaxed, Relaxed) {
|
||||
Ok(_) => {}
|
||||
Err(NOTIFIED) => {
|
||||
// We must read here, even though we know it will be `NOTIFIED`.
|
||||
|
@ -168,7 +170,7 @@ impl Parker {
|
|||
// acquire operation that synchronizes with that `unpark` to observe
|
||||
// any writes it made before the call to unpark. To do that we must
|
||||
// read from the write it made to `state`.
|
||||
let old = self.state.swap(EMPTY, SeqCst);
|
||||
let old = self.state.swap(EMPTY, Acquire);
|
||||
|
||||
unlock(self.lock.get());
|
||||
|
||||
|
@ -185,7 +187,7 @@ impl Parker {
|
|||
loop {
|
||||
wait(self.cvar.get(), self.lock.get());
|
||||
|
||||
match self.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst) {
|
||||
match self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Relaxed) {
|
||||
Ok(_) => break, // got a notification
|
||||
Err(_) => {} // spurious wakeup, go back to sleep
|
||||
}
|
||||
|
@ -201,16 +203,16 @@ impl Parker {
|
|||
// Like `park` above we have a fast path for an already-notified thread, and
|
||||
// afterwards we start coordinating for a sleep.
|
||||
// return quickly.
|
||||
if self.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst).is_ok() {
|
||||
if self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Relaxed).is_ok() {
|
||||
return;
|
||||
}
|
||||
|
||||
lock(self.lock.get());
|
||||
match self.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) {
|
||||
match self.state.compare_exchange(EMPTY, PARKED, Relaxed, Relaxed) {
|
||||
Ok(_) => {}
|
||||
Err(NOTIFIED) => {
|
||||
// We must read again here, see `park`.
|
||||
let old = self.state.swap(EMPTY, SeqCst);
|
||||
let old = self.state.swap(EMPTY, Acquire);
|
||||
unlock(self.lock.get());
|
||||
|
||||
assert_eq!(old, NOTIFIED, "park state changed unexpectedly");
|
||||
|
@ -228,7 +230,7 @@ impl Parker {
|
|||
// parked.
|
||||
wait_timeout(self.cvar.get(), self.lock.get(), dur);
|
||||
|
||||
match self.state.swap(EMPTY, SeqCst) {
|
||||
match self.state.swap(EMPTY, Acquire) {
|
||||
NOTIFIED => unlock(self.lock.get()), // got a notification, hurray!
|
||||
PARKED => unlock(self.lock.get()), // no notification, alas
|
||||
n => {
|
||||
|
@ -245,7 +247,7 @@ impl Parker {
|
|||
// `state` is already `NOTIFIED`. That is why this must be a swap
|
||||
// rather than a compare-and-swap that returns if it reads `NOTIFIED`
|
||||
// on failure.
|
||||
match self.state.swap(NOTIFIED, SeqCst) {
|
||||
match self.state.swap(NOTIFIED, Release) {
|
||||
EMPTY => return, // no one was waiting
|
||||
NOTIFIED => return, // already unparked
|
||||
PARKED => {} // gotta go wake someone up
|
||||
|
|
|
@ -57,7 +57,10 @@ unsafe impl GlobalAlloc for System {
|
|||
|
||||
#[cfg(target_feature = "atomics")]
|
||||
mod lock {
|
||||
use crate::sync::atomic::{AtomicI32, Ordering::SeqCst};
|
||||
use crate::sync::atomic::{
|
||||
AtomicI32,
|
||||
Ordering::{Acquire, Release},
|
||||
};
|
||||
|
||||
static LOCKED: AtomicI32 = AtomicI32::new(0);
|
||||
|
||||
|
@ -65,7 +68,7 @@ mod lock {
|
|||
|
||||
pub fn lock() -> DropLock {
|
||||
loop {
|
||||
if LOCKED.swap(1, SeqCst) == 0 {
|
||||
if LOCKED.swap(1, Acquire) == 0 {
|
||||
return DropLock;
|
||||
}
|
||||
// Ok so here's where things get a little depressing. At this point
|
||||
|
@ -143,7 +146,7 @@ mod lock {
|
|||
|
||||
impl Drop for DropLock {
|
||||
fn drop(&mut self) {
|
||||
let r = LOCKED.swap(0, SeqCst);
|
||||
let r = LOCKED.swap(0, Release);
|
||||
debug_assert_eq!(r, 1);
|
||||
|
||||
// Note that due to the above logic we don't actually need to wake
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::path::Path;
|
|||
use crate::ptr;
|
||||
use crate::slice;
|
||||
use crate::sync::atomic::AtomicUsize;
|
||||
use crate::sync::atomic::Ordering::SeqCst;
|
||||
use crate::sync::atomic::Ordering::Relaxed;
|
||||
use crate::sys::c;
|
||||
use crate::sys::fs::{File, OpenOptions};
|
||||
use crate::sys::handle::Handle;
|
||||
|
@ -214,11 +214,11 @@ pub fn spawn_pipe_relay(
|
|||
fn random_number() -> usize {
|
||||
static N: AtomicUsize = AtomicUsize::new(0);
|
||||
loop {
|
||||
if N.load(SeqCst) != 0 {
|
||||
return N.fetch_add(1, SeqCst);
|
||||
if N.load(Relaxed) != 0 {
|
||||
return N.fetch_add(1, Relaxed);
|
||||
}
|
||||
|
||||
N.store(hashmap_random_keys().0 as usize, SeqCst);
|
||||
N.store(hashmap_random_keys().0 as usize, Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,10 @@ unsafe impl GlobalAlloc for System {
|
|||
}
|
||||
|
||||
mod lock {
|
||||
use crate::sync::atomic::{AtomicI32, Ordering::SeqCst};
|
||||
use crate::sync::atomic::{
|
||||
AtomicI32,
|
||||
Ordering::{Acquire, Release},
|
||||
};
|
||||
|
||||
static LOCKED: AtomicI32 = AtomicI32::new(0);
|
||||
|
||||
|
@ -54,7 +57,7 @@ mod lock {
|
|||
|
||||
pub fn lock() -> DropLock {
|
||||
loop {
|
||||
if LOCKED.swap(1, SeqCst) == 0 {
|
||||
if LOCKED.swap(1, Acquire) == 0 {
|
||||
return DropLock;
|
||||
}
|
||||
crate::os::xous::ffi::do_yield();
|
||||
|
@ -63,7 +66,7 @@ mod lock {
|
|||
|
||||
impl Drop for DropLock {
|
||||
fn drop(&mut self) {
|
||||
let r = LOCKED.swap(0, SeqCst);
|
||||
let r = LOCKED.swap(0, Release);
|
||||
debug_assert_eq!(r, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ impl TcpStream {
|
|||
}
|
||||
|
||||
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||
self.nonblocking.store(nonblocking, Ordering::SeqCst);
|
||||
self.nonblocking.store(nonblocking, Ordering::Relaxed);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::mem::ManuallyDrop;
|
|||
use crate::ptr;
|
||||
use crate::sync::atomic::AtomicPtr;
|
||||
use crate::sync::atomic::AtomicUsize;
|
||||
use crate::sync::atomic::Ordering::SeqCst;
|
||||
use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
|
||||
use core::arch::asm;
|
||||
|
||||
use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags};
|
||||
|
@ -92,7 +92,7 @@ fn tls_table() -> &'static mut [*mut u8] {
|
|||
pub unsafe fn create(dtor: Option<Dtor>) -> Key {
|
||||
// Allocate a new TLS key. These keys are shared among all threads.
|
||||
#[allow(unused_unsafe)]
|
||||
let key = unsafe { TLS_KEY_INDEX.fetch_add(1, SeqCst) };
|
||||
let key = unsafe { TLS_KEY_INDEX.fetch_add(1, Relaxed) };
|
||||
if let Some(f) = dtor {
|
||||
unsafe { register_dtor(key, f) };
|
||||
}
|
||||
|
@ -154,11 +154,11 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
|
|||
let mut node = ManuallyDrop::new(Box::new(Node { key, dtor, next: ptr::null_mut() }));
|
||||
|
||||
#[allow(unused_unsafe)]
|
||||
let mut head = unsafe { DTORS.load(SeqCst) };
|
||||
let mut head = unsafe { DTORS.load(Acquire) };
|
||||
loop {
|
||||
node.next = head;
|
||||
#[allow(unused_unsafe)]
|
||||
match unsafe { DTORS.compare_exchange(head, &mut **node, SeqCst, SeqCst) } {
|
||||
match unsafe { DTORS.compare_exchange(head, &mut **node, Release, Acquire) } {
|
||||
Ok(_) => return, // nothing to drop, we successfully added the node to the list
|
||||
Err(cur) => head = cur,
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ unsafe fn run_dtors() {
|
|||
}
|
||||
any_run = false;
|
||||
#[allow(unused_unsafe)]
|
||||
let mut cur = unsafe { DTORS.load(SeqCst) };
|
||||
let mut cur = unsafe { DTORS.load(Acquire) };
|
||||
while !cur.is_null() {
|
||||
let ptr = unsafe { get((*cur).key) };
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use crate::os::xous::ffi::{blocking_scalar, do_yield};
|
||||
use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
|
||||
use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering::Relaxed, Ordering::SeqCst};
|
||||
use crate::sync::atomic::{
|
||||
AtomicBool, AtomicUsize,
|
||||
Ordering::{Acquire, Relaxed, Release},
|
||||
};
|
||||
|
||||
pub struct Mutex {
|
||||
/// The "locked" value indicates how many threads are waiting on this
|
||||
|
@ -68,7 +71,7 @@ impl Mutex {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn unlock(&self) {
|
||||
let prev = self.locked.fetch_sub(1, SeqCst);
|
||||
let prev = self.locked.fetch_sub(1, Release);
|
||||
|
||||
// If the previous value was 1, then this was a "fast path" unlock, so no
|
||||
// need to involve the Ticktimer server
|
||||
|
@ -89,12 +92,12 @@ impl Mutex {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn try_lock(&self) -> bool {
|
||||
self.locked.compare_exchange(0, 1, SeqCst, SeqCst).is_ok()
|
||||
self.locked.compare_exchange(0, 1, Acquire, Relaxed).is_ok()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn try_lock_or_poison(&self) -> bool {
|
||||
self.locked.fetch_add(1, SeqCst) == 0
|
||||
self.locked.fetch_add(1, Acquire) == 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ impl StaticKey {
|
|||
|
||||
#[inline]
|
||||
unsafe fn key(&self) -> imp::Key {
|
||||
match self.key.load(Ordering::Relaxed) {
|
||||
match self.key.load(Ordering::Acquire) {
|
||||
KEY_SENTVAL => self.lazy_init() as imp::Key,
|
||||
n => n as imp::Key,
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ impl StaticKey {
|
|||
match self.key.compare_exchange(
|
||||
KEY_SENTVAL,
|
||||
key as usize,
|
||||
Ordering::SeqCst,
|
||||
Ordering::SeqCst,
|
||||
Ordering::Release,
|
||||
Ordering::Acquire,
|
||||
) {
|
||||
// The CAS succeeded, so we've created the actual key
|
||||
Ok(_) => key as usize,
|
||||
|
|
|
@ -255,6 +255,9 @@ fn join_orders_after_tls_destructors() {
|
|||
// observe the channel in the `THREAD1_WAITING` state. If this does occur,
|
||||
// we switch to the “poison” state `THREAD2_JOINED` and panic all around.
|
||||
// (This is equivalent to “sending” from an alternate producer thread.)
|
||||
//
|
||||
// Relaxed memory ordering is fine because and spawn()/join() already provide all the
|
||||
// synchronization we need here.
|
||||
const FRESH: u8 = 0;
|
||||
const THREAD2_LAUNCHED: u8 = 1;
|
||||
const THREAD1_WAITING: u8 = 2;
|
||||
|
@ -263,7 +266,7 @@ fn join_orders_after_tls_destructors() {
|
|||
static SYNC_STATE: AtomicU8 = AtomicU8::new(FRESH);
|
||||
|
||||
for _ in 0..10 {
|
||||
SYNC_STATE.store(FRESH, Ordering::SeqCst);
|
||||
SYNC_STATE.store(FRESH, Ordering::Relaxed);
|
||||
|
||||
let jh = thread::Builder::new()
|
||||
.name("thread1".into())
|
||||
|
@ -272,7 +275,7 @@ fn join_orders_after_tls_destructors() {
|
|||
|
||||
impl Drop for TlDrop {
|
||||
fn drop(&mut self) {
|
||||
let mut sync_state = SYNC_STATE.swap(THREAD1_WAITING, Ordering::SeqCst);
|
||||
let mut sync_state = SYNC_STATE.swap(THREAD1_WAITING, Ordering::Relaxed);
|
||||
loop {
|
||||
match sync_state {
|
||||
THREAD2_LAUNCHED | THREAD1_WAITING => thread::yield_now(),
|
||||
|
@ -282,7 +285,7 @@ fn join_orders_after_tls_destructors() {
|
|||
),
|
||||
v => unreachable!("sync state: {}", v),
|
||||
}
|
||||
sync_state = SYNC_STATE.load(Ordering::SeqCst);
|
||||
sync_state = SYNC_STATE.load(Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +297,7 @@ fn join_orders_after_tls_destructors() {
|
|||
TL_DROP.with(|_| {});
|
||||
|
||||
loop {
|
||||
match SYNC_STATE.load(Ordering::SeqCst) {
|
||||
match SYNC_STATE.load(Ordering::Relaxed) {
|
||||
FRESH => thread::yield_now(),
|
||||
THREAD2_LAUNCHED => break,
|
||||
v => unreachable!("sync state: {}", v),
|
||||
|
@ -306,9 +309,9 @@ fn join_orders_after_tls_destructors() {
|
|||
let jh2 = thread::Builder::new()
|
||||
.name("thread2".into())
|
||||
.spawn(move || {
|
||||
assert_eq!(SYNC_STATE.swap(THREAD2_LAUNCHED, Ordering::SeqCst), FRESH);
|
||||
assert_eq!(SYNC_STATE.swap(THREAD2_LAUNCHED, Ordering::Relaxed), FRESH);
|
||||
jh.join().unwrap();
|
||||
match SYNC_STATE.swap(THREAD2_JOINED, Ordering::SeqCst) {
|
||||
match SYNC_STATE.swap(THREAD2_JOINED, Ordering::Relaxed) {
|
||||
MAIN_THREAD_RENDEZVOUS => return,
|
||||
THREAD2_LAUNCHED | THREAD1_WAITING => {
|
||||
panic!("Thread 2 running after thread 1 join before main thread rendezvous")
|
||||
|
@ -322,8 +325,8 @@ fn join_orders_after_tls_destructors() {
|
|||
match SYNC_STATE.compare_exchange(
|
||||
THREAD1_WAITING,
|
||||
MAIN_THREAD_RENDEZVOUS,
|
||||
Ordering::SeqCst,
|
||||
Ordering::SeqCst,
|
||||
Ordering::Relaxed,
|
||||
Ordering::Relaxed,
|
||||
) {
|
||||
Ok(_) => break,
|
||||
Err(FRESH) => thread::yield_now(),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use rustc_hir::{intravisit, Body, Expr, ExprKind, FnDecl, Let, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_hir::{intravisit, Body, Expr, ExprKind, FnDecl, LetExpr, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty;
|
||||
|
@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let ExprKind::Let(Let { pat, .. }) = expr.kind {
|
||||
if let ExprKind::Let(LetExpr { pat, .. }) = expr.kind {
|
||||
apply_lint(cx, pat, DerefPossible::Possible);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::hir_id::ItemLocalId;
|
||||
use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, Let, Node, Pat, PatKind, QPath, UnOp};
|
||||
use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, LetExpr, Node, Pat, PatKind, QPath, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
@ -238,7 +238,7 @@ fn find_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'
|
|||
let init = match node {
|
||||
Node::Arm(_) | Node::Pat(_) => continue,
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
ExprKind::Match(e, _, _) | ExprKind::Let(&Let { init: e, .. }) => Some(e),
|
||||
ExprKind::Match(e, _, _) | ExprKind::Let(&LetExpr { init: e, .. }) => Some(e),
|
||||
_ => None,
|
||||
},
|
||||
Node::Local(local) => local.init,
|
||||
|
|
|
@ -131,7 +131,7 @@ fn non_consuming_ok_arm<'a>(cx: &LateContext<'a>, arm: &hir::Arm<'a>) -> bool {
|
|||
fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) {
|
||||
match expr.kind {
|
||||
hir::ExprKind::If(cond, _, _)
|
||||
if let ExprKind::Let(hir::Let { pat, init, .. }) = cond.kind
|
||||
if let ExprKind::Let(hir::LetExpr { pat, init, .. }) = cond.kind
|
||||
&& is_ok_wild_or_dotdot_pattern(cx, pat)
|
||||
&& let Some(op) = should_lint(cx, init) =>
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ impl<'hir> IfLet<'hir> {
|
|||
if let ExprKind::If(
|
||||
Expr {
|
||||
kind:
|
||||
ExprKind::Let(&hir::Let {
|
||||
ExprKind::Let(&hir::LetExpr {
|
||||
pat: let_pat,
|
||||
init: let_expr,
|
||||
span: let_span,
|
||||
|
@ -379,7 +379,7 @@ impl<'hir> WhileLet<'hir> {
|
|||
ExprKind::If(
|
||||
Expr {
|
||||
kind:
|
||||
ExprKind::Let(&hir::Let {
|
||||
ExprKind::Let(&hir::LetExpr {
|
||||
pat: let_pat,
|
||||
init: let_expr,
|
||||
span: let_span,
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_hir::def::Res;
|
|||
use rustc_hir::MatchSource::TryDesugar;
|
||||
use rustc_hir::{
|
||||
ArrayLen, BinOpKind, BindingAnnotation, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg,
|
||||
GenericArgs, HirId, HirIdMap, InlineAsmOperand, Let, Lifetime, LifetimeName, Pat, PatField, PatKind, Path,
|
||||
GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, LifetimeName, Pat, PatField, PatKind, Path,
|
||||
PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding,
|
||||
};
|
||||
use rustc_lexer::{tokenize, TokenKind};
|
||||
|
@ -837,7 +837,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
},
|
||||
ExprKind::Let(Let { pat, init, ty, .. }) => {
|
||||
ExprKind::Let(LetExpr { pat, init, ty, .. }) => {
|
||||
self.hash_expr(init);
|
||||
if let Some(ty) = ty {
|
||||
self.hash_ty(ty);
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::intravisit::{self, walk_block, walk_expr, Visitor};
|
||||
use rustc_hir::{
|
||||
AnonConst, Arm, Block, BlockCheckMode, Body, BodyId, Expr, ExprKind, HirId, ItemId, ItemKind, Let, Pat, QPath,
|
||||
AnonConst, Arm, Block, BlockCheckMode, Body, BodyId, Expr, ExprKind, HirId, ItemId, ItemKind, LetExpr, Pat, QPath,
|
||||
Stmt, UnOp, UnsafeSource, Unsafety,
|
||||
};
|
||||
use rustc_lint::LateContext;
|
||||
|
@ -624,7 +624,7 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
|
|||
| ExprKind::Field(e, _)
|
||||
| ExprKind::Unary(UnOp::Deref, e)
|
||||
| ExprKind::Match(e, ..)
|
||||
| ExprKind::Let(&Let { init: e, .. }) => {
|
||||
| ExprKind::Let(&LetExpr { init: e, .. }) => {
|
||||
helper(typeck, false, e, f)?;
|
||||
},
|
||||
ExprKind::Block(&Block { expr: Some(e), .. }, _) | ExprKind::Cast(e, _) | ExprKind::Unary(_, e) => {
|
||||
|
|
|
@ -198,6 +198,11 @@ pub fn compute_stamp_hash(config: &Config) -> String {
|
|||
format!("{:x}", hash.finish())
|
||||
}
|
||||
|
||||
fn remove_and_create_dir_all(path: &Path) {
|
||||
let _ = fs::remove_dir_all(path);
|
||||
fs::create_dir_all(path).unwrap();
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct TestCx<'test> {
|
||||
config: &'test Config,
|
||||
|
@ -998,8 +1003,7 @@ impl<'test> TestCx<'test> {
|
|||
let mut rustc = Command::new(&self.config.rustc_path);
|
||||
|
||||
let out_dir = self.output_base_name().with_extension("pretty-out");
|
||||
let _ = fs::remove_dir_all(&out_dir);
|
||||
create_dir_all(&out_dir).unwrap();
|
||||
remove_and_create_dir_all(&out_dir);
|
||||
|
||||
let target = if self.props.force_host { &*self.config.host } else { &*self.config.target };
|
||||
|
||||
|
@ -2094,14 +2098,12 @@ impl<'test> TestCx<'test> {
|
|||
let aux_dir = self.aux_output_dir_name();
|
||||
|
||||
if !self.props.aux_builds.is_empty() {
|
||||
let _ = fs::remove_dir_all(&aux_dir);
|
||||
create_dir_all(&aux_dir).unwrap();
|
||||
remove_and_create_dir_all(&aux_dir);
|
||||
}
|
||||
|
||||
if !self.props.aux_bins.is_empty() {
|
||||
let aux_bin_dir = self.aux_bin_output_dir_name();
|
||||
let _ = fs::remove_dir_all(&aux_bin_dir);
|
||||
create_dir_all(&aux_bin_dir).unwrap();
|
||||
remove_and_create_dir_all(&aux_bin_dir);
|
||||
}
|
||||
|
||||
aux_dir
|
||||
|
@ -2469,8 +2471,7 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
|
||||
let mir_dump_dir = self.get_mir_dump_dir();
|
||||
let _ = fs::remove_dir_all(&mir_dump_dir);
|
||||
create_dir_all(mir_dump_dir.as_path()).unwrap();
|
||||
remove_and_create_dir_all(&mir_dump_dir);
|
||||
let mut dir_opt = "-Zdump-mir-dir=".to_string();
|
||||
dir_opt.push_str(mir_dump_dir.to_str().unwrap());
|
||||
debug!("dir_opt: {:?}", dir_opt);
|
||||
|
@ -2951,8 +2952,7 @@ impl<'test> TestCx<'test> {
|
|||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
let out_dir = self.output_base_dir();
|
||||
let _ = fs::remove_dir_all(&out_dir);
|
||||
create_dir_all(&out_dir).unwrap();
|
||||
remove_and_create_dir_all(&out_dir);
|
||||
|
||||
let proc_res = self.document(&out_dir);
|
||||
if !proc_res.status.success() {
|
||||
|
@ -2986,9 +2986,7 @@ impl<'test> TestCx<'test> {
|
|||
let suffix =
|
||||
self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly");
|
||||
let compare_dir = output_base_dir(self.config, self.testpaths, Some(&suffix));
|
||||
// Don't give an error if the directory didn't already exist
|
||||
let _ = fs::remove_dir_all(&compare_dir);
|
||||
create_dir_all(&compare_dir).unwrap();
|
||||
remove_and_create_dir_all(&compare_dir);
|
||||
|
||||
// We need to create a new struct for the lifetimes on `config` to work.
|
||||
let new_rustdoc = TestCx {
|
||||
|
@ -3137,8 +3135,7 @@ impl<'test> TestCx<'test> {
|
|||
assert!(self.revision.is_none(), "revisions not relevant here");
|
||||
|
||||
let out_dir = self.output_base_dir();
|
||||
let _ = fs::remove_dir_all(&out_dir);
|
||||
create_dir_all(&out_dir).unwrap();
|
||||
remove_and_create_dir_all(&out_dir);
|
||||
|
||||
let proc_res = self.document(&out_dir);
|
||||
if !proc_res.status.success() {
|
||||
|
|
30
tests/coverage/let_else_loop.cov-map
Normal file
30
tests/coverage/let_else_loop.cov-map
Normal file
|
@ -0,0 +1,30 @@
|
|||
Function name: let_else_loop::_if (unused)
|
||||
Raw bytes (19): 0x[01, 01, 00, 03, 00, 16, 01, 01, 0c, 00, 02, 09, 00, 10, 00, 02, 09, 00, 10]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 3
|
||||
- Code(Zero) at (prev + 22, 1) to (start + 1, 12)
|
||||
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
|
||||
- Code(Zero) at (prev + 2, 9) to (start + 0, 16)
|
||||
|
||||
Function name: let_else_loop::_loop_either_way (unused)
|
||||
Raw bytes (19): 0x[01, 01, 00, 03, 00, 0f, 01, 01, 14, 00, 01, 1c, 00, 23, 00, 01, 05, 00, 0c]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 3
|
||||
- Code(Zero) at (prev + 15, 1) to (start + 1, 20)
|
||||
- Code(Zero) at (prev + 1, 28) to (start + 0, 35)
|
||||
- Code(Zero) at (prev + 1, 5) to (start + 0, 12)
|
||||
|
||||
Function name: let_else_loop::loopy
|
||||
Raw bytes (19): 0x[01, 01, 00, 03, 01, 09, 01, 01, 14, 00, 01, 1c, 00, 23, 05, 01, 01, 00, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 3
|
||||
- Code(Counter(0)) at (prev + 9, 1) to (start + 1, 20)
|
||||
- Code(Zero) at (prev + 1, 28) to (start + 0, 35)
|
||||
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
|
||||
|
35
tests/coverage/let_else_loop.coverage
Normal file
35
tests/coverage/let_else_loop.coverage
Normal file
|
@ -0,0 +1,35 @@
|
|||
LL| |#![feature(coverage_attribute)]
|
||||
LL| |//@ edition: 2021
|
||||
LL| |
|
||||
LL| |// Regression test for <https://github.com/rust-lang/rust/issues/122738>.
|
||||
LL| |// These code patterns should not trigger an ICE when allocating a physical
|
||||
LL| |// counter to a node and also one of its in-edges, because that is allowed
|
||||
LL| |// when the node contains a tight loop to itself.
|
||||
LL| |
|
||||
LL| 1|fn loopy(cond: bool) {
|
||||
LL| 1| let true = cond else { loop {} };
|
||||
^0
|
||||
LL| 1|}
|
||||
LL| |
|
||||
LL| |// Variant that also has `loop {}` on the success path.
|
||||
LL| |// This isn't needed to catch the original ICE, but might help detect regressions.
|
||||
LL| 0|fn _loop_either_way(cond: bool) {
|
||||
LL| 0| let true = cond else { loop {} };
|
||||
LL| 0| loop {}
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |// Variant using regular `if` instead of let-else.
|
||||
LL| |// This doesn't trigger the original ICE, but might help detect regressions.
|
||||
LL| 0|fn _if(cond: bool) {
|
||||
LL| 0| if cond {
|
||||
LL| 0| loop {}
|
||||
LL| | } else {
|
||||
LL| 0| loop {}
|
||||
LL| | }
|
||||
LL| |}
|
||||
LL| |
|
||||
LL| |#[coverage(off)]
|
||||
LL| |fn main() {
|
||||
LL| | loopy(true);
|
||||
LL| |}
|
||||
|
33
tests/coverage/let_else_loop.rs
Normal file
33
tests/coverage/let_else_loop.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
#![feature(coverage_attribute)]
|
||||
//@ edition: 2021
|
||||
|
||||
// Regression test for <https://github.com/rust-lang/rust/issues/122738>.
|
||||
// These code patterns should not trigger an ICE when allocating a physical
|
||||
// counter to a node and also one of its in-edges, because that is allowed
|
||||
// when the node contains a tight loop to itself.
|
||||
|
||||
fn loopy(cond: bool) {
|
||||
let true = cond else { loop {} };
|
||||
}
|
||||
|
||||
// Variant that also has `loop {}` on the success path.
|
||||
// This isn't needed to catch the original ICE, but might help detect regressions.
|
||||
fn _loop_either_way(cond: bool) {
|
||||
let true = cond else { loop {} };
|
||||
loop {}
|
||||
}
|
||||
|
||||
// Variant using regular `if` instead of let-else.
|
||||
// This doesn't trigger the original ICE, but might help detect regressions.
|
||||
fn _if(cond: bool) {
|
||||
if cond {
|
||||
loop {}
|
||||
} else {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
#[coverage(off)]
|
||||
fn main() {
|
||||
loopy(true);
|
||||
}
|
|
@ -9,8 +9,7 @@ trait MyTrait<'a, 'b, T> {
|
|||
impl<'a, 'b, T, U> MyTrait<T> for U {
|
||||
//~^ ERROR: implicit elided lifetime not allowed here [E0726]
|
||||
async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||
//~^ ERROR: method `foo` has a `&self` declaration in the trait, but not in the impl [E0186]
|
||||
//~| ERROR: mismatched types [E0308]
|
||||
//~^ ERROR: mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -15,15 +15,6 @@ error[E0412]: cannot find type `ConnImpl` in this scope
|
|||
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||
| ^^^^^^^^ not found in this scope
|
||||
|
||||
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
|
||||
--> $DIR/return-not-existing-pair.rs:11:5
|
||||
|
|
||||
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||
| ------------------------------------------------------------ `&self` used in trait
|
||||
...
|
||||
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/return-not-existing-pair.rs:11:42
|
||||
|
|
||||
|
@ -33,7 +24,7 @@ LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
|||
= note: expected tuple `(&'a U, &'b T)`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0186, E0308, E0412, E0726.
|
||||
For more information about an error, try `rustc --explain E0186`.
|
||||
Some errors have detailed explanations: E0308, E0412, E0726.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
|
@ -14,6 +14,7 @@ impl<'a> Actor for () {
|
|||
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
|
||||
type Message = &'a ();
|
||||
async fn on_mount(self, _: impl Inbox<&'a ()>) {}
|
||||
//~^ ERROR the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
error[E0277]: the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
|
||||
--> $DIR/unconstrained-impl-region.rs:16:5
|
||||
|
|
||||
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Inbox<&'a ()>` is not implemented for `impl Inbox<&'a ()>`
|
||||
|
|
||||
note: required by a bound in `<() as Actor>::on_mount`
|
||||
--> $DIR/unconstrained-impl-region.rs:16:37
|
||||
|
|
||||
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
|
||||
| ^^^^^^^^^^^^^ required by this bound in `<() as Actor>::on_mount`
|
||||
help: consider further restricting this bound
|
||||
|
|
||||
LL | async fn on_mount(self, _: impl Inbox<&'a ()> + Inbox<&'a ()>) {}
|
||||
| +++++++++++++++
|
||||
|
||||
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/unconstrained-impl-region.rs:13:6
|
||||
|
|
||||
LL | impl<'a> Actor for () {
|
||||
| ^^ unconstrained lifetime parameter
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0207`.
|
||||
Some errors have detailed explanations: E0207, E0277.
|
||||
For more information about an error, try `rustc --explain E0207`.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
impl EntriesBuffer {
|
||||
fn a(&self) -> impl Iterator {
|
||||
self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference
|
||||
//~| ERROR captures lifetime that does not appear in bounds
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0425]: cannot find value `HashesEntryLEN` in this scope
|
||||
--> $DIR/issue-109141.rs:10:32
|
||||
--> $DIR/issue-109141.rs:11:32
|
||||
|
|
||||
LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>);
|
||||
| ^^^^^^^^^^^^^^ not found in this scope
|
||||
|
@ -20,7 +20,22 @@ help: consider changing this to be a mutable reference
|
|||
LL | fn a(&mut self) -> impl Iterator {
|
||||
| ~~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds
|
||||
--> $DIR/issue-109141.rs:6:9
|
||||
|
|
||||
LL | fn a(&self) -> impl Iterator {
|
||||
| ----- ------------- opaque type defined here
|
||||
| |
|
||||
| hidden type `std::slice::IterMut<'_, [u8; {const error}]>` captures the anonymous lifetime defined here
|
||||
LL | self.0.iter_mut()
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: to declare that `impl Iterator` captures `'_`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | fn a(&self) -> impl Iterator + '_ {
|
||||
| ++++
|
||||
|
||||
Some errors have detailed explanations: E0425, E0596.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0425, E0596, E0700.
|
||||
For more information about an error, try `rustc --explain E0425`.
|
||||
|
|
|
@ -4,46 +4,5 @@ error: cannot capture late-bound lifetime in constant
|
|||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| -- lifetime defined here ^^
|
||||
|
||||
error: overly complex generic constant
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constants
|
||||
|
|
||||
= help: consider moving this anonymous constant into a `const` function
|
||||
= note: this operation may be supported in the future
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error[E0391]: cycle detected when evaluating type-level constant
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires const-evaluating + checking `bug::{constant#0}`...
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires caching mir of `bug::{constant#0}` for CTFE...
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires elaborating drops for `bug::{constant#0}`...
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires borrow-checking `bug::{constant#0}`...
|
||||
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
||||
|
|
||||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires normalizing `Binder { value: ConstEvaluatable(UnevaluatedConst { def: DefId(0:8 ~ late_bound_in_return_issue_77357[9394]::bug::{constant#0}), args: [T/#0] }: usize), bound_vars: [] }`...
|
||||
= note: ...which again requires evaluating type-level constant, completing the cycle
|
||||
= note: cycle used when normalizing `&dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]>`
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
||||
|
|
|
@ -2,9 +2,9 @@ fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
|
|||
//~^ ERROR: `'_` cannot be used here [E0637]
|
||||
//~| ERROR: missing lifetime specifier
|
||||
if str1.len() > str2.len() {
|
||||
str1 //~ ERROR: lifetime may not live long enough
|
||||
str1
|
||||
} else {
|
||||
str2 //~ ERROR: lifetime may not live long enough
|
||||
str2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,25 +27,7 @@ help: consider introducing a higher-ranked lifetime here
|
|||
LL | T: for<'a> Into<&'a u32>,
|
||||
| +++++++ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/E0637.rs:5:9
|
||||
|
|
||||
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
...
|
||||
LL | str1
|
||||
| ^^^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/E0637.rs:7:9
|
||||
|
|
||||
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
|
||||
| - let's call the lifetime of this reference `'2`
|
||||
...
|
||||
LL | str2
|
||||
| ^^^^ returning this value requires that `'2` must outlive `'static`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0637.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -29,5 +29,5 @@ fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
|
|||
|
||||
fn main() {
|
||||
let mut t1: E<f32> = Default::default();
|
||||
test_simpler(&mut t1); //~ ERROR does not live long enough
|
||||
test_simpler(&mut t1);
|
||||
}
|
||||
|
|
|
@ -48,20 +48,7 @@ LL | *dst.test_mut() = n.into();
|
|||
| `dst` escapes the function body here
|
||||
| argument requires that `'a` must outlive `'static`
|
||||
|
||||
error[E0597]: `t1` does not live long enough
|
||||
--> $DIR/issue-80433.rs:32:18
|
||||
|
|
||||
LL | let mut t1: E<f32> = Default::default();
|
||||
| ------ binding `t1` declared here
|
||||
LL | test_simpler(&mut t1);
|
||||
| -------------^^^^^^^-
|
||||
| | |
|
||||
| | borrowed value does not live long enough
|
||||
| argument requires that `t1` is borrowed for `'static`
|
||||
LL | }
|
||||
| - `t1` dropped here while still borrowed
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0107, E0499, E0521, E0597.
|
||||
Some errors have detailed explanations: E0107, E0499, E0521.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
||||
|
|
|
@ -4,19 +4,16 @@ use std::fmt::Debug;
|
|||
fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
|
||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
|x| x
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
|x| x
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
|x| x
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn d() -> impl Fn() -> (impl Debug + '_) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:22:38
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:19:38
|
||||
|
|
||||
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
|
||||
| ^^ expected named lifetime parameter
|
||||
|
@ -22,58 +22,31 @@ note: lifetime declared here
|
|||
LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
|
||||
| ^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:6:9
|
||||
|
|
||||
LL | |x| x
|
||||
| -- ^ returning this value requires that `'1` must outlive `'2`
|
||||
| ||
|
||||
| |return type of closure is impl Debug + '2
|
||||
| has type `&'1 u8`
|
||||
|
||||
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:10:52
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:9:52
|
||||
|
|
||||
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
| ^^
|
||||
|
|
||||
note: lifetime declared here
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:10:20
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:9:20
|
||||
|
|
||||
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
| ^^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:12:9
|
||||
|
|
||||
LL | |x| x
|
||||
| -- ^ returning this value requires that `'1` must outlive `'2`
|
||||
| ||
|
||||
| |return type of closure is impl Debug + '2
|
||||
| has type `&'1 u8`
|
||||
|
||||
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:16:52
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:14:52
|
||||
|
|
||||
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| ^^
|
||||
|
|
||||
note: lifetime declared here
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:16:20
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:14:20
|
||||
|
|
||||
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| ^^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:18:9
|
||||
|
|
||||
LL | |x| x
|
||||
| -- ^ returning this value requires that `'1` must outlive `'2`
|
||||
| ||
|
||||
| |return type of closure is impl Debug + '2
|
||||
| has type `&'1 u8`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0657.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -5,7 +5,6 @@ fn a() -> impl Fn(&u8) -> impl Debug + '_ {
|
|||
//~^ ERROR ambiguous `+` in a type
|
||||
//~| ERROR cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
|x| x
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn b() -> impl Fn() -> impl Debug + Send {
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
|
|||
| ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)`
|
||||
|
||||
error: ambiguous `+` in a type
|
||||
--> $DIR/impl-fn-parsing-ambiguities.rs:11:24
|
||||
--> $DIR/impl-fn-parsing-ambiguities.rs:10:24
|
||||
|
|
||||
LL | fn b() -> impl Fn() -> impl Debug + Send {
|
||||
| ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)`
|
||||
|
@ -22,15 +22,6 @@ note: lifetime declared here
|
|||
LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
|
||||
| ^
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/impl-fn-parsing-ambiguities.rs:7:9
|
||||
|
|
||||
LL | |x| x
|
||||
| -- ^ returning this value requires that `'1` must outlive `'2`
|
||||
| ||
|
||||
| |return type of closure is impl Debug + '2
|
||||
| has type `&'1 u8`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0657`.
|
||||
|
|
|
@ -35,7 +35,6 @@ fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {}
|
|||
|
||||
fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {}
|
||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|
||||
//~| ERROR: the trait bound `for<'a> &'a (): Qux<'_>` is not satisfied
|
||||
|
||||
// This should resolve.
|
||||
fn one_hrtb_mention_fn_trait_param<'b>() -> impl for<'a> Foo<'a, Assoc = impl Qux<'b>> {}
|
||||
|
@ -45,7 +44,7 @@ fn one_hrtb_mention_fn_outlives<'b>() -> impl for<'a> Foo<'a, Assoc = impl Sized
|
|||
|
||||
// This should resolve.
|
||||
fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Qux<'b>> {}
|
||||
//~^ ERROR: the trait bound `for<'a> &'a (): Qux<'b>` is not satisfied
|
||||
//~^ ERROR type annotations needed: cannot satisfy `for<'a> &'a (): Qux<'b>`
|
||||
|
||||
// This should resolve.
|
||||
fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/nested-rpit-hrtb.rs:58:77
|
||||
--> $DIR/nested-rpit-hrtb.rs:57:77
|
||||
|
|
||||
LL | fn two_htrb_outlives() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Sized + 'b> {}
|
||||
| ^^ undeclared lifetime
|
||||
|
@ -15,7 +15,7 @@ LL | fn two_htrb_outlives<'b>() -> impl for<'a> Foo<'a, Assoc = impl for<'b> Siz
|
|||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/nested-rpit-hrtb.rs:66:82
|
||||
--> $DIR/nested-rpit-hrtb.rs:65:82
|
||||
|
|
||||
LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Sized + 'b> {}
|
||||
| ^^ undeclared lifetime
|
||||
|
@ -86,26 +86,18 @@ note: lifetime declared here
|
|||
LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {}
|
||||
| ^^
|
||||
|
||||
error[E0277]: the trait bound `for<'a> &'a (): Qux<'_>` is not satisfied
|
||||
--> $DIR/nested-rpit-hrtb.rs:36:64
|
||||
|
|
||||
LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {}
|
||||
| ^^^^^^^^^^^^ the trait `for<'a> Qux<'_>` is not implemented for `&'a ()`
|
||||
|
|
||||
= help: the trait `Qux<'_>` is implemented for `()`
|
||||
= help: for that trait implementation, expected `()`, found `&'a ()`
|
||||
|
||||
error[E0277]: the trait bound `for<'a> &'a (): Qux<'b>` is not satisfied
|
||||
--> $DIR/nested-rpit-hrtb.rs:47:79
|
||||
error[E0283]: type annotations needed: cannot satisfy `for<'a> &'a (): Qux<'b>`
|
||||
--> $DIR/nested-rpit-hrtb.rs:46:79
|
||||
|
|
||||
LL | fn one_hrtb_mention_fn_trait_param_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Qux<'b>> {}
|
||||
| ^^^^^^^^^^^^ the trait `for<'a> Qux<'b>` is not implemented for `&'a ()`
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: cannot satisfy `for<'a> &'a (): Qux<'b>`
|
||||
= help: the trait `Qux<'_>` is implemented for `()`
|
||||
= help: for that trait implementation, expected `()`, found `&'a ()`
|
||||
|
||||
error: implementation of `Bar` is not general enough
|
||||
--> $DIR/nested-rpit-hrtb.rs:51:93
|
||||
--> $DIR/nested-rpit-hrtb.rs:50:93
|
||||
|
|
||||
LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'b> {}
|
||||
| ^^ implementation of `Bar` is not general enough
|
||||
|
@ -114,7 +106,7 @@ LL | fn one_hrtb_mention_fn_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc =
|
|||
= note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0`
|
||||
|
||||
error[E0277]: the trait bound `for<'a, 'b> &'a (): Qux<'b>` is not satisfied
|
||||
--> $DIR/nested-rpit-hrtb.rs:62:64
|
||||
--> $DIR/nested-rpit-hrtb.rs:61:64
|
||||
|
|
||||
LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Qux<'b>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Qux<'b>` is not implemented for `&'a ()`
|
||||
|
@ -123,7 +115,7 @@ LL | fn two_htrb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b>
|
|||
= help: for that trait implementation, expected `()`, found `&'a ()`
|
||||
|
||||
error: implementation of `Bar` is not general enough
|
||||
--> $DIR/nested-rpit-hrtb.rs:66:86
|
||||
--> $DIR/nested-rpit-hrtb.rs:65:86
|
||||
|
|
||||
LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Sized + 'b> {}
|
||||
| ^^ implementation of `Bar` is not general enough
|
||||
|
@ -131,7 +123,7 @@ LL | fn two_htrb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl for<'b> Si
|
|||
= note: `()` must implement `Bar<'a>`
|
||||
= note: ...but it actually implements `Bar<'0>`, for some specific lifetime `'0`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0277, E0657.
|
||||
Some errors have detailed explanations: E0261, E0277, E0283, E0657.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
|
|
|
@ -19,7 +19,7 @@ impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
|
|||
|
||||
fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
sadness.cast() //~ ERROR: mismatched types
|
||||
sadness.cast()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -66,19 +66,6 @@ LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short,
|
|||
| |
|
||||
| help: consider introducing lifetime `'short` here: `'short,`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-107090.rs:22:5
|
||||
|
|
||||
LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
|
||||
| - expected this type parameter ------- expected `&'out T` because of return type
|
||||
LL |
|
||||
LL | sadness.cast()
|
||||
| ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>`
|
||||
|
|
||||
= note: expected reference `&'out T`
|
||||
found reference `&Foo<'_, '_, T>`
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0308.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
For more information about this error, try `rustc --explain E0261`.
|
||||
|
|
|
@ -8,7 +8,6 @@ impl<'self> Serializable<str> for &'self str {
|
|||
//~^ ERROR lifetimes cannot use keyword names
|
||||
//~| ERROR lifetimes cannot use keyword names
|
||||
//~| ERROR implicit elided lifetime not allowed here
|
||||
//~| ERROR the size for values of type `str` cannot be known at compilation time [E0277]
|
||||
fn serialize(val: &'self str) -> Vec<u8> {
|
||||
//~^ ERROR lifetimes cannot use keyword names
|
||||
vec![1]
|
||||
|
|
|
@ -29,13 +29,13 @@ LL | impl<'self> Serializable<str> for &'self str {
|
|||
| ^^^^^
|
||||
|
||||
error: lifetimes cannot use keyword names
|
||||
--> $DIR/issue-10412.rs:12:24
|
||||
--> $DIR/issue-10412.rs:11:24
|
||||
|
|
||||
LL | fn serialize(val: &'self str) -> Vec<u8> {
|
||||
| ^^^^^
|
||||
|
||||
error: lifetimes cannot use keyword names
|
||||
--> $DIR/issue-10412.rs:16:37
|
||||
--> $DIR/issue-10412.rs:15:37
|
||||
|
|
||||
LL | fn deserialize(repr: &[u8]) -> &'self str {
|
||||
| ^^^^^
|
||||
|
@ -51,24 +51,6 @@ help: indicate the anonymous lifetime
|
|||
LL | impl<'self> Serializable<'_, str> for &'self str {
|
||||
| +++
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/issue-10412.rs:7:13
|
||||
|
|
||||
LL | impl<'self> Serializable<str> for &'self str {
|
||||
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
note: required by an implicit `Sized` bound in `Serializable`
|
||||
--> $DIR/issue-10412.rs:1:27
|
||||
|
|
||||
LL | trait Serializable<'self, T> {
|
||||
| ^ required by the implicit `Sized` requirement on this type parameter in `Serializable`
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | trait Serializable<'self, T: ?Sized> {
|
||||
| ++++++++
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0726.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0726`.
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
struct Struct;
|
||||
impl Struct {
|
||||
async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
|
||||
//~^ ERROR the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
|
||||
//~| ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without
|
||||
//~^ ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without
|
||||
&1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,3 @@
|
|||
error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
|
||||
--> $DIR/could-not-resolve-issue-121503.rs:6:5
|
||||
|
|
||||
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)`
|
||||
|
|
||||
note: required by a bound in `Box`
|
||||
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
help: consider further restricting this bound
|
||||
|
|
||||
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self) + std::alloc::Allocator>) -> &u32 {
|
||||
| +++++++++++++++++++++++
|
||||
|
||||
error[E0658]: `Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
|
||||
--> $DIR/could-not-resolve-issue-121503.rs:6:35
|
||||
|
|
||||
|
@ -22,7 +9,6 @@ LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32
|
|||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Some errors have detailed explanations: E0277, E0658.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
|
||||
//~^ ERROR missing lifetime specifier [E0106]
|
||||
//~| ERROR mismatched types
|
||||
|
||||
fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
||||
//~^ ERROR missing lifetime specifier [E0106]
|
||||
|
|
|
@ -11,7 +11,7 @@ LL | fn parse_type<'a>(iter: Box<dyn Iterator<Item=&'a str>+'static>) -> &'a str
|
|||
| ++++ ++ ++
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/issue-26638.rs:5:40
|
||||
--> $DIR/issue-26638.rs:4:40
|
||||
|
|
||||
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
||||
| ^ expected named lifetime parameter
|
||||
|
@ -31,7 +31,7 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> String { iter() }
|
|||
| ~~~~~~
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/issue-26638.rs:10:22
|
||||
--> $DIR/issue-26638.rs:9:22
|
||||
|
|
||||
LL | fn parse_type_3() -> &str { unimplemented!() }
|
||||
| ^ expected named lifetime parameter
|
||||
|
@ -46,23 +46,8 @@ help: instead, you are more likely to want to return an owned value
|
|||
LL | fn parse_type_3() -> String { unimplemented!() }
|
||||
| ~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-26638.rs:1:69
|
||||
|
|
||||
LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
|
||||
| ---- ^^^^^^^^^^^ expected `&str`, found `Option<&str>`
|
||||
| |
|
||||
| expected `&str` because of return type
|
||||
|
|
||||
= note: expected reference `&str`
|
||||
found enum `Option<&str>`
|
||||
help: consider using `Option::expect` to unwrap the `Option<&str>` value, panicking if the value is an `Option::None`
|
||||
|
|
||||
LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next().expect("REASON") }
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0061]: this function takes 1 argument but 0 arguments were supplied
|
||||
--> $DIR/issue-26638.rs:5:47
|
||||
--> $DIR/issue-26638.rs:4:47
|
||||
|
|
||||
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
||||
| ^^^^-- an argument of type `&u8` is missing
|
||||
|
@ -73,7 +58,7 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) }
|
|||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-26638.rs:5:47
|
||||
--> $DIR/issue-26638.rs:4:47
|
||||
|
|
||||
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
||||
| ---- ^^^^^^ expected `&str`, found `&u8`
|
||||
|
@ -83,7 +68,7 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
|||
= note: expected reference `&'static str`
|
||||
found reference `&u8`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0061, E0106, E0308.
|
||||
For more information about an error, try `rustc --explain E0061`.
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
fn foo(x: &i32, y: &i32) -> &i32 { //~ ERROR missing lifetime
|
||||
if x > y { x } else { y }
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
//~| ERROR: lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -10,22 +10,6 @@ help: consider introducing a named lifetime parameter
|
|||
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
|
||||
| ++++ ++ ++ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex1b-return-no-names-if-else.rs:2:16
|
||||
|
|
||||
LL | fn foo(x: &i32, y: &i32) -> &i32 {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
LL | if x > y { x } else { y }
|
||||
| ^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex1b-return-no-names-if-else.rs:2:27
|
||||
|
|
||||
LL | fn foo(x: &i32, y: &i32) -> &i32 {
|
||||
| - let's call the lifetime of this reference `'2`
|
||||
LL | if x > y { x } else { y }
|
||||
| ^ returning this value requires that `'2` must outlive `'static`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -35,6 +35,7 @@ fn main() {
|
|||
foo::bar();
|
||||
foo::$b(); // issue #96698
|
||||
$a::bar();
|
||||
$a::$b();
|
||||
} }
|
||||
m!(foo, bar);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ fn main() {
|
|||
foo::bar();
|
||||
foo::$b(); // issue #96698
|
||||
$a::bar();
|
||||
$a::$b();
|
||||
} }
|
||||
m!(foo, bar);
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ impl Lt<'missing> for () { //~ ERROR undeclared lifetime
|
|||
|
||||
fn main() {
|
||||
let _: <() as Lt<'_>>::T = &();
|
||||
//~^ ERROR the trait bound `(): Lt<'_>` is not satisfied
|
||||
}
|
||||
|
|
|
@ -21,6 +21,13 @@ help: consider introducing lifetime `'missing` here
|
|||
LL | impl<'missing> Lt<'missing> for () {
|
||||
| ++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0277]: the trait bound `(): Lt<'_>` is not satisfied
|
||||
--> $DIR/region-error-ice-109072.rs:13:13
|
||||
|
|
||||
LL | let _: <() as Lt<'_>>::T = &();
|
||||
| ^^ the trait `Lt<'_>` is not implemented for `()`
|
||||
|
||||
For more information about this error, try `rustc --explain E0261`.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0277.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
|
|
|
@ -15,7 +15,6 @@ fn is_static<T>(_: T) where T: 'static { }
|
|||
// code forces us into a conservative, hacky path.
|
||||
fn bar(x: &str) -> &dyn Foo<Item = dyn Bar> { &() }
|
||||
//~^ ERROR please supply an explicit bound
|
||||
//~| ERROR `(): Foo<'_>` is not satisfied
|
||||
|
||||
fn main() {
|
||||
let s = format!("foo");
|
||||
|
|
|
@ -4,20 +4,6 @@ error[E0228]: the lifetime bound for this object type cannot be deduced from con
|
|||
LL | fn bar(x: &str) -> &dyn Foo<Item = dyn Bar> { &() }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `(): Foo<'_>` is not satisfied
|
||||
--> $DIR/object-lifetime-default-dyn-binding-nonstatic3.rs:16:47
|
||||
|
|
||||
LL | fn bar(x: &str) -> &dyn Foo<Item = dyn Bar> { &() }
|
||||
| ^^^ the trait `Foo<'_>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/object-lifetime-default-dyn-binding-nonstatic3.rs:4:1
|
||||
|
|
||||
LL | trait Foo<'a> {
|
||||
| ^^^^^^^^^^^^^
|
||||
= note: required for the cast from `&()` to `&dyn Foo<'_, Item = dyn Bar>`
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0228, E0277.
|
||||
For more information about an error, try `rustc --explain E0228`.
|
||||
For more information about this error, try `rustc --explain E0228`.
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
async fn a(s1: &str, s2: &str) -> &str {
|
||||
//~^ ERROR: missing lifetime specifier [E0106]
|
||||
s1
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn b(s1: &str, s2: &str) -> &str {
|
||||
//~^ ERROR: missing lifetime specifier [E0106]
|
||||
s1
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -11,7 +11,7 @@ LL | async fn a<'a>(s1: &'a str, s2: &'a str) -> &'a str {
|
|||
| ++++ ++ ++ ++
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/issue-86667.rs:12:29
|
||||
--> $DIR/issue-86667.rs:11:29
|
||||
|
|
||||
LL | fn b(s1: &str, s2: &str) -> &str {
|
||||
| ---- ---- ^ expected named lifetime parameter
|
||||
|
@ -22,24 +22,6 @@ help: consider introducing a named lifetime parameter
|
|||
LL | fn b<'a>(s1: &'a str, s2: &'a str) -> &'a str {
|
||||
| ++++ ++ ++ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-86667.rs:8:5
|
||||
|
|
||||
LL | async fn a(s1: &str, s2: &str) -> &str {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
LL |
|
||||
LL | s1
|
||||
| ^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-86667.rs:14:5
|
||||
|
|
||||
LL | fn b(s1: &str, s2: &str) -> &str {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
LL |
|
||||
LL | s1
|
||||
| ^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -20,31 +20,21 @@ pub union Qux<'t, 'k, I> {
|
|||
trait Tar<'t, 'k, I> {}
|
||||
|
||||
thread_local! {
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| ERROR missing lifetime specifiers
|
||||
}
|
||||
thread_local! {
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| ERROR missing lifetime specifiers
|
||||
}
|
||||
thread_local! {
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| ERROR missing lifetime specifiers
|
||||
}
|
||||
thread_local! {
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
//~| ERROR lifetime may not live long enough
|
||||
static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| ERROR missing lifetime specifiers
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:25:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:23:44
|
||||
|
|
||||
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
|
||||
| ^^^ expected 2 lifetime parameters
|
||||
|
@ -11,11 +11,9 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefC
|
|||
| ++++++++++++++++++
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:25:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:23:44
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
|
||||
| | ^^^ expected 2 lifetime parameters
|
||||
LL | |
|
||||
|
@ -26,7 +24,7 @@ LL | | }
|
|||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:33:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:28:44
|
||||
|
|
||||
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
|
||||
| ^^^^ expected 2 lifetime parameters
|
||||
|
@ -40,12 +38,9 @@ LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>>
|
|||
| +++++++ ++++++++++++++++++
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:33:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:28:44
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
|
||||
| | ^^^^ expected 2 lifetime parameters
|
||||
| | |
|
||||
|
@ -58,7 +53,7 @@ LL | | }
|
|||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:40:47
|
||||
--> $DIR/missing-lifetime-specifier.rs:33:47
|
||||
|
|
||||
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
|
||||
| ^ expected 2 lifetime parameters
|
||||
|
@ -70,11 +65,9 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> =
|
|||
| +++++++++++++++++
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:40:47
|
||||
--> $DIR/missing-lifetime-specifier.rs:33:47
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
|
||||
| | ^ expected 2 lifetime parameters
|
||||
LL | |
|
||||
|
@ -85,7 +78,7 @@ LL | | }
|
|||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:48:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:38:44
|
||||
|
|
||||
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
|
||||
| ^ ^ expected 2 lifetime parameters
|
||||
|
@ -99,12 +92,9 @@ LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i
|
|||
| +++++++ +++++++++++++++++
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/missing-lifetime-specifier.rs:48:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:38:44
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
|
||||
| | ^ ^ expected 2 lifetime parameters
|
||||
| | |
|
||||
|
@ -117,7 +107,7 @@ LL | | }
|
|||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/missing-lifetime-specifier.rs:58:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:48:44
|
||||
|
|
||||
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
|
||||
| ^ expected named lifetime parameter
|
||||
|
@ -129,7 +119,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> =
|
|||
| +++++++
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/missing-lifetime-specifier.rs:58:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:48:44
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
|
||||
|
@ -143,7 +133,7 @@ LL | | }
|
|||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
|
||||
|
||||
error[E0107]: union takes 2 lifetime arguments but 1 lifetime argument was supplied
|
||||
--> $DIR/missing-lifetime-specifier.rs:54:44
|
||||
--> $DIR/missing-lifetime-specifier.rs:44:44
|
||||
|
|
||||
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
|
||||
| ^^^ ------- supplied 1 lifetime argument
|
||||
|
@ -161,7 +151,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> =
|
|||
| +++++++++
|
||||
|
||||
error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
|
||||
--> $DIR/missing-lifetime-specifier.rs:58:45
|
||||
--> $DIR/missing-lifetime-specifier.rs:48:45
|
||||
|
|
||||
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
|
||||
| ^^^ ------- supplied 1 lifetime argument
|
||||
|
@ -178,199 +168,7 @@ help: add missing lifetime argument
|
|||
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
|
||||
| +++++++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:22:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<Foo<'1, '_>>>>>>>`
|
||||
| returning this value requires that `'1` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:22:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<Foo<'_, '2>>>>>>>`
|
||||
| returning this value requires that `'2` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:29:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
|
||||
| | - let's call the lifetime of this reference `'1`
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ returning this value requires that `'1` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:29:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<&dyn Bar<'2, '_>>>>>>>`
|
||||
| returning this value requires that `'2` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:29:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<&dyn Bar<'_, '3>>>>>>>`
|
||||
| returning this value requires that `'3` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:37:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<Qux<'1, '_, i32>>>>>>>`
|
||||
| returning this value requires that `'1` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:37:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<Qux<'_, '2, i32>>>>>>>`
|
||||
| returning this value requires that `'2` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:44:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
|
||||
| | - let's call the lifetime of this reference `'1`
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ returning this value requires that `'1` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32> + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:44:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'2, '_, i32>>>>>>>`
|
||||
| returning this value requires that `'2` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32> + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/missing-lifetime-specifier.rs:44:1
|
||||
|
|
||||
LL | / thread_local! {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| | ^
|
||||
| | |
|
||||
| |_has type `Option<&mut Option<RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'_, '3, i32>>>>>>>`
|
||||
| returning this value requires that `'3` must outlive `'static`
|
||||
|
|
||||
= note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: to declare that the trait object captures data from argument `init`, you can add an explicit `'_` lifetime bound
|
||||
|
|
||||
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32> + '_>>>> = RefCell::new(HashMap::new());
|
||||
| ++++
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0107.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -6,7 +6,8 @@ impl<'a> Bar for Foo<'f> { //~ ERROR undeclared lifetime
|
|||
type Type = u32;
|
||||
}
|
||||
|
||||
fn test() //~ ERROR implementation of `Bar` is not general enough
|
||||
fn test() //~ ERROR the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
|
||||
//~| ERROR the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
|
||||
where
|
||||
for<'a> <Foo<'a> as Bar>::Type: Sized,
|
||||
{
|
||||
|
|
|
@ -6,15 +6,22 @@ LL | impl<'a> Bar for Foo<'f> {
|
|||
| |
|
||||
| help: consider introducing lifetime `'f` here: `'f,`
|
||||
|
||||
error: implementation of `Bar` is not general enough
|
||||
error[E0277]: the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
|
||||
--> $DIR/span-bug-issue-121414.rs:9:1
|
||||
|
|
||||
LL | / fn test()
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | for<'a> <Foo<'a> as Bar>::Type: Sized,
|
||||
| |__________________________________________^ the trait `for<'a> Bar` is not implemented for `Foo<'a>`
|
||||
|
||||
error[E0277]: the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
|
||||
--> $DIR/span-bug-issue-121414.rs:9:4
|
||||
|
|
||||
LL | fn test()
|
||||
| ^^^^ implementation of `Bar` is not general enough
|
||||
|
|
||||
= note: `Bar` would have to be implemented for the type `Foo<'0>`, for any lifetime `'0`...
|
||||
= note: ...but `Bar` is actually implemented for the type `Foo<'1>`, for some specific lifetime `'1`
|
||||
| ^^^^ the trait `for<'a> Bar` is not implemented for `Foo<'a>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0261`.
|
||||
Some errors have detailed explanations: E0261, E0277.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
|
|
|
@ -11,9 +11,6 @@ where
|
|||
(): Test<{ 1 + (<() as Elide(&())>::call) }>,
|
||||
//~^ ERROR cannot capture late-bound lifetime in constant
|
||||
//~| ERROR associated type bindings are not allowed here
|
||||
//~| ERROR the trait bound `(): Elide<(&(),)>` is not satisfied
|
||||
//~| ERROR the trait bound `(): Elide<(&(),)>` is not satisfied
|
||||
//~| ERROR cannot add
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,49 +12,6 @@ error[E0229]: associated type bindings are not allowed here
|
|||
LL | (): Test<{ 1 + (<() as Elide(&())>::call) }>,
|
||||
| ^^^^^^^^^^ associated type not allowed here
|
||||
|
||||
error[E0277]: the trait bound `(): Elide<(&(),)>` is not satisfied
|
||||
--> $DIR/escaping_bound_vars.rs:11:22
|
||||
|
|
||||
LL | (): Test<{ 1 + (<() as Elide(&())>::call) }>,
|
||||
| ^^ the trait `Elide<(&(),)>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/escaping_bound_vars.rs:5:1
|
||||
|
|
||||
LL | trait Elide<T> {
|
||||
| ^^^^^^^^^^^^^^
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error[E0277]: cannot add `fn() {<() as Elide<(&(),)>>::call}` to `{integer}`
|
||||
--> $DIR/escaping_bound_vars.rs:11:18
|
||||
|
|
||||
LL | (): Test<{ 1 + (<() as Elide(&())>::call) }>,
|
||||
| ^ no implementation for `{integer} + fn() {<() as Elide<(&(),)>>::call}`
|
||||
|
|
||||
= help: the trait `Add<fn() {<() as Elide<(&(),)>>::call}>` is not implemented for `{integer}`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
<isize as Add>
|
||||
<isize as Add<&isize>>
|
||||
<i8 as Add>
|
||||
<i8 as Add<&i8>>
|
||||
<i16 as Add>
|
||||
<i16 as Add<&i16>>
|
||||
<i32 as Add>
|
||||
<i32 as Add<&i32>>
|
||||
and 48 others
|
||||
|
||||
error[E0277]: the trait bound `(): Elide<(&(),)>` is not satisfied
|
||||
--> $DIR/escaping_bound_vars.rs:11:18
|
||||
|
|
||||
LL | (): Test<{ 1 + (<() as Elide(&())>::call) }>,
|
||||
| ^ the trait `Elide<(&(),)>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/escaping_bound_vars.rs:5:1
|
||||
|
|
||||
LL | trait Elide<T> {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0229, E0277.
|
||||
For more information about an error, try `rustc --explain E0229`.
|
||||
For more information about this error, try `rustc --explain E0229`.
|
||||
|
|
|
@ -33,7 +33,6 @@ fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) {
|
|||
//~^ ERROR trait takes 1 lifetime argument but 0 lifetime arguments were supplied
|
||||
// Here, the omitted lifetimes are expanded to distinct things.
|
||||
same_type(x, y)
|
||||
//~^ ERROR borrowed data escapes outside of function
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -34,22 +34,6 @@ note: trait defined here, with 1 lifetime parameter: `'a`
|
|||
LL | trait Foo<'a,T> {
|
||||
| ^^^ --
|
||||
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/unboxed-closure-sugar-region.rs:35:5
|
||||
|
|
||||
LL | fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) {
|
||||
| - - `y` declared here, outside of the function body
|
||||
| |
|
||||
| `x` is a reference that is only valid in the function body
|
||||
| has type `&dyn Foo<'1, (isize,), Output = ()>`
|
||||
...
|
||||
LL | same_type(x, y)
|
||||
| ^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| `x` escapes the function body here
|
||||
| argument requires that `'1` must outlive `'static`
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0107, E0521.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
||||
For more information about this error, try `rustc --explain E0107`.
|
||||
|
|
|
@ -14,7 +14,6 @@ fn meh() -> Box<dyn for<'_> Meh<'_>> //~ ERROR cannot be used here
|
|||
}
|
||||
|
||||
fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
|
|
|
@ -45,15 +45,7 @@ help: consider introducing a named lifetime parameter
|
|||
LL | fn foo2<'a>(_: &'a u8, y: &'a u8) -> &'a u8 { y }
|
||||
| ++++ ~~ ~~ ~~
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/underscore-lifetime-binders.rs:16:43
|
||||
|
|
||||
LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y }
|
||||
| - ^ returning this value requires that `'1` must outlive `'static`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'1`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0637.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
|
|
|
@ -14,4 +14,5 @@ impl Trait for Ref {} //~ ERROR: implicit elided lifetime not allowed here
|
|||
|
||||
extern "C" {
|
||||
pub fn repro(_: Wrapper<Ref>);
|
||||
//~^ ERROR the trait bound `Ref<'_>: Trait` is not satisfied
|
||||
}
|
||||
|
|
|
@ -9,6 +9,19 @@ help: indicate the anonymous lifetime
|
|||
LL | impl Trait for Ref<'_> {}
|
||||
| ++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0277]: the trait bound `Ref<'_>: Trait` is not satisfied
|
||||
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21
|
||||
|
|
||||
LL | pub fn repro(_: Wrapper<Ref>);
|
||||
| ^^^^^^^^^^^^ the trait `Trait` is not implemented for `Ref<'_>`
|
||||
|
|
||||
note: required by a bound in `Wrapper`
|
||||
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:8:23
|
||||
|
|
||||
LL | pub struct Wrapper<T: Trait>(T);
|
||||
| ^^^^^ required by this bound in `Wrapper`
|
||||
|
||||
For more information about this error, try `rustc --explain E0726`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0726.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue