mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
Auto merge of #94357 - matthiaskrgr:rollup-xrjaof3, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #93845 (Remove in band lifetimes) - #94155 (Extend toggle GUI test a bit) - #94252 (don't special case `DefKind::Ctor` in encoding) - #94305 (Remove an unnecessary restriction in `dest_prop`) - #94343 (Miri fn ptr check: don't use conservative null check) - #94344 (diagnostic: suggest parens when users want logical ops, but get closures) - #94352 (Fix SGX docs build) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
9f8f0a6e94
@ -142,13 +142,9 @@ struct LoweringContext<'a, 'hir: 'a> {
|
||||
/// indicate whether or not we're in a place where new lifetimes will result
|
||||
/// in in-band lifetime definitions, such a function or an impl header,
|
||||
/// including implicit lifetimes from `impl_header_lifetime_elision`.
|
||||
is_collecting_in_band_lifetimes: bool,
|
||||
is_collecting_anonymous_lifetimes: bool,
|
||||
|
||||
/// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
|
||||
/// When `is_collecting_in_band_lifetimes` is true, each lifetime is checked
|
||||
/// against this list to see if it is already in-scope, or if a definition
|
||||
/// needs to be created for it.
|
||||
///
|
||||
/// We always store a `normalize_to_macros_2_0()` version of the param-name in this
|
||||
/// vector.
|
||||
in_scope_lifetimes: Vec<ParamName>,
|
||||
@ -379,7 +375,7 @@ pub fn lower_crate<'a, 'hir>(
|
||||
task_context: None,
|
||||
current_item: None,
|
||||
lifetimes_to_define: Vec::new(),
|
||||
is_collecting_in_band_lifetimes: false,
|
||||
is_collecting_anonymous_lifetimes: false,
|
||||
in_scope_lifetimes: Vec::new(),
|
||||
allow_try_trait: Some([sym::try_trait_v2][..].into()),
|
||||
allow_gen_future: Some([sym::gen_future][..].into()),
|
||||
@ -726,13 +722,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
&mut self,
|
||||
f: impl FnOnce(&mut Self) -> T,
|
||||
) -> (Vec<(Span, ParamName)>, T) {
|
||||
let was_collecting = std::mem::replace(&mut self.is_collecting_in_band_lifetimes, true);
|
||||
let was_collecting = std::mem::replace(&mut self.is_collecting_anonymous_lifetimes, true);
|
||||
let len = self.lifetimes_to_define.len();
|
||||
|
||||
let res = f(self);
|
||||
|
||||
let lifetimes_to_define = self.lifetimes_to_define.split_off(len);
|
||||
self.is_collecting_in_band_lifetimes = was_collecting;
|
||||
self.is_collecting_anonymous_lifetimes = was_collecting;
|
||||
(lifetimes_to_define, res)
|
||||
}
|
||||
|
||||
@ -749,7 +745,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// that collisions are ok here and this shouldn't
|
||||
// really show up for end-user.
|
||||
let (str_name, kind) = match hir_name {
|
||||
ParamName::Plain(ident) => (ident.name, hir::LifetimeParamKind::InBand),
|
||||
ParamName::Plain(ident) => (ident.name, hir::LifetimeParamKind::Explicit),
|
||||
ParamName::Fresh(_) => (kw::UnderscoreLifetime, hir::LifetimeParamKind::Elided),
|
||||
ParamName::Error => (kw::UnderscoreLifetime, hir::LifetimeParamKind::Error),
|
||||
};
|
||||
@ -773,38 +769,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
/// When there is a reference to some lifetime `'a`, and in-band
|
||||
/// lifetimes are enabled, then we want to push that lifetime into
|
||||
/// the vector of names to define later. In that case, it will get
|
||||
/// added to the appropriate generics.
|
||||
fn maybe_collect_in_band_lifetime(&mut self, ident: Ident) {
|
||||
if !self.is_collecting_in_band_lifetimes {
|
||||
return;
|
||||
}
|
||||
|
||||
if !self.sess.features_untracked().in_band_lifetimes {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.in_scope_lifetimes.contains(&ParamName::Plain(ident.normalize_to_macros_2_0())) {
|
||||
return;
|
||||
}
|
||||
|
||||
let hir_name = ParamName::Plain(ident);
|
||||
|
||||
if self.lifetimes_to_define.iter().any(|(_, lt_name)| {
|
||||
lt_name.normalize_to_macros_2_0() == hir_name.normalize_to_macros_2_0()
|
||||
}) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.lifetimes_to_define.push((ident.span, hir_name));
|
||||
}
|
||||
|
||||
/// When we have either an elided or `'_` lifetime in an impl
|
||||
/// header, we convert it to an in-band lifetime.
|
||||
fn collect_fresh_in_band_lifetime(&mut self, span: Span) -> ParamName {
|
||||
assert!(self.is_collecting_in_band_lifetimes);
|
||||
fn collect_fresh_anonymous_lifetime(&mut self, span: Span) -> ParamName {
|
||||
assert!(self.is_collecting_anonymous_lifetimes);
|
||||
let index = self.lifetimes_to_define.len() + self.in_scope_lifetimes.len();
|
||||
let hir_name = ParamName::Fresh(index);
|
||||
self.lifetimes_to_define.push((span, hir_name));
|
||||
@ -1946,7 +1914,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
ident if ident.name == kw::UnderscoreLifetime => match self.anonymous_lifetime_mode {
|
||||
AnonymousLifetimeMode::CreateParameter => {
|
||||
let fresh_name = self.collect_fresh_in_band_lifetime(span);
|
||||
let fresh_name = self.collect_fresh_anonymous_lifetime(span);
|
||||
self.new_named_lifetime(l.id, span, hir::LifetimeName::Param(fresh_name))
|
||||
}
|
||||
|
||||
@ -1957,7 +1925,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
AnonymousLifetimeMode::ReportError => self.new_error_lifetime(Some(l.id), span),
|
||||
},
|
||||
ident => {
|
||||
self.maybe_collect_in_band_lifetime(ident);
|
||||
let param_name = ParamName::Plain(self.lower_ident(ident));
|
||||
self.new_named_lifetime(l.id, span, hir::LifetimeName::Param(param_name))
|
||||
}
|
||||
@ -2001,8 +1968,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
let (name, kind) = match param.kind {
|
||||
GenericParamKind::Lifetime => {
|
||||
let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
|
||||
self.is_collecting_in_band_lifetimes = false;
|
||||
let was_collecting_in_band = self.is_collecting_anonymous_lifetimes;
|
||||
self.is_collecting_anonymous_lifetimes = false;
|
||||
|
||||
let lt = self
|
||||
.with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| {
|
||||
@ -2025,7 +1992,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
let kind =
|
||||
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };
|
||||
|
||||
self.is_collecting_in_band_lifetimes = was_collecting_in_band;
|
||||
self.is_collecting_anonymous_lifetimes = was_collecting_in_band;
|
||||
|
||||
(param_name, kind)
|
||||
}
|
||||
@ -2384,7 +2351,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// Hence `impl Foo for &u32` becomes `impl<'f> Foo for &'f u32` for some fresh
|
||||
// `'f`.
|
||||
AnonymousLifetimeMode::CreateParameter => {
|
||||
let fresh_name = self.collect_fresh_in_band_lifetime(span);
|
||||
let fresh_name = self.collect_fresh_anonymous_lifetime(span);
|
||||
hir::Lifetime {
|
||||
hir_id: self.next_id(),
|
||||
span: self.lower_span(span),
|
||||
|
@ -217,8 +217,9 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
|
||||
// Comparisons of abstract pointers with null pointers are known if the pointer
|
||||
// is in bounds, because if they are in bounds, the pointer can't be null.
|
||||
// Inequality with integers other than null can never be known for sure.
|
||||
(Scalar::Int(int), Scalar::Ptr(ptr, _)) | (Scalar::Ptr(ptr, _), Scalar::Int(int)) => {
|
||||
int.is_null() && !self.memory.ptr_may_be_null(ptr.into())
|
||||
(Scalar::Int(int), ptr @ Scalar::Ptr(..))
|
||||
| (ptr @ Scalar::Ptr(..), Scalar::Int(int)) => {
|
||||
int.is_null() && !self.scalar_may_be_null(ptr)
|
||||
}
|
||||
// FIXME: return `true` for at least some comparisons where we can reliably
|
||||
// determine the result of runtime inequality tests at compile-time.
|
||||
|
@ -22,9 +22,9 @@ use rustc_span::{Pos, Span};
|
||||
use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
|
||||
|
||||
use super::{
|
||||
AllocId, GlobalId, Immediate, InterpErrorInfo, InterpResult, MPlaceTy, Machine, MemPlace,
|
||||
MemPlaceMeta, Memory, MemoryKind, Operand, Place, PlaceTy, Pointer, Provenance, Scalar,
|
||||
ScalarMaybeUninit, StackPopJump,
|
||||
AllocCheck, AllocId, GlobalId, Immediate, InterpErrorInfo, InterpResult, MPlaceTy, Machine,
|
||||
MemPlace, MemPlaceMeta, Memory, MemoryKind, Operand, Place, PlaceTy, Pointer, Provenance,
|
||||
Scalar, ScalarMaybeUninit, StackPopJump,
|
||||
};
|
||||
use crate::transform::validate::equal_up_to_regions;
|
||||
|
||||
@ -440,6 +440,29 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.memory.scalar_to_ptr(scalar)
|
||||
}
|
||||
|
||||
/// Test if this value might be null.
|
||||
/// If the machine does not support ptr-to-int casts, this is conservative.
|
||||
pub fn scalar_may_be_null(&self, scalar: Scalar<M::PointerTag>) -> bool {
|
||||
match scalar.try_to_int() {
|
||||
Ok(int) => int.is_null(),
|
||||
Err(_) => {
|
||||
let ptr = self.scalar_to_ptr(scalar);
|
||||
match self.memory.ptr_try_get_alloc(ptr) {
|
||||
Ok((alloc_id, offset, _)) => {
|
||||
let (size, _align) = self
|
||||
.memory
|
||||
.get_size_and_align(alloc_id, AllocCheck::MaybeDead)
|
||||
.expect("alloc info with MaybeDead cannot fail");
|
||||
// If the pointer is out-of-bounds, it may be null.
|
||||
// Note that one-past-the-end (offset == size) is still inbounds, and never null.
|
||||
offset > size
|
||||
}
|
||||
Err(offset) => offset == 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Call this to turn untagged "global" pointers (obtained via `tcx`) into
|
||||
/// the machine pointer to the allocation. Must never be used
|
||||
/// for any other pointers, nor for TLS statics.
|
||||
|
@ -483,21 +483,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Test if the pointer might be null.
|
||||
pub fn ptr_may_be_null(&self, ptr: Pointer<Option<M::PointerTag>>) -> bool {
|
||||
match self.ptr_try_get_alloc(ptr) {
|
||||
Ok((alloc_id, offset, _)) => {
|
||||
let (size, _align) = self
|
||||
.get_size_and_align(alloc_id, AllocCheck::MaybeDead)
|
||||
.expect("alloc info with MaybeDead cannot fail");
|
||||
// If the pointer is out-of-bounds, it may be null.
|
||||
// Note that one-past-the-end (offset == size) is still inbounds, and never null.
|
||||
offset > size
|
||||
}
|
||||
Err(offset) => offset == 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Allocation accessors
|
||||
|
@ -720,12 +720,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Err(dbg_val) => {
|
||||
// So this is a pointer then, and casting to an int failed.
|
||||
// Can only happen during CTFE.
|
||||
let ptr = self.scalar_to_ptr(tag_val);
|
||||
// The niche must be just 0, and the ptr not null, then we know this is
|
||||
// okay. Everything else, we conservatively reject.
|
||||
let ptr_valid = niche_start == 0
|
||||
&& variants_start == variants_end
|
||||
&& !self.memory.ptr_may_be_null(ptr);
|
||||
&& !self.scalar_may_be_null(tag_val);
|
||||
if !ptr_valid {
|
||||
throw_ub!(InvalidTag(dbg_val))
|
||||
}
|
||||
|
@ -572,21 +572,25 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
err_unsup!(ReadPointerAsBytes) => { "part of a pointer" } expected { "a proper pointer or integer value" },
|
||||
err_ub!(InvalidUninitBytes(None)) => { "uninitialized bytes" } expected { "a proper pointer or integer value" },
|
||||
);
|
||||
let ptr = self.ecx.scalar_to_ptr(value);
|
||||
// Ensure the pointer is non-null.
|
||||
if self.ecx.memory.ptr_may_be_null(ptr) {
|
||||
throw_validation_failure!(self.path, { "a potentially null function pointer" });
|
||||
}
|
||||
|
||||
// If we check references recursively, also check that this points to a function.
|
||||
if let Some(_) = self.ref_tracking {
|
||||
let ptr = self.ecx.scalar_to_ptr(value);
|
||||
let _fn = try_validation!(
|
||||
self.ecx.memory.get_fn(ptr),
|
||||
self.path,
|
||||
err_ub!(DanglingIntPointer(0, _)) =>
|
||||
{ "a null function pointer" },
|
||||
err_ub!(DanglingIntPointer(..)) |
|
||||
err_ub!(InvalidFunctionPointer(..)) =>
|
||||
{ "{:x}", value } expected { "a function pointer" },
|
||||
);
|
||||
// FIXME: Check if the signature matches
|
||||
} else {
|
||||
// Otherwise (for standalone Miri), we have to still check it to be non-null.
|
||||
if self.ecx.scalar_may_be_null(value) {
|
||||
throw_validation_failure!(self.path, { "a null function pointer" });
|
||||
}
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
@ -644,10 +648,9 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
Err(_) => {
|
||||
// So this is a pointer then, and casting to an int failed.
|
||||
// Can only happen during CTFE.
|
||||
let ptr = self.ecx.scalar_to_ptr(value);
|
||||
if start == 1 && end == max_value {
|
||||
// Only null is the niche. So make sure the ptr is NOT null.
|
||||
if self.ecx.memory.ptr_may_be_null(ptr) {
|
||||
if self.ecx.scalar_may_be_null(value) {
|
||||
throw_validation_failure!(self.path,
|
||||
{ "a potentially null pointer" }
|
||||
expected {
|
||||
@ -758,7 +761,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
|
||||
fn visit_value(&mut self, op: &OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx> {
|
||||
trace!("visit_value: {:?}, {:?}", *op, op.layout);
|
||||
|
||||
// Check primitive types -- the leafs of our recursive descend.
|
||||
// Check primitive types -- the leaves of our recursive descent.
|
||||
if self.try_visit_primitive(op)? {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
In-band lifetimes cannot be used in `fn`/`Fn` syntax.
|
||||
|
||||
Erroneous code examples:
|
||||
|
||||
```compile_fail,E0687
|
||||
```ignore (feature got removed)
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: fn(&'a u32)) {} // error!
|
||||
|
@ -1,8 +1,10 @@
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
In-band lifetimes were mixed with explicit lifetime binders.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0688
|
||||
```ignore (feature got removed)
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo<'a>(x: &'a u32, y: &'b u32) {} // error!
|
||||
|
@ -400,8 +400,6 @@ declare_features! (
|
||||
(active, if_let_guard, "1.47.0", Some(51114), None),
|
||||
/// Allows using imported `main` function
|
||||
(active, imported_main, "1.53.0", Some(28937), None),
|
||||
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
|
||||
(active, in_band_lifetimes, "1.23.0", Some(44524), None),
|
||||
/// Allows inferring `'static` outlives requirements (RFC 2093).
|
||||
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
|
||||
/// Allows associated types in inherent impls.
|
||||
|
@ -104,6 +104,9 @@ declare_features! (
|
||||
(removed, impl_trait_in_bindings, "1.55.0", Some(63065), None,
|
||||
Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")),
|
||||
(removed, import_shadowing, "1.0.0", None, None, None),
|
||||
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
|
||||
(removed, in_band_lifetimes, "1.23.0", Some(44524), None,
|
||||
Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")),
|
||||
/// Lazily evaluate constants. This allows constants to depend on type parameters.
|
||||
(removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
|
||||
/// Allows using the `#[link_args]` attribute.
|
||||
|
@ -471,11 +471,6 @@ pub enum LifetimeParamKind {
|
||||
// `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`).
|
||||
Explicit,
|
||||
|
||||
// Indicates that the lifetime definition was synthetically added
|
||||
// as a result of an in-band lifetime usage (e.g., in
|
||||
// `fn foo(x: &'a u8) -> &'a u8 { x }`).
|
||||
InBand,
|
||||
|
||||
// Indication that the lifetime was elided (e.g., in both cases in
|
||||
// `fn foo(x: &u8) -> &'_ u8 { x }`).
|
||||
Elided,
|
||||
|
@ -125,7 +125,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
||||
// Find the index of the named region that was part of the
|
||||
// error. We will then search the function parameters for a bound
|
||||
// region at the right depth with the same index
|
||||
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
|
||||
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id == def_id {
|
||||
self.found_type = Some(arg);
|
||||
@ -137,7 +137,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
||||
// error. We will then search the function parameters for a bound
|
||||
// region at the right depth with the same index
|
||||
(
|
||||
Some(rl::Region::LateBound(debruijn_index, _, id, _)),
|
||||
Some(rl::Region::LateBound(debruijn_index, _, id)),
|
||||
ty::BrNamed(def_id, _),
|
||||
) => {
|
||||
debug!(
|
||||
@ -155,8 +155,8 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
||||
Some(
|
||||
rl::Region::Static
|
||||
| rl::Region::Free(_, _)
|
||||
| rl::Region::EarlyBound(_, _, _)
|
||||
| rl::Region::LateBound(_, _, _, _)
|
||||
| rl::Region::EarlyBound(_, _)
|
||||
| rl::Region::LateBound(_, _, _)
|
||||
| rl::Region::LateBoundAnon(_, _, _),
|
||||
)
|
||||
| None,
|
||||
@ -221,7 +221,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
|
||||
(Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id == def_id {
|
||||
self.found_it = true;
|
||||
@ -229,7 +229,7 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(Some(rl::Region::LateBound(debruijn_index, _, id, _)), ty::BrNamed(def_id, _)) => {
|
||||
(Some(rl::Region::LateBound(debruijn_index, _, id)), ty::BrNamed(def_id, _)) => {
|
||||
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index,);
|
||||
debug!("id={:?}", id);
|
||||
debug!("def_id={:?}", def_id);
|
||||
@ -242,8 +242,8 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
|
||||
(
|
||||
Some(
|
||||
rl::Region::Static
|
||||
| rl::Region::EarlyBound(_, _, _)
|
||||
| rl::Region::LateBound(_, _, _, _)
|
||||
| rl::Region::EarlyBound(_, _)
|
||||
| rl::Region::LateBound(_, _, _)
|
||||
| rl::Region::LateBoundAnon(_, _, _)
|
||||
| rl::Region::Free(_, _),
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||
use rustc_data_structures::stable_hasher::StableHasher;
|
||||
use rustc_data_structures::sync::{join, par_iter, Lrc, ParallelIterator};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{
|
||||
CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE,
|
||||
};
|
||||
@ -983,12 +983,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
let def_id = local_id.to_def_id();
|
||||
let def_kind = tcx.opt_def_kind(local_id);
|
||||
let Some(def_kind) = def_kind else { continue };
|
||||
record!(self.tables.opt_def_kind[def_id] <- match def_kind {
|
||||
// Replace Ctor by the enclosing object to avoid leaking details in children crates.
|
||||
DefKind::Ctor(CtorOf::Struct, _) => DefKind::Struct,
|
||||
DefKind::Ctor(CtorOf::Variant, _) => DefKind::Variant,
|
||||
def_kind => def_kind,
|
||||
});
|
||||
record!(self.tables.opt_def_kind[def_id] <- def_kind);
|
||||
record!(self.tables.def_span[def_id] <- tcx.def_span(def_id));
|
||||
record!(self.tables.attributes[def_id] <- tcx.get_attrs(def_id));
|
||||
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id));
|
||||
|
@ -4,47 +4,14 @@ use crate::ty;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::{GenericParam, ItemLocalId};
|
||||
use rustc_hir::{GenericParamKind, LifetimeParamKind};
|
||||
use rustc_hir::ItemLocalId;
|
||||
use rustc_macros::HashStable;
|
||||
|
||||
/// The origin of a named lifetime definition.
|
||||
///
|
||||
/// This is used to prevent the usage of in-band lifetimes in `Fn`/`fn` syntax.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
|
||||
pub enum LifetimeDefOrigin {
|
||||
// Explicit binders like `fn foo<'a>(x: &'a u8)` or elided like `impl Foo<&u32>`
|
||||
ExplicitOrElided,
|
||||
// In-band declarations like `fn foo(x: &'a u8)`
|
||||
InBand,
|
||||
// Some kind of erroneous origin
|
||||
Error,
|
||||
}
|
||||
|
||||
impl LifetimeDefOrigin {
|
||||
pub fn from_param(param: &GenericParam<'_>) -> Self {
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { kind } => match kind {
|
||||
LifetimeParamKind::InBand => LifetimeDefOrigin::InBand,
|
||||
LifetimeParamKind::Explicit => LifetimeDefOrigin::ExplicitOrElided,
|
||||
LifetimeParamKind::Elided => LifetimeDefOrigin::ExplicitOrElided,
|
||||
LifetimeParamKind::Error => LifetimeDefOrigin::Error,
|
||||
},
|
||||
_ => bug!("expected a lifetime param"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
|
||||
pub enum Region {
|
||||
Static,
|
||||
EarlyBound(/* index */ u32, /* lifetime decl */ DefId, LifetimeDefOrigin),
|
||||
LateBound(
|
||||
ty::DebruijnIndex,
|
||||
/* late-bound index */ u32,
|
||||
/* lifetime decl */ DefId,
|
||||
LifetimeDefOrigin,
|
||||
),
|
||||
EarlyBound(/* index */ u32, /* lifetime decl */ DefId),
|
||||
LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* lifetime decl */ DefId),
|
||||
LateBoundAnon(ty::DebruijnIndex, /* late-bound index */ u32, /* anon index */ u32),
|
||||
Free(DefId, /* lifetime decl */ DefId),
|
||||
}
|
||||
|
@ -38,12 +38,6 @@
|
||||
//! It must also not contain any indexing projections, since those take an arbitrary `Local` as
|
||||
//! the index, and that local might only be initialized shortly before `dest` is used.
|
||||
//!
|
||||
//! Subtle case: If `dest` is a, or projects through a union, then we have to make sure that there
|
||||
//! remains an assignment to it, since that sets the "active field" of the union. But if `src` is
|
||||
//! a ZST, it might not be initialized, so there might not be any use of it before the assignment,
|
||||
//! and performing the optimization would simply delete the assignment, leaving `dest`
|
||||
//! uninitialized.
|
||||
//!
|
||||
//! * `src` must be a bare `Local` without any indirections or field projections (FIXME: Is this a
|
||||
//! fundamental restriction or just current impl state?). It can be copied or moved by the
|
||||
//! assignment.
|
||||
@ -103,7 +97,6 @@ use rustc_index::{
|
||||
bit_set::{BitMatrix, BitSet},
|
||||
vec::IndexVec,
|
||||
};
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{dump_mir, PassWhere};
|
||||
use rustc_middle::mir::{
|
||||
@ -135,7 +128,7 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
let def_id = body.source.def_id();
|
||||
|
||||
let candidates = find_candidates(tcx, body);
|
||||
let candidates = find_candidates(body);
|
||||
if candidates.is_empty() {
|
||||
debug!("{:?}: no dest prop candidates, done", def_id);
|
||||
return;
|
||||
@ -803,9 +796,8 @@ struct CandidateAssignment<'tcx> {
|
||||
/// comment) and also throw out assignments that involve a local that has its address taken or is
|
||||
/// otherwise ineligible (eg. locals used as array indices are ignored because we cannot propagate
|
||||
/// arbitrary places into array indices).
|
||||
fn find_candidates<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Vec<CandidateAssignment<'tcx>> {
|
||||
fn find_candidates<'tcx>(body: &Body<'tcx>) -> Vec<CandidateAssignment<'tcx>> {
|
||||
let mut visitor = FindAssignments {
|
||||
tcx,
|
||||
body,
|
||||
candidates: Vec::new(),
|
||||
ever_borrowed_locals: ever_borrowed_locals(body),
|
||||
@ -816,7 +808,6 @@ fn find_candidates<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> Vec<CandidateA
|
||||
}
|
||||
|
||||
struct FindAssignments<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &'a Body<'tcx>,
|
||||
candidates: Vec<CandidateAssignment<'tcx>>,
|
||||
ever_borrowed_locals: BitSet<Local>,
|
||||
@ -845,10 +836,11 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't optimize if both locals ever have their address taken (can introduce
|
||||
// aliasing).
|
||||
// FIXME: This can be smarter and take `StorageDead` into account (which
|
||||
// invalidates borrows).
|
||||
// Can't optimize if either local ever has their address taken. This optimization does
|
||||
// liveness analysis only based on assignments, and a local can be live even if its
|
||||
// never assigned to again, because a reference to it might be live.
|
||||
// FIXME: This can be smarter and take `StorageDead` into account (which invalidates
|
||||
// borrows).
|
||||
if self.ever_borrowed_locals.contains(dest.local)
|
||||
|| self.ever_borrowed_locals.contains(src.local)
|
||||
{
|
||||
@ -862,22 +854,11 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle the "subtle case" described above by rejecting any `dest` that is or
|
||||
// projects through a union.
|
||||
let mut place_ty = PlaceTy::from_ty(self.body.local_decls[dest.local].ty);
|
||||
if place_ty.ty.is_union() {
|
||||
return;
|
||||
}
|
||||
for elem in dest.projection {
|
||||
if let PlaceElem::Index(_) = elem {
|
||||
// `dest` contains an indexing projection.
|
||||
return;
|
||||
}
|
||||
|
||||
place_ty = place_ty.projection_ty(self.tcx, elem);
|
||||
if place_ty.ty.is_union() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self.candidates.push(CandidateAssignment {
|
||||
|
@ -372,10 +372,17 @@ impl<'a> Parser<'a> {
|
||||
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
|
||||
false
|
||||
}
|
||||
(true, Some(AssocOp::LAnd)) => {
|
||||
(true, Some(AssocOp::LAnd)) |
|
||||
(true, Some(AssocOp::LOr)) |
|
||||
(true, Some(AssocOp::BitOr)) => {
|
||||
// `{ 42 } &&x` (#61475) or `{ 42 } && if x { 1 } else { 0 }`. Separated from the
|
||||
// above due to #74233.
|
||||
// These cases are ambiguous and can't be identified in the parser alone.
|
||||
//
|
||||
// Bitwise AND is left out because guessing intent is hard. We can make
|
||||
// suggestions based on the assumption that double-refs are rarely intentional,
|
||||
// and closures are distinct enough that they don't get mixed up with their
|
||||
// return value.
|
||||
let sp = self.sess.source_map().start_point(self.token.span);
|
||||
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
|
||||
false
|
||||
@ -1247,7 +1254,14 @@ impl<'a> Parser<'a> {
|
||||
} else if self.check(&token::OpenDelim(token::Brace)) {
|
||||
self.parse_block_expr(None, lo, BlockCheckMode::Default, attrs)
|
||||
} else if self.check(&token::BinOp(token::Or)) || self.check(&token::OrOr) {
|
||||
self.parse_closure_expr(attrs)
|
||||
self.parse_closure_expr(attrs).map_err(|mut err| {
|
||||
// If the input is something like `if a { 1 } else { 2 } | if a { 3 } else { 4 }`
|
||||
// then suggest parens around the lhs.
|
||||
if let Some(sp) = self.sess.ambiguous_block_expr_parse.borrow().get(&lo) {
|
||||
self.sess.expr_parentheses_needed(&mut err, *sp);
|
||||
}
|
||||
err
|
||||
})
|
||||
} else if self.check(&token::OpenDelim(token::Bracket)) {
|
||||
self.parse_array_or_repeat_expr(attrs, token::Bracket)
|
||||
} else if self.check_path() {
|
||||
|
@ -1838,7 +1838,6 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||
lifetime_ref
|
||||
);
|
||||
err.span_label(lifetime_ref.span, "undeclared lifetime");
|
||||
let mut suggests_in_band = false;
|
||||
let mut suggested_spans = vec![];
|
||||
for missing in &self.missing_named_lifetime_spots {
|
||||
match missing {
|
||||
@ -1854,7 +1853,6 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||
}) {
|
||||
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
|
||||
} else {
|
||||
suggests_in_band = true;
|
||||
(generics.span, format!("<{}>", lifetime_ref))
|
||||
};
|
||||
if suggested_spans.contains(&span) {
|
||||
@ -1889,15 +1887,6 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if self.tcx.sess.is_nightly_build()
|
||||
&& !self.tcx.features().in_band_lifetimes
|
||||
&& suggests_in_band
|
||||
{
|
||||
err.help(
|
||||
"if you want to experiment with in-band lifetime bindings, \
|
||||
add `#![feature(in_band_lifetimes)]` to the crate attributes",
|
||||
);
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
// ignore-tidy-filelength
|
||||
//! Name resolution for lifetimes.
|
||||
//!
|
||||
//! Name resolution for lifetimes follows *much* simpler rules than the
|
||||
@ -16,7 +15,7 @@ use rustc_hir::def_id::{DefIdMap, LocalDefId};
|
||||
use rustc_hir::hir_id::ItemLocalId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{GenericArg, GenericParam, LifetimeName, Node, ParamName, QPath};
|
||||
use rustc_hir::{GenericParamKind, HirIdMap, HirIdSet, LifetimeParamKind};
|
||||
use rustc_hir::{GenericParamKind, HirIdMap, HirIdSet};
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::middle::resolve_lifetime::*;
|
||||
@ -63,23 +62,18 @@ impl RegionExt for Region {
|
||||
let i = *index;
|
||||
*index += 1;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
let origin = LifetimeDefOrigin::from_param(param);
|
||||
debug!("Region::early: index={} def_id={:?}", i, def_id);
|
||||
(param.name.normalize_to_macros_2_0(), Region::EarlyBound(i, def_id.to_def_id(), origin))
|
||||
(param.name.normalize_to_macros_2_0(), Region::EarlyBound(i, def_id.to_def_id()))
|
||||
}
|
||||
|
||||
fn late(idx: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
let depth = ty::INNERMOST;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
let origin = LifetimeDefOrigin::from_param(param);
|
||||
debug!(
|
||||
"Region::late: idx={:?}, param={:?} depth={:?} def_id={:?} origin={:?}",
|
||||
idx, param, depth, def_id, origin,
|
||||
"Region::late: idx={:?}, param={:?} depth={:?} def_id={:?}",
|
||||
idx, param, depth, def_id,
|
||||
);
|
||||
(
|
||||
param.name.normalize_to_macros_2_0(),
|
||||
Region::LateBound(depth, idx, def_id.to_def_id(), origin),
|
||||
)
|
||||
(param.name.normalize_to_macros_2_0(), Region::LateBound(depth, idx, def_id.to_def_id()))
|
||||
}
|
||||
|
||||
fn late_anon(named_late_bound_vars: u32, index: &Cell<u32>) -> Region {
|
||||
@ -93,7 +87,7 @@ impl RegionExt for Region {
|
||||
match *self {
|
||||
Region::Static | Region::LateBoundAnon(..) => None,
|
||||
|
||||
Region::EarlyBound(_, id, _) | Region::LateBound(_, _, id, _) | Region::Free(_, id) => {
|
||||
Region::EarlyBound(_, id) | Region::LateBound(_, _, id) | Region::Free(_, id) => {
|
||||
Some(id)
|
||||
}
|
||||
}
|
||||
@ -101,8 +95,8 @@ impl RegionExt for Region {
|
||||
|
||||
fn shifted(self, amount: u32) -> Region {
|
||||
match self {
|
||||
Region::LateBound(debruijn, idx, id, origin) => {
|
||||
Region::LateBound(debruijn.shifted_in(amount), idx, id, origin)
|
||||
Region::LateBound(debruijn, idx, id) => {
|
||||
Region::LateBound(debruijn.shifted_in(amount), idx, id)
|
||||
}
|
||||
Region::LateBoundAnon(debruijn, index, anon_index) => {
|
||||
Region::LateBoundAnon(debruijn.shifted_in(amount), index, anon_index)
|
||||
@ -113,8 +107,8 @@ impl RegionExt for Region {
|
||||
|
||||
fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region {
|
||||
match self {
|
||||
Region::LateBound(debruijn, index, id, origin) => {
|
||||
Region::LateBound(debruijn.shifted_out_to_binder(binder), index, id, origin)
|
||||
Region::LateBound(debruijn, index, id) => {
|
||||
Region::LateBound(debruijn.shifted_out_to_binder(binder), index, id)
|
||||
}
|
||||
Region::LateBoundAnon(debruijn, index, anon_index) => {
|
||||
Region::LateBoundAnon(debruijn.shifted_out_to_binder(binder), index, anon_index)
|
||||
@ -127,7 +121,7 @@ impl RegionExt for Region {
|
||||
where
|
||||
L: Iterator<Item = &'a hir::Lifetime>,
|
||||
{
|
||||
if let Region::EarlyBound(index, _, _) = self {
|
||||
if let Region::EarlyBound(index, _) = self {
|
||||
params.nth(index as usize).and_then(|lifetime| map.defs.get(&lifetime.hir_id).cloned())
|
||||
} else {
|
||||
Some(self)
|
||||
@ -568,7 +562,7 @@ fn sub_items_have_self_param(node: &hir::ItemKind<'_>) -> bool {
|
||||
|
||||
fn late_region_as_bound_region<'tcx>(tcx: TyCtxt<'tcx>, region: &Region) -> ty::BoundVariableKind {
|
||||
match region {
|
||||
Region::LateBound(_, _, def_id, _) => {
|
||||
Region::LateBound(_, _, def_id) => {
|
||||
let name = tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id.expect_local()));
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(*def_id, name))
|
||||
}
|
||||
@ -1010,7 +1004,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
// well-supported at the moment, so this doesn't work.
|
||||
// In the future, this should be fixed and this error should be removed.
|
||||
let def = self.map.defs.get(&lifetime.hir_id).cloned();
|
||||
let Some(Region::LateBound(_, _, def_id, _)) = def else {
|
||||
let Some(Region::LateBound(_, _, def_id)) = def else {
|
||||
continue
|
||||
};
|
||||
let Some(def_id) = def_id.as_local() else {
|
||||
@ -1046,7 +1040,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
let (name, reg) = Region::early(self.tcx.hir(), &mut index, ¶m);
|
||||
let Region::EarlyBound(_, def_id, _) = reg else {
|
||||
let Region::EarlyBound(_, def_id) = reg else {
|
||||
bug!();
|
||||
};
|
||||
// We cannot predict what lifetimes are unused in opaque type.
|
||||
@ -1325,9 +1319,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
|
||||
if !self.trait_definition_only {
|
||||
check_mixed_explicit_and_in_band_defs(self.tcx, &generics.params);
|
||||
}
|
||||
let scope = Scope::TraitRefBoundary { s: self.scope };
|
||||
self.with(scope, |_, this| {
|
||||
for param in generics.params {
|
||||
@ -1535,30 +1526,6 @@ impl ShadowKind {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &[hir::GenericParam<'_>]) {
|
||||
let lifetime_params: Vec<_> = params
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { kind, .. } => Some((kind, param.span)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let explicit = lifetime_params.iter().find(|(kind, _)| *kind == LifetimeParamKind::Explicit);
|
||||
let in_band = lifetime_params.iter().find(|(kind, _)| *kind == LifetimeParamKind::InBand);
|
||||
|
||||
if let (Some((_, explicit_span)), Some((_, in_band_span))) = (explicit, in_band) {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
*in_band_span,
|
||||
E0688,
|
||||
"cannot mix in-band and explicit lifetime definitions"
|
||||
)
|
||||
.span_label(*in_band_span, "in-band lifetime definition here")
|
||||
.span_label(*explicit_span, "explicit lifetime definition here")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: Symbol, orig: Original, shadower: Shadower) {
|
||||
let mut err = if let (ShadowKind::Lifetime, ShadowKind::Lifetime) = (orig.kind, shadower.kind) {
|
||||
// lifetime/lifetime shadowing is an error
|
||||
@ -1696,7 +1663,7 @@ fn compute_object_lifetime_defaults<'tcx>(
|
||||
.map(|set| match *set {
|
||||
Set1::Empty => "BaseDefault".into(),
|
||||
Set1::One(Region::Static) => "'static".into(),
|
||||
Set1::One(Region::EarlyBound(mut i, _, _)) => generics
|
||||
Set1::One(Region::EarlyBound(mut i, _)) => generics
|
||||
.params
|
||||
.iter()
|
||||
.find_map(|param| match param.kind {
|
||||
@ -1777,18 +1744,16 @@ fn object_lifetime_defaults_for_item<'tcx>(
|
||||
.params
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => Some((
|
||||
param.hir_id,
|
||||
hir::LifetimeName::Param(param.name),
|
||||
LifetimeDefOrigin::from_param(param),
|
||||
)),
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some((param.hir_id, hir::LifetimeName::Param(param.name)))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.enumerate()
|
||||
.find(|&(_, (_, lt_name, _))| lt_name == name)
|
||||
.map_or(Set1::Many, |(i, (id, _, origin))| {
|
||||
.find(|&(_, (_, lt_name))| lt_name == name)
|
||||
.map_or(Set1::Many, |(i, (id, _))| {
|
||||
let def_id = tcx.hir().local_def_id(id);
|
||||
Set1::One(Region::EarlyBound(i as u32, def_id.to_def_id(), origin))
|
||||
Set1::One(Region::EarlyBound(i as u32, def_id.to_def_id()))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1846,13 +1811,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option<Span> {
|
||||
generics.params.iter().enumerate().find_map(|(i, param)| {
|
||||
if param.name.ident() == name {
|
||||
let in_band = matches!(
|
||||
param.kind,
|
||||
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::InBand }
|
||||
);
|
||||
if in_band {
|
||||
Some(param.span)
|
||||
} else if generics.params.len() == 1 {
|
||||
if generics.params.len() == 1 {
|
||||
// if sole lifetime, remove the entire `<>` brackets
|
||||
Some(generics.span)
|
||||
} else {
|
||||
@ -1982,8 +1941,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
let def_ids: Vec<_> = defined_by
|
||||
.values()
|
||||
.flat_map(|region| match region {
|
||||
Region::EarlyBound(_, def_id, _)
|
||||
| Region::LateBound(_, _, def_id, _)
|
||||
Region::EarlyBound(_, def_id)
|
||||
| Region::LateBound(_, _, def_id)
|
||||
| Region::Free(_, def_id) => Some(*def_id),
|
||||
|
||||
Region::LateBoundAnon(..) | Region::Static => None,
|
||||
@ -2338,39 +2297,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for fn-syntax conflicts with in-band lifetime definitions
|
||||
if !self.trait_definition_only && self.is_in_fn_syntax {
|
||||
match def {
|
||||
Region::EarlyBound(_, _, LifetimeDefOrigin::InBand)
|
||||
| Region::LateBound(_, _, _, LifetimeDefOrigin::InBand) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
lifetime_ref.span,
|
||||
E0687,
|
||||
"lifetimes used in `fn` or `Fn` syntax must be \
|
||||
explicitly declared using `<...>` binders"
|
||||
)
|
||||
.span_label(lifetime_ref.span, "in-band lifetime definition")
|
||||
.emit();
|
||||
}
|
||||
|
||||
Region::Static
|
||||
| Region::EarlyBound(
|
||||
_,
|
||||
_,
|
||||
LifetimeDefOrigin::ExplicitOrElided | LifetimeDefOrigin::Error,
|
||||
)
|
||||
| Region::LateBound(
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
LifetimeDefOrigin::ExplicitOrElided | LifetimeDefOrigin::Error,
|
||||
)
|
||||
| Region::LateBoundAnon(..)
|
||||
| Region::Free(..) => {}
|
||||
}
|
||||
}
|
||||
|
||||
self.insert_lifetime(lifetime_ref, def);
|
||||
} else {
|
||||
self.emit_undeclared_lifetime_error(lifetime_ref);
|
||||
@ -2950,7 +2876,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
|
||||
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
|
||||
match lifetime {
|
||||
Region::LateBound(debruijn, _, _, _)
|
||||
Region::LateBound(debruijn, _, _)
|
||||
| Region::LateBoundAnon(debruijn, _, _)
|
||||
if debruijn < self.outer_index =>
|
||||
{
|
||||
@ -3356,8 +3282,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
Region::Free(_, def_id)
|
||||
| Region::LateBound(_, _, def_id, _)
|
||||
| Region::EarlyBound(_, def_id, _) => {
|
||||
| Region::LateBound(_, _, def_id)
|
||||
| Region::EarlyBound(_, def_id) => {
|
||||
// A lifetime declared by the user.
|
||||
let track_lifetime_uses = self.track_lifetime_uses();
|
||||
debug!(?track_lifetime_uses);
|
||||
|
@ -205,7 +205,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let r = match tcx.named_region(lifetime.hir_id) {
|
||||
Some(rl::Region::Static) => tcx.lifetimes.re_static,
|
||||
|
||||
Some(rl::Region::LateBound(debruijn, index, def_id, _)) => {
|
||||
Some(rl::Region::LateBound(debruijn, index, def_id)) => {
|
||||
let name = lifetime_name(def_id.expect_local());
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(index),
|
||||
@ -222,7 +222,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
tcx.mk_region(ty::ReLateBound(debruijn, br))
|
||||
}
|
||||
|
||||
Some(rl::Region::EarlyBound(index, id, _)) => {
|
||||
Some(rl::Region::EarlyBound(index, id)) => {
|
||||
let name = lifetime_name(id.expect_local());
|
||||
tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { def_id: id, index, name }))
|
||||
}
|
||||
|
@ -1377,7 +1377,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||
match self.tcx.named_region(lt.hir_id) {
|
||||
Some(rl::Region::Static | rl::Region::EarlyBound(..)) => {}
|
||||
Some(
|
||||
rl::Region::LateBound(debruijn, _, _, _)
|
||||
rl::Region::LateBound(debruijn, _, _)
|
||||
| rl::Region::LateBoundAnon(debruijn, _, _),
|
||||
) if debruijn < self.outer_index => {}
|
||||
Some(
|
||||
|
@ -8,7 +8,7 @@ use crate::fmt;
|
||||
use crate::fs;
|
||||
use crate::marker::PhantomData;
|
||||
use crate::mem::forget;
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
#[cfg(not(any(target_os = "wasi", target_env = "sgx")))]
|
||||
use crate::sys::cvt;
|
||||
use crate::sys_common::{AsInner, FromInner, IntoInner};
|
||||
|
||||
|
@ -193,8 +193,8 @@ impl Clean<Lifetime> for hir::Lifetime {
|
||||
fn clean(&self, cx: &mut DocContext<'_>) -> Lifetime {
|
||||
let def = cx.tcx.named_region(self.hir_id);
|
||||
if let Some(
|
||||
rl::Region::EarlyBound(_, node_id, _)
|
||||
| rl::Region::LateBound(_, _, node_id, _)
|
||||
rl::Region::EarlyBound(_, node_id)
|
||||
| rl::Region::LateBound(_, _, node_id)
|
||||
| rl::Region::Free(_, node_id),
|
||||
) = def
|
||||
{
|
||||
|
@ -17,23 +17,29 @@
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/union.rs:13:9: 13:11
|
||||
StorageLive(_2); // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
_2 = val() -> bb1; // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
- StorageLive(_1); // scope 0 at $DIR/union.rs:13:9: 13:11
|
||||
- StorageLive(_2); // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
- _2 = val() -> bb1; // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
+ nop; // scope 0 at $DIR/union.rs:13:9: 13:11
|
||||
+ nop; // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
+ (_1.0: u32) = val() -> bb1; // scope 0 at $DIR/union.rs:13:23: 13:28
|
||||
// mir::Constant
|
||||
// + span: $DIR/union.rs:13:23: 13:26
|
||||
// + literal: Const { ty: fn() -> u32 {val}, val: Value(Scalar(<ZST>)) }
|
||||
}
|
||||
|
||||
bb1: {
|
||||
(_1.0: u32) = move _2; // scope 0 at $DIR/union.rs:13:14: 13:30
|
||||
StorageDead(_2); // scope 0 at $DIR/union.rs:13:29: 13:30
|
||||
- (_1.0: u32) = move _2; // scope 0 at $DIR/union.rs:13:14: 13:30
|
||||
- StorageDead(_2); // scope 0 at $DIR/union.rs:13:29: 13:30
|
||||
+ nop; // scope 0 at $DIR/union.rs:13:14: 13:30
|
||||
+ nop; // scope 0 at $DIR/union.rs:13:29: 13:30
|
||||
StorageLive(_3); // scope 1 at $DIR/union.rs:15:5: 15:27
|
||||
StorageLive(_4); // scope 1 at $DIR/union.rs:15:10: 15:26
|
||||
_4 = (_1.0: u32); // scope 2 at $DIR/union.rs:15:19: 15:24
|
||||
StorageDead(_4); // scope 1 at $DIR/union.rs:15:26: 15:27
|
||||
StorageDead(_3); // scope 1 at $DIR/union.rs:15:27: 15:28
|
||||
StorageDead(_1); // scope 0 at $DIR/union.rs:16:1: 16:2
|
||||
- StorageDead(_1); // scope 0 at $DIR/union.rs:16:1: 16:2
|
||||
+ nop; // scope 0 at $DIR/union.rs:16:1: 16:2
|
||||
return; // scope 0 at $DIR/union.rs:16:2: 16:2
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! Tests that projections through unions cancel `DestinationPropagation`.
|
||||
//! Tests that we can propogate into places that are projections into unions
|
||||
// compile-flags: -Zunsound-mir-opts
|
||||
fn val() -> u32 {
|
||||
1
|
||||
|
@ -3,12 +3,36 @@ goto: file://|DOC_PATH|/test_docs/index.html
|
||||
assert-attribute: ("#main-content > details.top-doc", {"open": ""})
|
||||
assert-text: ("#toggle-all-docs", "[−]")
|
||||
click: "#toggle-all-docs"
|
||||
wait-for: 1000
|
||||
wait-for: 50
|
||||
// This is now collapsed so there shouldn't be the "open" attribute on details.
|
||||
assert-attribute-false: ("#main-content > details.top-doc", {"open": ""})
|
||||
assert-text: ("#toggle-all-docs", "[+]")
|
||||
click: "#toggle-all-docs"
|
||||
wait-for: 1000
|
||||
wait-for: 50
|
||||
// Not collapsed anymore so the "open" attribute should be back.
|
||||
assert-attribute: ("#main-content > details.top-doc", {"open": ""})
|
||||
assert-text: ("#toggle-all-docs", "[−]")
|
||||
|
||||
// Check that it works on non-module pages as well.
|
||||
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
|
||||
// We first check that everything is visible.
|
||||
assert-text: ("#toggle-all-docs", "[−]")
|
||||
assert-attribute: ("details.rustdoc-toggle", {"open": ""}, ALL)
|
||||
// We collapse them all.
|
||||
click: "#toggle-all-docs"
|
||||
wait-for: 50
|
||||
assert-text: ("#toggle-all-docs", "[+]")
|
||||
// We check that all <details> are collapsed (except for the impl block ones).
|
||||
assert-attribute-false: ("details.rustdoc-toggle:not(.implementors-toggle)", {"open": ""}, ALL)
|
||||
assert-attribute: ("details.rustdoc-toggle.implementors-toggle", {"open": ""})
|
||||
// We now check that the other impl blocks are collapsed.
|
||||
assert-attribute-false: (
|
||||
"#blanket-implementations-list > details.rustdoc-toggle.implementors-toggle",
|
||||
{"open": ""},
|
||||
ALL,
|
||||
)
|
||||
// We open them all again.
|
||||
click: "#toggle-all-docs"
|
||||
wait-for: 50
|
||||
assert-text: ("#toggle-all-docs", "[−]")
|
||||
assert-attribute: ("details.rustdoc-toggle", {"open": ""}, ALL)
|
||||
|
@ -2,8 +2,6 @@
|
||||
// edition:2018
|
||||
// compile-flags: --crate-type lib
|
||||
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
pub async fn simple_generic<T>() {}
|
||||
@ -73,10 +71,6 @@ pub fn call_with_ref_block<'a>(f: &'a (impl Foo + 'a)) -> impl Future<Output = (
|
||||
async move { f.foo() }
|
||||
}
|
||||
|
||||
pub fn call_with_ref_block_in_band(f: &'a (impl Foo + 'a)) -> impl Future<Output = ()> + 'a {
|
||||
async move { f.foo() }
|
||||
}
|
||||
|
||||
pub fn async_block_with_same_generic_params_unifies() {
|
||||
let mut a = call_generic_bound_block(FooType);
|
||||
a = call_generic_bound_block(FooType);
|
||||
@ -91,9 +85,4 @@ pub fn async_block_with_same_generic_params_unifies() {
|
||||
let f_two = FooType;
|
||||
let mut d = call_with_ref_block(&f_one);
|
||||
d = call_with_ref_block(&f_two);
|
||||
|
||||
let f_one = FooType;
|
||||
let f_two = FooType;
|
||||
let mut d = call_with_ref_block_in_band(&f_one);
|
||||
d = call_with_ref_block_in_band(&f_two);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref-ptr.rs:49:1
|
||||
|
|
||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a potentially null function pointer
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null function pointer
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
|
@ -112,7 +112,7 @@ error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref-ptr.rs:49:1
|
||||
|
|
||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a potentially null function pointer
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null function pointer
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
|
@ -35,21 +35,21 @@ mod cross_crate {
|
||||
i: 0 //~ ERROR use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text
|
||||
};
|
||||
|
||||
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedUnitStruct`: text
|
||||
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::DeprecatedUnitStruct`: text
|
||||
|
||||
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated variant `deprecation_lint::Enum::DeprecatedVariant`: text
|
||||
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::Enum::DeprecatedVariant`: text
|
||||
|
||||
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated struct `deprecation_lint::DeprecatedTupleStruct`: text
|
||||
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::DeprecatedTupleStruct`: text
|
||||
|
||||
let _ = nested::DeprecatedStruct { //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: text
|
||||
i: 0 //~ ERROR use of deprecated field `deprecation_lint::nested::DeprecatedStruct::i`: text
|
||||
};
|
||||
|
||||
let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
|
||||
let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated unit struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
|
||||
|
||||
let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
|
||||
let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated unit variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
|
||||
|
||||
let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
|
||||
let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
|
||||
|
||||
// At the moment, the lint checker only checks stability in
|
||||
// in the arguments of macros.
|
||||
@ -130,7 +130,7 @@ mod cross_crate {
|
||||
{ .. } = x;
|
||||
|
||||
let x = Deprecated2(1, 2, 3);
|
||||
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
|
||||
let _ = x.0;
|
||||
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
|
||||
@ -140,7 +140,7 @@ mod cross_crate {
|
||||
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
|
||||
|
||||
let Deprecated2
|
||||
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
(_,
|
||||
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::0`: text
|
||||
_,
|
||||
@ -149,7 +149,7 @@ mod cross_crate {
|
||||
//~^ ERROR use of deprecated field `deprecation_lint::Deprecated2::2`: text
|
||||
= x;
|
||||
let Deprecated2
|
||||
//~^ ERROR use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
//~^ ERROR use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
// the patterns are all fine:
|
||||
(..) = x;
|
||||
}
|
||||
|
@ -46,19 +46,19 @@ error: use of deprecated struct `deprecation_lint::DeprecatedStruct`: text
|
||||
LL | let _ = DeprecatedStruct {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::DeprecatedUnitStruct`: text
|
||||
error: use of deprecated unit struct `deprecation_lint::DeprecatedUnitStruct`: text
|
||||
--> $DIR/deprecation-lint.rs:38:17
|
||||
|
|
||||
LL | let _ = DeprecatedUnitStruct;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated variant `deprecation_lint::Enum::DeprecatedVariant`: text
|
||||
error: use of deprecated unit variant `deprecation_lint::Enum::DeprecatedVariant`: text
|
||||
--> $DIR/deprecation-lint.rs:40:23
|
||||
|
|
||||
LL | let _ = Enum::DeprecatedVariant;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::DeprecatedTupleStruct`: text
|
||||
error: use of deprecated tuple struct `deprecation_lint::DeprecatedTupleStruct`: text
|
||||
--> $DIR/deprecation-lint.rs:42:17
|
||||
|
|
||||
LL | let _ = DeprecatedTupleStruct (1);
|
||||
@ -70,19 +70,19 @@ error: use of deprecated struct `deprecation_lint::nested::DeprecatedStruct`: te
|
||||
LL | let _ = nested::DeprecatedStruct {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
|
||||
error: use of deprecated unit struct `deprecation_lint::nested::DeprecatedUnitStruct`: text
|
||||
--> $DIR/deprecation-lint.rs:48:25
|
||||
|
|
||||
LL | let _ = nested::DeprecatedUnitStruct;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
|
||||
error: use of deprecated unit variant `deprecation_lint::nested::Enum::DeprecatedVariant`: text
|
||||
--> $DIR/deprecation-lint.rs:50:31
|
||||
|
|
||||
LL | ... let _ = nested::Enum::DeprecatedVariant;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
|
||||
error: use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text
|
||||
--> $DIR/deprecation-lint.rs:52:25
|
||||
|
|
||||
LL | ... let _ = nested::DeprecatedTupleStruct (1);
|
||||
@ -154,19 +154,19 @@ error: use of deprecated struct `deprecation_lint::Deprecated`: text
|
||||
LL | let Deprecated
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
--> $DIR/deprecation-lint.rs:132:17
|
||||
|
|
||||
LL | let x = Deprecated2(1, 2, 3);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
--> $DIR/deprecation-lint.rs:142:13
|
||||
|
|
||||
LL | let Deprecated2
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `deprecation_lint::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `deprecation_lint::Deprecated2`: text
|
||||
--> $DIR/deprecation-lint.rs:151:13
|
||||
|
|
||||
LL | let Deprecated2
|
||||
|
@ -5,8 +5,6 @@ LL | fn foo(x: &'a str) { }
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/E0261.rs:5:9
|
||||
@ -15,8 +13,6 @@ LL | struct Foo {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | x: &'a str,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
|
||||
fn foo(x: &'x u8) -> &'x u8 { x }
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
//~^^ ERROR use of undeclared lifetime name
|
||||
|
||||
struct X<'a>(&'a u8);
|
||||
|
||||
impl<'a> X<'a> {
|
||||
fn inner(&self) -> &'a u8 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> X<'b> {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn inner_2(&self) -> &'b u8 {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl X<'b> {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn inner_3(&self) -> &'b u8 {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
struct Y<T>(T);
|
||||
|
||||
impl Y<&'a u8> {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn inner(&self) -> &'a u8 {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
trait MyTrait<'a> {
|
||||
fn my_lifetime(&self) -> &'a u8;
|
||||
fn any_lifetime() -> &'b u8;
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
//~^^ ERROR use of undeclared lifetime name
|
||||
}
|
||||
|
||||
impl MyTrait<'a> for Y<&'a u8> {
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
//~^^ ERROR use of undeclared lifetime name
|
||||
fn my_lifetime(&self) -> &'a u8 { self.0 }
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn any_lifetime() -> &'b u8 { &0 }
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||
//~^ ERROR use of undeclared lifetime name
|
||||
//~^^ ERROR use of undeclared lifetime name
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,231 +0,0 @@
|
||||
error[E0261]: use of undeclared lifetime name `'x`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:3:12
|
||||
|
|
||||
LL | fn foo(x: &'x u8) -> &'x u8 { x }
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'x` here: `<'x>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'x`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:3:23
|
||||
|
|
||||
LL | fn foo(x: &'x u8) -> &'x u8 { x }
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'x` here: `<'x>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:15:12
|
||||
|
|
||||
LL | impl<'a> X<'b> {
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'b` here: `'b,`
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:17:27
|
||||
|
|
||||
LL | fn inner_2(&self) -> &'b u8 {
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b, 'a> X<'b> {
|
||||
| +++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn inner_2<'b>(&self) -> &'b u8 {
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:23:8
|
||||
|
|
||||
LL | impl X<'b> {
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'b` here: `<'b>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:25:27
|
||||
|
|
||||
LL | fn inner_3(&self) -> &'b u8 {
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b> X<'b> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn inner_3<'b>(&self) -> &'b u8 {
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:33:9
|
||||
|
|
||||
LL | impl Y<&'a u8> {
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:35:25
|
||||
|
|
||||
LL | fn inner(&self) -> &'a u8 {
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'a` here
|
||||
|
|
||||
LL | impl<'a> Y<&'a u8> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'a` here
|
||||
|
|
||||
LL | fn inner<'a>(&self) -> &'a u8 {
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:50:14
|
||||
|
|
||||
LL | impl MyTrait<'a> for Y<&'a u8> {
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:50:25
|
||||
|
|
||||
LL | impl MyTrait<'a> for Y<&'a u8> {
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:53:31
|
||||
|
|
||||
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'a` here
|
||||
|
|
||||
LL | impl<'a> MyTrait<'a> for Y<&'a u8> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'a` here
|
||||
|
|
||||
LL | fn my_lifetime<'a>(&self) -> &'a u8 { self.0 }
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:55:27
|
||||
|
|
||||
LL | fn any_lifetime() -> &'b u8 { &0 }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn any_lifetime<'b>() -> &'b u8 { &0 }
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:57:27
|
||||
|
|
||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn borrowed_lifetime<'b>(&'b self) -> &'b u8 { &*self.0 }
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:57:40
|
||||
|
|
||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b> MyTrait<'a> for Y<&'a u8> {
|
||||
| ++++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn borrowed_lifetime<'b>(&'b self) -> &'b u8 { &*self.0 }
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:43:27
|
||||
|
|
||||
LL | fn any_lifetime() -> &'b u8;
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | trait MyTrait<'b, 'a> {
|
||||
| +++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn any_lifetime<'b>() -> &'b u8;
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:45:27
|
||||
|
|
||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | trait MyTrait<'b, 'a> {
|
||||
| +++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn borrowed_lifetime<'b>(&'b self) -> &'b u8;
|
||||
| ++++
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/feature-gate-in_band_lifetimes.rs:45:40
|
||||
|
|
||||
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | trait MyTrait<'b, 'a> {
|
||||
| +++
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn borrowed_lifetime<'b>(&'b self) -> &'b u8;
|
||||
| ++++
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0261`.
|
@ -5,8 +5,6 @@ LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'x` here: `<'x>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
|
||||
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:33
|
||||
|
@ -4,7 +4,6 @@ error[E0261]: use of undeclared lifetime name `'b`
|
||||
LL | + Deref<Target = Self::Item<'b>>;
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | trait Iterable<'b> {
|
||||
@ -20,7 +19,6 @@ error[E0261]: use of undeclared lifetime name `'undeclared`
|
||||
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
|
||||
| ^^^^^^^^^^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'undeclared` here
|
||||
|
|
||||
LL | trait Iterable<'undeclared> {
|
||||
|
@ -5,8 +5,6 @@ LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/issue-67510.rs:7:26
|
||||
@ -15,8 +13,6 @@ LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -8,9 +8,8 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: &'x u32) -> impl Fn() -> &'y u32
|
||||
fn foo<'x, 'y>(x: &'x u32) -> impl Fn() -> &'y u32
|
||||
where 'x: 'y
|
||||
{
|
||||
move || x
|
||||
|
@ -8,13 +8,12 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
trait Trait<'a> { }
|
||||
|
||||
impl Trait<'b> for &'a u32 { }
|
||||
impl<'a, 'b> Trait<'b> for &'a u32 { }
|
||||
|
||||
fn foo(x: &'x u32) -> impl Trait<'y>
|
||||
fn foo<'x, 'y>(x: &'x u32) -> impl Trait<'y>
|
||||
where 'x: 'y
|
||||
{
|
||||
x
|
||||
|
@ -4,15 +4,14 @@
|
||||
// See https://github.com/rust-lang/rust/issues/46541 for more details.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
trait Trait<'a> { }
|
||||
|
||||
impl Trait<'b> for Cell<&'a u32> { }
|
||||
impl<'a, 'b> Trait<'b> for Cell<&'a u32> { }
|
||||
|
||||
fn foo(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700]
|
||||
where 'x: 'y
|
||||
{
|
||||
|
@ -1,16 +1,15 @@
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/region-escape-via-bound.rs:15:29
|
||||
--> $DIR/region-escape-via-bound.rs:14:37
|
||||
|
|
||||
LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
| ^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | where 'x: 'y
|
||||
| -- hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here
|
||||
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
| -- ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here
|
||||
|
|
||||
help: to declare that the `impl Trait` captures `'x`, you can add an explicit `'x` lifetime bound
|
||||
|
|
||||
LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y> + 'x
|
||||
| ++++
|
||||
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + 'x
|
||||
| ++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: fn(&'a u32)) {} //~ ERROR must be explicitly
|
||||
|
||||
fn bar(x: &Fn(&'a u32)) {} //~ ERROR must be explicitly
|
||||
|
||||
fn baz(x: fn(&'a u32), y: &'a u32) {} //~ ERROR must be explicitly
|
||||
|
||||
struct Foo<'a> { x: &'a u32 }
|
||||
|
||||
impl Foo<'a> {
|
||||
fn bar(&self, x: fn(&'a u32)) {} //~ ERROR must be explicitly
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,27 +0,0 @@
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687.rs:4:15
|
||||
|
|
||||
LL | fn foo(x: fn(&'a u32)) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687.rs:6:16
|
||||
|
|
||||
LL | fn bar(x: &Fn(&'a u32)) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687.rs:8:15
|
||||
|
|
||||
LL | fn baz(x: fn(&'a u32), y: &'a u32) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687.rs:13:26
|
||||
|
|
||||
LL | fn bar(&self, x: fn(&'a u32)) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0687`.
|
@ -1,8 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn bar<F>(x: &F) where F: Fn(&'a u32) {} //~ ERROR must be explicitly
|
||||
|
||||
fn baz(x: &impl Fn(&'a u32)) {} //~ ERROR must be explicitly
|
||||
|
||||
fn main() {}
|
@ -1,15 +0,0 @@
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687_where.rs:4:31
|
||||
|
|
||||
LL | fn bar<F>(x: &F) where F: Fn(&'a u32) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error[E0687]: lifetimes used in `fn` or `Fn` syntax must be explicitly declared using `<...>` binders
|
||||
--> $DIR/E0687_where.rs:6:21
|
||||
|
|
||||
LL | fn baz(x: &impl Fn(&'a u32)) {}
|
||||
| ^^ in-band lifetime definition
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0687`.
|
@ -1,16 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo<'a>(x: &'a u32, y: &'b u32) {} //~ ERROR cannot mix
|
||||
|
||||
struct Foo<'a> { x: &'a u32 }
|
||||
|
||||
impl Foo<'a> {
|
||||
fn bar<'b>(x: &'a u32, y: &'b u32, z: &'c u32) {} //~ ERROR cannot mix
|
||||
}
|
||||
|
||||
impl<'b> Foo<'a> { //~ ERROR cannot mix
|
||||
fn baz() {}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,27 +0,0 @@
|
||||
error[E0688]: cannot mix in-band and explicit lifetime definitions
|
||||
--> $DIR/E0688.rs:4:28
|
||||
|
|
||||
LL | fn foo<'a>(x: &'a u32, y: &'b u32) {}
|
||||
| -- ^^ in-band lifetime definition here
|
||||
| |
|
||||
| explicit lifetime definition here
|
||||
|
||||
error[E0688]: cannot mix in-band and explicit lifetime definitions
|
||||
--> $DIR/E0688.rs:9:44
|
||||
|
|
||||
LL | fn bar<'b>(x: &'a u32, y: &'b u32, z: &'c u32) {}
|
||||
| -- ^^ in-band lifetime definition here
|
||||
| |
|
||||
| explicit lifetime definition here
|
||||
|
||||
error[E0688]: cannot mix in-band and explicit lifetime definitions
|
||||
--> $DIR/E0688.rs:12:14
|
||||
|
|
||||
LL | impl<'b> Foo<'a> {
|
||||
| -- ^^ in-band lifetime definition here
|
||||
| |
|
||||
| explicit lifetime definition here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0688`.
|
@ -1,119 +0,0 @@
|
||||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![allow(unused)]
|
||||
#![deny(elided_lifetimes_in_paths)]
|
||||
//~^ NOTE the lint level is defined here
|
||||
|
||||
use std::cell::{Ref, RefCell};
|
||||
|
||||
struct Foo<'a> {
|
||||
x: &'a u32,
|
||||
}
|
||||
|
||||
fn foo(x: &Foo<'_>) {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
}
|
||||
|
||||
fn bar(x: &Foo<'_>) {}
|
||||
|
||||
struct Wrapped<'a>(&'a str);
|
||||
|
||||
struct WrappedWithBow<'a> {
|
||||
gift: &'a str,
|
||||
}
|
||||
|
||||
struct MatchedSet<'a, 'b> {
|
||||
one: &'a str,
|
||||
another: &'b str,
|
||||
}
|
||||
|
||||
fn wrap_gift(gift: &str) -> Wrapped<'_> {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
Wrapped(gift)
|
||||
}
|
||||
|
||||
fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow<'_> {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
WrappedWithBow { gift }
|
||||
}
|
||||
|
||||
fn inspect_matched_set(set: MatchedSet<'_, '_>) {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected 2 lifetime parameters
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
println!("{} {}", set.one, set.another);
|
||||
}
|
||||
|
||||
// Verify that the lint does not fire, because the added `'_` wouldn't be resolved correctly.
|
||||
fn match_sets() -> MatchedSet<'static, 'static> {
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| NOTE expected 2 lifetime parameters
|
||||
//~| HELP this function's return type contains a borrowed value
|
||||
//~| HELP consider using the `'static` lifetime
|
||||
MatchedSet { one: "one", another: "another" }
|
||||
}
|
||||
|
||||
macro_rules! autowrapper {
|
||||
($type_name:ident, $fn_name:ident, $lt:lifetime) => {
|
||||
struct $type_name<$lt> {
|
||||
gift: &$lt str
|
||||
}
|
||||
|
||||
fn $fn_name(gift: &str) -> $type_name<'_> {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
//~| ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
$type_name { gift }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
autowrapper!(Autowrapped, autowrap_gift, 'a);
|
||||
//~^ NOTE in this expansion of autowrapper!
|
||||
//~| NOTE in this expansion of autowrapper!
|
||||
|
||||
// Verify that rustfix does not try to apply the fix twice.
|
||||
autowrapper!(AutowrappedAgain, autowrap_gift_again, 'a);
|
||||
//~^ NOTE in this expansion of autowrapper!
|
||||
//~| NOTE in this expansion of autowrapper!
|
||||
|
||||
macro_rules! anytuple_ref_ty {
|
||||
($($types:ty),*) => {
|
||||
Ref<'_, ($($types),*)>
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(elided_lifetimes_in_paths)]
|
||||
mod blah {
|
||||
struct Thing<'a>(&'a i32);
|
||||
struct Bar<T>(T);
|
||||
|
||||
fn foo(b: Bar<Thing>) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let honesty = RefCell::new((4, 'e'));
|
||||
let loyalty: Ref<'_, (u32, char)> = honesty.borrow();
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
let generosity = Ref::map(loyalty, |t| &t.0);
|
||||
|
||||
let laughter = RefCell::new((true, "magic"));
|
||||
let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
|
||||
//~^ NOTE in this expansion of anytuple_ref_ty!
|
||||
//~| NOTE in this expansion of anytuple_ref_ty!
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![allow(unused)]
|
||||
#![deny(elided_lifetimes_in_paths)]
|
||||
//~^ NOTE the lint level is defined here
|
||||
|
||||
use std::cell::{Ref, RefCell};
|
||||
|
||||
struct Foo<'a> {
|
||||
x: &'a u32,
|
||||
}
|
||||
|
||||
fn foo(x: &Foo) {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
}
|
||||
|
||||
fn bar(x: &Foo<'_>) {}
|
||||
|
||||
struct Wrapped<'a>(&'a str);
|
||||
|
||||
struct WrappedWithBow<'a> {
|
||||
gift: &'a str,
|
||||
}
|
||||
|
||||
struct MatchedSet<'a, 'b> {
|
||||
one: &'a str,
|
||||
another: &'b str,
|
||||
}
|
||||
|
||||
fn wrap_gift(gift: &str) -> Wrapped {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
Wrapped(gift)
|
||||
}
|
||||
|
||||
fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
WrappedWithBow { gift }
|
||||
}
|
||||
|
||||
fn inspect_matched_set(set: MatchedSet) {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected 2 lifetime parameters
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
println!("{} {}", set.one, set.another);
|
||||
}
|
||||
|
||||
// Verify that the lint does not fire, because the added `'_` wouldn't be resolved correctly.
|
||||
fn match_sets() -> MatchedSet {
|
||||
//~^ ERROR missing lifetime specifiers
|
||||
//~| NOTE expected 2 lifetime parameters
|
||||
//~| HELP this function's return type contains a borrowed value
|
||||
//~| HELP consider using the `'static` lifetime
|
||||
MatchedSet { one: "one", another: "another" }
|
||||
}
|
||||
|
||||
macro_rules! autowrapper {
|
||||
($type_name:ident, $fn_name:ident, $lt:lifetime) => {
|
||||
struct $type_name<$lt> {
|
||||
gift: &$lt str
|
||||
}
|
||||
|
||||
fn $fn_name(gift: &str) -> $type_name {
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
//~| ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
$type_name { gift }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
autowrapper!(Autowrapped, autowrap_gift, 'a);
|
||||
//~^ NOTE in this expansion of autowrapper!
|
||||
//~| NOTE in this expansion of autowrapper!
|
||||
|
||||
// Verify that rustfix does not try to apply the fix twice.
|
||||
autowrapper!(AutowrappedAgain, autowrap_gift_again, 'a);
|
||||
//~^ NOTE in this expansion of autowrapper!
|
||||
//~| NOTE in this expansion of autowrapper!
|
||||
|
||||
macro_rules! anytuple_ref_ty {
|
||||
($($types:ty),*) => {
|
||||
Ref<($($types),*)>
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(elided_lifetimes_in_paths)]
|
||||
mod blah {
|
||||
struct Thing<'a>(&'a i32);
|
||||
struct Bar<T>(T);
|
||||
|
||||
fn foo(b: Bar<Thing>) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let honesty = RefCell::new((4, 'e'));
|
||||
let loyalty: Ref<(u32, char)> = honesty.borrow();
|
||||
//~^ ERROR hidden lifetime parameters in types are deprecated
|
||||
//~| NOTE expected named lifetime parameter
|
||||
//~| HELP consider using the `'_` lifetime
|
||||
let generosity = Ref::map(loyalty, |t| &t.0);
|
||||
|
||||
let laughter = RefCell::new((true, "magic"));
|
||||
let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
|
||||
//~^ NOTE in this expansion of anytuple_ref_ty!
|
||||
//~| NOTE in this expansion of anytuple_ref_ty!
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:14:12
|
||||
|
|
||||
LL | fn foo(x: &Foo) {
|
||||
| ^^^ expected named lifetime parameter
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/elided-lifetimes.rs:5:9
|
||||
|
|
||||
LL | #![deny(elided_lifetimes_in_paths)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn foo(x: &Foo<'_>) {
|
||||
| ~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:33:29
|
||||
|
|
||||
LL | fn wrap_gift(gift: &str) -> Wrapped {
|
||||
| ^^^^^^^ expected named lifetime parameter
|
||||
|
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn wrap_gift(gift: &str) -> Wrapped<'_> {
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:40:38
|
||||
|
|
||||
LL | fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
|
||||
| ^^^^^^^^^^^^^^ expected named lifetime parameter
|
||||
|
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow<'_> {
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:47:29
|
||||
|
|
||||
LL | fn inspect_matched_set(set: MatchedSet) {
|
||||
| ^^^^^^^^^^ expected 2 lifetime parameters
|
||||
|
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn inspect_matched_set(set: MatchedSet<'_, '_>) {
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0106]: missing lifetime specifiers
|
||||
--> $DIR/elided-lifetimes.rs:55:20
|
||||
|
|
||||
LL | fn match_sets() -> MatchedSet {
|
||||
| ^^^^^^^^^^ expected 2 lifetime parameters
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||
help: consider using the `'static` lifetime
|
||||
|
|
||||
LL | fn match_sets() -> MatchedSet<'static, 'static> {
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:69:36
|
||||
|
|
||||
LL | fn $fn_name(gift: &str) -> $type_name {
|
||||
| ^^^^^^^^^^ expected named lifetime parameter
|
||||
...
|
||||
LL | autowrapper!(Autowrapped, autowrap_gift, 'a);
|
||||
| -------------------------------------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `autowrapper` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn $fn_name(gift: &str) -> $type_name<'_> {
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:69:36
|
||||
|
|
||||
LL | fn $fn_name(gift: &str) -> $type_name {
|
||||
| ^^^^^^^^^^ expected named lifetime parameter
|
||||
...
|
||||
LL | autowrapper!(AutowrappedAgain, autowrap_gift_again, 'a);
|
||||
| ------------------------------------------------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `autowrapper` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | fn $fn_name(gift: &str) -> $type_name<'_> {
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:109:22
|
||||
|
|
||||
LL | let loyalty: Ref<(u32, char)> = honesty.borrow();
|
||||
| ^ expected named lifetime parameter
|
||||
|
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | let loyalty: Ref<'_, (u32, char)> = honesty.borrow();
|
||||
| +++
|
||||
|
||||
error: hidden lifetime parameters in types are deprecated
|
||||
--> $DIR/elided-lifetimes.rs:92:13
|
||||
|
|
||||
LL | Ref<($($types),*)>
|
||||
| ^ expected named lifetime parameter
|
||||
...
|
||||
LL | let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
|
||||
| ---------------------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `anytuple_ref_ty` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider using the `'_` lifetime
|
||||
|
|
||||
LL | Ref<'_, ($($types),*)>
|
||||
| +++
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
@ -1,96 +0,0 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: &'x u8) -> &'x u8 { x }
|
||||
fn foo2(x: &'a u8, y: &u8) -> &'a u8 { x }
|
||||
|
||||
fn check_in_band_can_be_late_bound() {
|
||||
let _: for<'x> fn(&'x u8, &u8) -> &'x u8 = foo2;
|
||||
}
|
||||
|
||||
struct ForInherentNoParams;
|
||||
|
||||
impl ForInherentNoParams {
|
||||
fn foo(x: &'a u32, y: &u32) -> &'a u32 { x }
|
||||
}
|
||||
|
||||
struct X<'a>(&'a u8);
|
||||
|
||||
impl<'a> X<'a> {
|
||||
fn inner(&self) -> &'a u8 {
|
||||
self.0
|
||||
}
|
||||
|
||||
fn same_lifetime_as_parameter(&mut self, x: &'a u8) {
|
||||
self.0 = x;
|
||||
}
|
||||
}
|
||||
|
||||
impl X<'b> {
|
||||
fn inner_2(&self) -> &'b u8 {
|
||||
self.0
|
||||
}
|
||||
|
||||
fn reference_already_introduced_in_band_from_method_with_explicit_binders<'a>(
|
||||
&'b self, x: &'a u32
|
||||
) {}
|
||||
}
|
||||
|
||||
struct Y<T>(T);
|
||||
|
||||
impl Y<&'a u8> {
|
||||
fn inner(&self) -> &'a u8 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
trait MyTrait<'a> {
|
||||
fn my_lifetime(&self) -> &'a u8;
|
||||
fn any_lifetime() -> &'b u8;
|
||||
fn borrowed_lifetime(&'b self) -> &'b u8;
|
||||
fn default_impl(&self, x: &'b u32, y: &u32) -> &'b u32 { x }
|
||||
fn in_band_def_explicit_impl(&self, x: &'b u8);
|
||||
}
|
||||
|
||||
impl MyTrait<'a> for Y<&'a u8> {
|
||||
fn my_lifetime(&self) -> &'a u8 { self.0 }
|
||||
fn any_lifetime() -> &'b u8 { &0 }
|
||||
fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
|
||||
fn in_band_def_explicit_impl<'b>(&self, x: &'b u8) {}
|
||||
}
|
||||
|
||||
fn test_hrtb_defined_lifetime_where<F>(_: F) where for<'a> F: Fn(&'a u8) {}
|
||||
fn test_hrtb_defined_lifetime_polytraitref<F>(_: F) where F: for<'a> Fn(&'a u8) {}
|
||||
|
||||
fn reference_in_band_from_locals(x: &'test u32) -> &'test u32 {
|
||||
let y: &'test u32 = x;
|
||||
y
|
||||
}
|
||||
|
||||
fn in_generics_in_band<T: MyTrait<'a>>(x: &T) {}
|
||||
fn where_clause_in_band<T>(x: &T) where T: MyTrait<'a> {}
|
||||
fn impl_trait_in_band(x: &impl MyTrait<'a>) {}
|
||||
|
||||
// Tests around using in-band lifetimes within existential traits.
|
||||
|
||||
trait FunkyTrait<'a> { }
|
||||
impl<'a, T> FunkyTrait<'a> for T { }
|
||||
fn ret_pos_impl_trait_in_band_outlives(x: &'a u32) -> impl ::std::fmt::Debug + 'a {
|
||||
x
|
||||
}
|
||||
fn ret_pos_impl_trait_in_band_param(x: &'a u32) -> impl FunkyTrait<'a> {
|
||||
x
|
||||
}
|
||||
fn ret_pos_impl_trait_in_band_param_static(x: &'a u32) -> impl FunkyTrait<'static> + 'a {
|
||||
x
|
||||
}
|
||||
fn ret_pos_impl_trait_in_band_param_outlives(x: &'a u32) -> impl FunkyTrait<'a> + 'a {
|
||||
x
|
||||
}
|
||||
fn ret_pos_impl_trait_in_band_higher_ranked(x: &'a u32) -> impl for<'b> FunkyTrait<'b> + 'a {
|
||||
x
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,10 +0,0 @@
|
||||
#![deny(elided_lifetimes_in_paths)]
|
||||
|
||||
// Previously, the elided-lifetimes-in-path lint would fire, but we don't want
|
||||
// that, because `'_` isn't legal in struct declarations.
|
||||
|
||||
struct Betrayal<'a> { x: &'a u8 }
|
||||
|
||||
struct Heartbreak(Betrayal); //~ ERROR missing lifetime specifier
|
||||
|
||||
fn main() {}
|
@ -1,14 +0,0 @@
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/issue-61124-anon-lifetime-in-struct-declaration.rs:8:19
|
||||
|
|
||||
LL | struct Heartbreak(Betrayal);
|
||||
| ^^^^^^^^ expected named lifetime parameter
|
||||
|
|
||||
help: consider introducing a named lifetime parameter
|
||||
|
|
||||
LL | struct Heartbreak<'a>(Betrayal<'a>);
|
||||
| ++++ ~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
@ -1,22 +0,0 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/mismatched.rs:4:42
|
||||
|
|
||||
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y }
|
||||
| ---- ^ lifetime `'a` required
|
||||
| |
|
||||
| help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/mismatched.rs:6:46
|
||||
|
|
||||
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y }
|
||||
| -- -- ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
|
||||
| | |
|
||||
| | lifetime `'b` defined here
|
||||
| lifetime `'a` defined here
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
@ -1,8 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
|
||||
|
||||
fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
|
||||
|
||||
fn main() {}
|
@ -1,20 +0,0 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/mismatched.rs:4:42
|
||||
|
|
||||
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y }
|
||||
| ---- ^ lifetime `'a` required
|
||||
| |
|
||||
| help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/mismatched.rs:6:46
|
||||
|
|
||||
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y }
|
||||
| ------- ------- ^ ...but data from `y` is returned here
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0621, E0623.
|
||||
For more information about an error, try `rustc --explain E0621`.
|
@ -1,10 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
trait Get {
|
||||
fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
|
||||
y //~ ERROR explicit lifetime required
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,11 +0,0 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/mismatched_trait.rs:6:9
|
||||
|
|
||||
LL | fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
|
||||
| ---- help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
|
||||
LL | y
|
||||
| ^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
@ -1,14 +0,0 @@
|
||||
use std::ops::Deref;
|
||||
trait Trait {}
|
||||
|
||||
struct Struct;
|
||||
|
||||
impl Deref for Struct {
|
||||
type Target = dyn Trait;
|
||||
fn deref(&self) -> &dyn Trait {
|
||||
//~^ ERROR `impl` item signature doesn't match `trait` item signature
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,18 +0,0 @@
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
||||
|
|
||||
LL | fn deref(&self) -> &dyn Trait {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
|
||||
|
|
||||
::: $SRC_DIR/core/src/ops/deref.rs:LL:COL
|
||||
|
|
||||
LL | fn deref(&self) -> &Self::Target;
|
||||
| --------------------------------- expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
|
||||
|
|
||||
= note: expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
|
||||
found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,16 +0,0 @@
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/mismatched_trait_impl.rs:9:5
|
||||
|
|
||||
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
||||
| ---------------------------------------------- expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||
...
|
||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||
|
|
||||
= note: expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||
found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,14 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
trait Get {
|
||||
fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
||||
}
|
||||
|
||||
impl Get for i32 {
|
||||
fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR `impl` item signature doesn't match
|
||||
x //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,27 +0,0 @@
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/mismatched_trait_impl.rs:9:5
|
||||
|
|
||||
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
||||
| ---------------------------------------------- expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||
...
|
||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||
|
|
||||
= note: expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||
found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/mismatched_trait_impl.rs:10:9
|
||||
|
|
||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||
| ---- -------
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | x
|
||||
| ^ ...but data from `x` is returned here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0623`.
|
@ -1,11 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: &'a u32) -> &'a u32 { x }
|
||||
|
||||
fn main() {
|
||||
let mut p = 3;
|
||||
let r = foo(&p);
|
||||
p += 1; //~ ERROR cannot assign to `p` because it is borrowed
|
||||
println!("{}", r);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
error[E0506]: cannot assign to `p` because it is borrowed
|
||||
--> $DIR/mut_while_borrow.rs:9:5
|
||||
|
|
||||
LL | let r = foo(&p);
|
||||
| -- borrow of `p` occurs here
|
||||
LL | p += 1;
|
||||
| ^^^^^^ assignment to borrowed `p` occurs here
|
||||
LL | println!("{}", r);
|
||||
| - borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0506`.
|
@ -1,20 +0,0 @@
|
||||
// Test that the `'a` from the impl doesn't
|
||||
// prevent us from creating a `'a` parameter
|
||||
// on the `blah` function.
|
||||
//
|
||||
// check-pass
|
||||
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
struct Foo<'a> {
|
||||
x: &'a u32
|
||||
|
||||
}
|
||||
|
||||
impl Foo<'a> {
|
||||
fn method(&self) {
|
||||
fn blah(f: Foo<'a>) { }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -1,12 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
struct Foo {
|
||||
x: &'test u32, //~ ERROR undeclared lifetime
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
Baz(&'test u32), //~ ERROR undeclared lifetime
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,19 +0,0 @@
|
||||
error[E0261]: use of undeclared lifetime name `'test`
|
||||
--> $DIR/no_in_band_in_struct.rs:5:9
|
||||
|
|
||||
LL | struct Foo {
|
||||
| - help: consider introducing lifetime `'test` here: `<'test>`
|
||||
LL | x: &'test u32,
|
||||
| ^^^^^ undeclared lifetime
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'test`
|
||||
--> $DIR/no_in_band_in_struct.rs:9:10
|
||||
|
|
||||
LL | enum Bar {
|
||||
| - help: consider introducing lifetime `'test` here: `<'test>`
|
||||
LL | Baz(&'test u32),
|
||||
| ^^^^^ undeclared lifetime
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0261`.
|
@ -1,13 +0,0 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
fn foo(x: &u32) {
|
||||
let y: &'test u32 = x; //~ ERROR use of undeclared lifetime
|
||||
}
|
||||
|
||||
fn foo2(x: &u32) {}
|
||||
fn bar() {
|
||||
let y: fn(&'test u32) = foo2; //~ ERROR use of undeclared lifetime
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,27 +0,0 @@
|
||||
error[E0261]: use of undeclared lifetime name `'test`
|
||||
--> $DIR/no_introducing_in_band_in_locals.rs:5:13
|
||||
|
|
||||
LL | fn foo(x: &u32) {
|
||||
| - help: consider introducing lifetime `'test` here: `<'test>`
|
||||
LL | let y: &'test u32 = x;
|
||||
| ^^^^^ undeclared lifetime
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'test`
|
||||
--> $DIR/no_introducing_in_band_in_locals.rs:10:16
|
||||
|
|
||||
LL | let y: fn(&'test u32) = foo2;
|
||||
| ^^^^^ undeclared lifetime
|
||||
|
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
help: consider introducing lifetime `'test` here
|
||||
|
|
||||
LL | fn bar<'test>() {
|
||||
| +++++++
|
||||
help: consider making the type lifetime-generic with a new `'test` lifetime
|
||||
|
|
||||
LL | let y: for<'test> fn(&'test u32) = foo2;
|
||||
| ++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0261`.
|
@ -1,5 +1,4 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![allow(unused)]
|
||||
|
||||
trait Trait<'a> {
|
||||
type Foo;
|
@ -1,5 +1,5 @@
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/missing-lifetime-in-alias.rs:23:24
|
||||
--> $DIR/missing-lifetime-in-alias.rs:22:24
|
||||
|
|
||||
LL | type B<'a> = <A<'a> as Trait>::Foo;
|
||||
| ^^^^^ expected named lifetime parameter
|
||||
@ -10,25 +10,25 @@ LL | type B<'a> = <A<'a> as Trait<'a>>::Foo;
|
||||
| ~~~~~~~~~
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/missing-lifetime-in-alias.rs:27:28
|
||||
--> $DIR/missing-lifetime-in-alias.rs:26:28
|
||||
|
|
||||
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
|
||||
| ^^^^^ expected named lifetime parameter
|
||||
|
|
||||
note: these named lifetimes are available to use
|
||||
--> $DIR/missing-lifetime-in-alias.rs:27:8
|
||||
--> $DIR/missing-lifetime-in-alias.rs:26:8
|
||||
|
|
||||
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
|
||||
| ^^ ^^
|
||||
|
||||
error[E0107]: missing generics for associated type `Trait::Bar`
|
||||
--> $DIR/missing-lifetime-in-alias.rs:27:36
|
||||
--> $DIR/missing-lifetime-in-alias.rs:26:36
|
||||
|
|
||||
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
|
||||
| ^^^ expected 1 lifetime argument
|
||||
|
|
||||
note: associated type defined here, with 1 lifetime parameter: `'b`
|
||||
--> $DIR/missing-lifetime-in-alias.rs:7:10
|
||||
--> $DIR/missing-lifetime-in-alias.rs:6:10
|
||||
|
|
||||
LL | type Bar<'b>
|
||||
| ^^^ --
|
7
src/test/ui/lifetimes/nested.rs
Normal file
7
src/test/ui/lifetimes/nested.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// check-pass
|
||||
|
||||
fn method<'a>(_i: &'a i32) {
|
||||
fn inner<'a>(_j: &'a f32) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,9 +1,6 @@
|
||||
#![allow(warnings)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl Foo<&'s u8> {
|
||||
impl<'s> Foo<&'s u8> {
|
||||
fn bar<'s>(&self, x: &'s u8) {} //~ ERROR shadows a lifetime name
|
||||
fn baz(x: for<'s> fn(&'s u32)) {} //~ ERROR shadows a lifetime name
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
error[E0496]: lifetime name `'s` shadows a lifetime name that is already in scope
|
||||
--> $DIR/shadow.rs:7:12
|
||||
--> $DIR/shadow.rs:4:12
|
||||
|
|
||||
LL | impl Foo<&'s u8> {
|
||||
| -- first declared here
|
||||
LL | impl<'s> Foo<&'s u8> {
|
||||
| -- first declared here
|
||||
LL | fn bar<'s>(&self, x: &'s u8) {}
|
||||
| ^^ lifetime `'s` already in scope
|
||||
|
||||
error[E0496]: lifetime name `'s` shadows a lifetime name that is already in scope
|
||||
--> $DIR/shadow.rs:8:19
|
||||
--> $DIR/shadow.rs:5:19
|
||||
|
|
||||
LL | impl Foo<&'s u8> {
|
||||
| -- first declared here
|
||||
LL | impl<'s> Foo<&'s u8> {
|
||||
| -- first declared here
|
||||
LL | fn bar<'s>(&self, x: &'s u8) {}
|
||||
LL | fn baz(x: for<'s> fn(&'s u32)) {}
|
||||
| ^^ lifetime `'s` already in scope
|
@ -5,8 +5,6 @@ LL | struct Test {
|
||||
| - help: consider introducing lifetime `'b` here: `<'b>`
|
||||
LL | a: &'b str,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9
|
||||
@ -15,8 +13,6 @@ LL | struct Test {
|
||||
| - help: consider introducing lifetime `'b` here: `<'b>`
|
||||
LL | a: &'b str,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:13:13
|
||||
@ -24,7 +20,6 @@ error[E0261]: use of undeclared lifetime name `'b`
|
||||
LL | fn foo(&'b self) {}
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b> T for Test {
|
||||
|
@ -115,18 +115,18 @@ mod cross_crate {
|
||||
let _ = UnstableStruct { i: 0 };
|
||||
let _ = StableStruct { i: 0 };
|
||||
|
||||
let _ = DeprecatedUnitStruct; //~ WARN use of deprecated struct `lint_stability::DeprecatedUnitStruct`
|
||||
let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated struct `lint_stability::DeprecatedUnstableUnitStruct`
|
||||
let _ = DeprecatedUnitStruct; //~ WARN use of deprecated unit struct `lint_stability::DeprecatedUnitStruct`
|
||||
let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated unit struct `lint_stability::DeprecatedUnstableUnitStruct`
|
||||
let _ = UnstableUnitStruct;
|
||||
let _ = StableUnitStruct;
|
||||
|
||||
let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated variant `lint_stability::Enum::DeprecatedVariant`
|
||||
let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated variant `lint_stability::Enum::DeprecatedUnstableVariant`
|
||||
let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated unit variant `lint_stability::Enum::DeprecatedVariant`
|
||||
let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated unit variant `lint_stability::Enum::DeprecatedUnstableVariant`
|
||||
let _ = Enum::UnstableVariant;
|
||||
let _ = Enum::StableVariant;
|
||||
|
||||
let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated struct `lint_stability::DeprecatedTupleStruct`
|
||||
let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated struct `lint_stability::DeprecatedUnstableTupleStruct`
|
||||
let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated tuple struct `lint_stability::DeprecatedTupleStruct`
|
||||
let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated tuple struct `lint_stability::DeprecatedUnstableTupleStruct`
|
||||
let _ = UnstableTupleStruct (1);
|
||||
let _ = StableTupleStruct (1);
|
||||
|
||||
|
@ -88,37 +88,37 @@ warning: use of deprecated struct `lint_stability::DeprecatedUnstableStruct`: te
|
||||
LL | let _ = DeprecatedUnstableStruct {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated struct `lint_stability::DeprecatedUnitStruct`: text
|
||||
warning: use of deprecated unit struct `lint_stability::DeprecatedUnitStruct`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:118:17
|
||||
|
|
||||
LL | let _ = DeprecatedUnitStruct;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated struct `lint_stability::DeprecatedUnstableUnitStruct`: text
|
||||
warning: use of deprecated unit struct `lint_stability::DeprecatedUnstableUnitStruct`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:119:17
|
||||
|
|
||||
LL | let _ = DeprecatedUnstableUnitStruct;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated variant `lint_stability::Enum::DeprecatedVariant`: text
|
||||
warning: use of deprecated unit variant `lint_stability::Enum::DeprecatedVariant`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:123:23
|
||||
|
|
||||
LL | let _ = Enum::DeprecatedVariant;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated variant `lint_stability::Enum::DeprecatedUnstableVariant`: text
|
||||
warning: use of deprecated unit variant `lint_stability::Enum::DeprecatedUnstableVariant`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:124:23
|
||||
|
|
||||
LL | let _ = Enum::DeprecatedUnstableVariant;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated struct `lint_stability::DeprecatedTupleStruct`: text
|
||||
warning: use of deprecated tuple struct `lint_stability::DeprecatedTupleStruct`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:128:17
|
||||
|
|
||||
LL | let _ = DeprecatedTupleStruct (1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated struct `lint_stability::DeprecatedUnstableTupleStruct`: text
|
||||
warning: use of deprecated tuple struct `lint_stability::DeprecatedUnstableTupleStruct`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:129:17
|
||||
|
|
||||
LL | let _ = DeprecatedUnstableTupleStruct (1);
|
||||
|
@ -129,7 +129,7 @@ mod cross_crate {
|
||||
{ .. } = x;
|
||||
|
||||
let x = Deprecated2(1, 2, 3);
|
||||
//~^ ERROR use of deprecated struct
|
||||
//~^ ERROR use of deprecated tuple struct
|
||||
|
||||
let _ = x.0;
|
||||
//~^ ERROR use of deprecated field
|
||||
@ -139,7 +139,7 @@ mod cross_crate {
|
||||
//~^ ERROR use of deprecated field
|
||||
|
||||
let Deprecated2
|
||||
//~^ ERROR use of deprecated struct
|
||||
//~^ ERROR use of deprecated tuple struct
|
||||
(_,
|
||||
//~^ ERROR use of deprecated field
|
||||
_,
|
||||
@ -148,7 +148,7 @@ mod cross_crate {
|
||||
//~^ ERROR use of deprecated field
|
||||
= x;
|
||||
let Deprecated2
|
||||
//~^ ERROR use of deprecated struct
|
||||
//~^ ERROR use of deprecated tuple struct
|
||||
// the patterns are all fine:
|
||||
(..) = x;
|
||||
}
|
||||
|
@ -22,19 +22,19 @@ error: use of deprecated struct `cross_crate::lint_stability_fields::Deprecated`
|
||||
LL | let Deprecated
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
--> $DIR/lint-stability-fields-deprecated.rs:131:17
|
||||
|
|
||||
LL | let x = Deprecated2(1, 2, 3);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
--> $DIR/lint-stability-fields-deprecated.rs:141:13
|
||||
|
|
||||
LL | let Deprecated2
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: use of deprecated struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
error: use of deprecated tuple struct `cross_crate::lint_stability_fields::Deprecated2`: text
|
||||
--> $DIR/lint-stability-fields-deprecated.rs:150:13
|
||||
|
|
||||
LL | let Deprecated2
|
||||
|
@ -5,8 +5,6 @@ LL | fn main() {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | 0.clone::<'a>();
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-52742.rs:14:9
|
||||
--> $DIR/issue-52742.rs:12:9
|
||||
|
|
||||
LL | fn take_bar(&mut self, b: Bar<'_>) {
|
||||
| --------- -- let's call this `'1`
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
||||
struct Foo<'a, 'b> {
|
||||
x: &'a u32,
|
||||
y: &'b u32,
|
||||
|
@ -1,16 +1,16 @@
|
||||
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
|
||||
--> $DIR/issue-52742.rs:14:18
|
||||
--> $DIR/issue-52742.rs:12:18
|
||||
|
|
||||
LL | self.y = b.z
|
||||
| ^^^
|
||||
|
|
||||
note: ...the reference is valid for the lifetime `'_` as defined here...
|
||||
--> $DIR/issue-52742.rs:12:10
|
||||
--> $DIR/issue-52742.rs:10:10
|
||||
|
|
||||
LL | impl Foo<'_, '_> {
|
||||
| ^^
|
||||
note: ...but the borrowed content is only valid for the anonymous lifetime defined here
|
||||
--> $DIR/issue-52742.rs:13:31
|
||||
--> $DIR/issue-52742.rs:11:31
|
||||
|
|
||||
LL | fn take_bar(&mut self, b: Bar<'_>) {
|
||||
| ^^^^^^^
|
||||
|
@ -37,4 +37,31 @@ fn qux() -> u32 {
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn space_cadet() -> bool {
|
||||
({ true }) | { true } //~ ERROR E0308
|
||||
//~^ ERROR expected parameter name
|
||||
}
|
||||
|
||||
fn revenge_from_mars() -> bool {
|
||||
({ true }) && { true } //~ ERROR E0308
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn attack_from_mars() -> bool {
|
||||
({ true }) || { true } //~ ERROR E0308
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
// This gets corrected by adding a semicolon, instead of parens.
|
||||
// It's placed here to help keep track of the way this diagnostic
|
||||
// needs to interact with type checking to avoid MachineApplicable
|
||||
// suggestions that actually break stuff.
|
||||
//
|
||||
// If you're wondering what happens if that `foo()` is a `true` like
|
||||
// all the ones above use? Nothing. It makes neither suggestion in
|
||||
// that case.
|
||||
fn asteroids() -> impl FnOnce() -> bool {
|
||||
{ foo(); } || { true } //~ ERROR E0308
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -37,4 +37,31 @@ fn qux() -> u32 {
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn space_cadet() -> bool {
|
||||
{ true } | { true } //~ ERROR E0308
|
||||
//~^ ERROR expected parameter name
|
||||
}
|
||||
|
||||
fn revenge_from_mars() -> bool {
|
||||
{ true } && { true } //~ ERROR E0308
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn attack_from_mars() -> bool {
|
||||
{ true } || { true } //~ ERROR E0308
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
// This gets corrected by adding a semicolon, instead of parens.
|
||||
// It's placed here to help keep track of the way this diagnostic
|
||||
// needs to interact with type checking to avoid MachineApplicable
|
||||
// suggestions that actually break stuff.
|
||||
//
|
||||
// If you're wondering what happens if that `foo()` is a `true` like
|
||||
// all the ones above use? Nothing. It makes neither suggestion in
|
||||
// that case.
|
||||
fn asteroids() -> impl FnOnce() -> bool {
|
||||
{ foo() } || { true } //~ ERROR E0308
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -44,6 +44,25 @@ LL | _ => 1,
|
||||
LL ~ }) > 0
|
||||
|
|
||||
|
||||
error: expected parameter name, found `{`
|
||||
--> $DIR/expr-as-stmt.rs:41:16
|
||||
|
|
||||
LL | { true } | { true }
|
||||
| ^ expected parameter name
|
||||
|
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
LL | ({ true }) | { true }
|
||||
| + +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:64:7
|
||||
|
|
||||
LL | { foo() } || { true }
|
||||
| ^^^^^- help: consider using a semicolon here: `;`
|
||||
| |
|
||||
| expected `()`, found `i32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:8:6
|
||||
|
|
||||
@ -121,7 +140,68 @@ help: parentheses are required to parse this as an expression
|
||||
LL | ({2}) - 2
|
||||
| + +
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:41:7
|
||||
|
|
||||
LL | { true } | { true }
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
|
||||
help: you might have meant to return this value
|
||||
|
|
||||
LL | { return true; } | { true }
|
||||
| ++++++ +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:46:7
|
||||
|
|
||||
LL | { true } && { true }
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
|
||||
help: you might have meant to return this value
|
||||
|
|
||||
LL | { return true; } && { true }
|
||||
| ++++++ +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:46:14
|
||||
|
|
||||
LL | fn revenge_from_mars() -> bool {
|
||||
| ---- expected `bool` because of return type
|
||||
LL | { true } && { true }
|
||||
| ^^^^^^^^^^^ expected `bool`, found `&&bool`
|
||||
|
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
LL | ({ true }) && { true }
|
||||
| + +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:51:7
|
||||
|
|
||||
LL | { true } || { true }
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
|
||||
help: you might have meant to return this value
|
||||
|
|
||||
LL | { return true; } || { true }
|
||||
| ++++++ +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expr-as-stmt.rs:51:14
|
||||
|
|
||||
LL | fn attack_from_mars() -> bool {
|
||||
| ---- expected `bool` because of return type
|
||||
LL | { true } || { true }
|
||||
| ^^^^^^^^^^^ expected `bool`, found closure
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:25]`
|
||||
help: parentheses are required to parse this as an expression
|
||||
|
|
||||
LL | ({ true }) || { true }
|
||||
| + +
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0600, E0614.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
@ -5,8 +5,6 @@ LL | enum No0 {
|
||||
| - help: consider introducing lifetime `'foo` here: `<'foo>`
|
||||
LL | X5(&'foo usize)
|
||||
| ^^^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-in-enums.rs:17:9
|
||||
@ -15,8 +13,6 @@ LL | enum No1 {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | X6(&'a usize)
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,8 +5,6 @@ LL | struct StructDecl {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | a: &'a isize,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-in-structs.rs:11:9
|
||||
@ -16,8 +14,6 @@ LL | struct StructDecl {
|
||||
LL | a: &'a isize,
|
||||
LL | b: &'a isize,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -5,8 +5,6 @@ LL | enum E {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | E1(&'a isize)
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-name-undeclared.rs:31:13
|
||||
@ -15,8 +13,6 @@ LL | struct S {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | f: &'a isize
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/regions-name-undeclared.rs:16:24
|
||||
@ -24,7 +20,6 @@ error[E0261]: use of undeclared lifetime name `'b`
|
||||
LL | fn m4(&self, arg: &'b isize) { }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b, 'a> Foo<'a> {
|
||||
@ -40,7 +35,6 @@ error[E0261]: use of undeclared lifetime name `'b`
|
||||
LL | fn m5(&'b self) { }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b, 'a> Foo<'a> {
|
||||
@ -56,7 +50,6 @@ error[E0261]: use of undeclared lifetime name `'b`
|
||||
LL | fn m6(&self, arg: Foo<'b>) { }
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | impl<'b, 'a> Foo<'a> {
|
||||
@ -73,8 +66,6 @@ LL | type X = Option<&'a isize>;
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-name-undeclared.rs:33:14
|
||||
@ -83,8 +74,6 @@ LL | fn f(a: &'a isize) { }
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-name-undeclared.rs:41:17
|
||||
@ -93,8 +82,6 @@ LL | fn fn_types(a: &'a isize,
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/regions-name-undeclared.rs:43:36
|
||||
@ -103,7 +90,6 @@ LL | ... &'b isize,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn fn_types<'b>(a: &'a isize,
|
||||
@ -120,7 +106,6 @@ LL | ... &'b isize)>,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'b` here
|
||||
|
|
||||
LL | fn fn_types<'b>(a: &'a isize,
|
||||
@ -138,8 +123,6 @@ LL | fn fn_types(a: &'a isize,
|
||||
...
|
||||
LL | c: &'a isize)
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-name-undeclared.rs:53:31
|
||||
@ -147,7 +130,6 @@ error[E0261]: use of undeclared lifetime name `'a`
|
||||
LL | async fn buggy(&self) -> &'a str {
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
help: consider introducing lifetime `'a` here
|
||||
|
|
||||
LL | impl<'a> Bug {
|
||||
|
@ -11,8 +11,6 @@ LL | enum EnumDecl {
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | Foo(&'a isize),
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-undeclared.rs:5:10
|
||||
@ -22,8 +20,6 @@ LL | enum EnumDecl {
|
||||
LL | Foo(&'a isize),
|
||||
LL | Bar(&'a isize),
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-undeclared.rs:8:15
|
||||
@ -32,8 +28,6 @@ LL | fn fnDecl(x: &'a isize,
|
||||
| - ^^ undeclared lifetime
|
||||
| |
|
||||
| help: consider introducing lifetime `'a` here: `<'a>`
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'a`
|
||||
--> $DIR/regions-undeclared.rs:9:15
|
||||
@ -42,8 +36,6 @@ LL | fn fnDecl(x: &'a isize,
|
||||
| - help: consider introducing lifetime `'a` here: `<'a>`
|
||||
LL | y: &'a isize)
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![deny(single_use_lifetimes)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
// Test that we DO warn when lifetime name is used only
|
||||
// once in a fn argument, even with in band lifetimes.
|
||||
|
||||
fn a(x: &u32, y: &u32) {
|
||||
//~^ ERROR `'a` only used once
|
||||
//~| ERROR `'b` only used once
|
||||
//~| HELP elide the single-use lifetime
|
||||
//~| HELP elide the single-use lifetime
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -1,18 +0,0 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![deny(single_use_lifetimes)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
// Test that we DO warn when lifetime name is used only
|
||||
// once in a fn argument, even with in band lifetimes.
|
||||
|
||||
fn a(x: &'a u32, y: &'b u32) {
|
||||
//~^ ERROR `'a` only used once
|
||||
//~| ERROR `'b` only used once
|
||||
//~| HELP elide the single-use lifetime
|
||||
//~| HELP elide the single-use lifetime
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -1,26 +0,0 @@
|
||||
error: lifetime parameter `'a` only used once
|
||||
--> $DIR/one-use-in-fn-argument-in-band.rs:11:10
|
||||
|
|
||||
LL | fn a(x: &'a u32, y: &'b u32) {
|
||||
| ^^-
|
||||
| |
|
||||
| this lifetime is only used here
|
||||
| help: elide the single-use lifetime
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/one-use-in-fn-argument-in-band.rs:4:9
|
||||
|
|
||||
LL | #![deny(single_use_lifetimes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lifetime parameter `'b` only used once
|
||||
--> $DIR/one-use-in-fn-argument-in-band.rs:11:22
|
||||
|
|
||||
LL | fn a(x: &'a u32, y: &'b u32) {
|
||||
| ^^-
|
||||
| |
|
||||
| this lifetime is only used here
|
||||
| help: elide the single-use lifetime
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -217,25 +217,25 @@ fn main() {
|
||||
|
||||
let _ = ENUM4;
|
||||
let _: Enum4<isize> = Enum4::Some(1);
|
||||
//~^ use of deprecated variant `unstable_generic_param::Enum4::Some`: test [deprecated]
|
||||
//~^ use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test [deprecated]
|
||||
//~^^ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated]
|
||||
let _ = ENUM4;
|
||||
let _: Enum4 = ENUM4; //~ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated]
|
||||
let _: Enum4<usize> = ENUM4; //~ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated]
|
||||
let _: Enum4<isize> = Enum4::Some(0);
|
||||
//~^ use of deprecated variant `unstable_generic_param::Enum4::Some`: test [deprecated]
|
||||
//~^ use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test [deprecated]
|
||||
//~^^ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated]
|
||||
|
||||
let _ = ENUM5;
|
||||
let _: Enum5<isize> = Enum5::Some(1); //~ ERROR use of unstable library feature 'unstable_default'
|
||||
//~^ use of deprecated variant `unstable_generic_param::Enum5::Some`: test [deprecated]
|
||||
//~^ use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test [deprecated]
|
||||
//~^^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated]
|
||||
let _ = ENUM5;
|
||||
let _: Enum5 = ENUM5; //~ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated]
|
||||
let _: Enum5<usize> = ENUM5; //~ ERROR use of unstable library feature 'unstable_default'
|
||||
//~^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated]
|
||||
let _: Enum5<isize> = Enum5::Some(0); //~ ERROR use of unstable library feature 'unstable_default'
|
||||
//~^ use of deprecated variant `unstable_generic_param::Enum5::Some`: test [deprecated]
|
||||
//~^ use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test [deprecated]
|
||||
//~^^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated]
|
||||
|
||||
let _: Enum6<isize> = Enum6::Some(1); // ok
|
||||
|
@ -144,7 +144,7 @@ warning: use of deprecated type alias `unstable_generic_param::Alias5`: test
|
||||
LL | let _: Alias5<isize> = Alias5::Some(0);
|
||||
| ^^^^^^
|
||||
|
||||
warning: use of deprecated variant `unstable_generic_param::Enum4::Some`: test
|
||||
warning: use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test
|
||||
--> $DIR/generics-default-stability.rs:219:34
|
||||
|
|
||||
LL | let _: Enum4<isize> = Enum4::Some(1);
|
||||
@ -168,7 +168,7 @@ warning: use of deprecated enum `unstable_generic_param::Enum4`: test
|
||||
LL | let _: Enum4<usize> = ENUM4;
|
||||
| ^^^^^
|
||||
|
||||
warning: use of deprecated variant `unstable_generic_param::Enum4::Some`: test
|
||||
warning: use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test
|
||||
--> $DIR/generics-default-stability.rs:225:34
|
||||
|
|
||||
LL | let _: Enum4<isize> = Enum4::Some(0);
|
||||
@ -180,7 +180,7 @@ warning: use of deprecated enum `unstable_generic_param::Enum4`: test
|
||||
LL | let _: Enum4<isize> = Enum4::Some(0);
|
||||
| ^^^^^
|
||||
|
||||
warning: use of deprecated variant `unstable_generic_param::Enum5::Some`: test
|
||||
warning: use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test
|
||||
--> $DIR/generics-default-stability.rs:230:34
|
||||
|
|
||||
LL | let _: Enum5<isize> = Enum5::Some(1);
|
||||
@ -204,7 +204,7 @@ warning: use of deprecated enum `unstable_generic_param::Enum5`: test
|
||||
LL | let _: Enum5<usize> = ENUM5;
|
||||
| ^^^^^
|
||||
|
||||
warning: use of deprecated variant `unstable_generic_param::Enum5::Some`: test
|
||||
warning: use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test
|
||||
--> $DIR/generics-default-stability.rs:237:34
|
||||
|
|
||||
LL | let _: Enum5<isize> = Enum5::Some(0);
|
||||
|
@ -6,8 +6,6 @@ LL | fn f() where
|
||||
LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK
|
||||
LL | (dyn for<'a> Trait1<'a>): Trait1<'a>,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error[E0261]: use of undeclared lifetime name `'b`
|
||||
--> $DIR/where-lifetime-resolution.rs:8:52
|
||||
@ -17,8 +15,6 @@ LL | fn f() where
|
||||
...
|
||||
LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
|
||||
| ^^ undeclared lifetime
|
||||
|
|
||||
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user