1
Fork 0

Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #88025 (ScmCredentials netbsd implementation.)
 - #95473 (track individual proc-macro expansions in the self-profiler)
 - #95547 (caution against ptr-to-int transmutes)
 - #95585 (Explain why `&T` is cloned when `T` is not `Clone`)
 - #95591 (Use revisions to track NLL test output (part 1))
 - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut)
 - #95673 (⬆️ rust-analyzer)
 - #95681 (resolve: Fix resolution of empty paths passed from rustdoc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-04-05 22:42:04 +00:00
commit bbe9d27b8f
132 changed files with 955 additions and 447 deletions

View file

@ -1047,6 +1047,12 @@ impl<'a> ExtCtxt<'a> {
self.current_expansion.id.expn_data().call_site
}
/// Returns the current expansion kind's description.
pub(crate) fn expansion_descr(&self) -> String {
let expn_data = self.current_expansion.id.expn_data();
expn_data.kind.descr()
}
/// Equivalent of `Span::def_site` from the proc macro API,
/// except that the location is taken from the span passed as an argument.
pub fn with_def_site_ctxt(&self, span: Span) -> Span {

View file

@ -24,6 +24,8 @@ impl base::ProcMacro for BangProcMacro {
span: Span,
input: TokenStream,
) -> Result<TokenStream, ErrorGuaranteed> {
let _timer =
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx);
self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace).map_err(|e| {
@ -48,6 +50,8 @@ impl base::AttrProcMacro for AttrProcMacro {
annotation: TokenStream,
annotated: TokenStream,
) -> Result<TokenStream, ErrorGuaranteed> {
let _timer =
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx);
self.client
@ -97,17 +101,21 @@ impl MultiItemModifier for ProcMacroDerive {
nt_to_tokenstream(&item, &ecx.sess.parse_sess, CanSynthesizeMissingTokens::No)
};
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx);
let stream = match self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace) {
Ok(stream) => stream,
Err(e) => {
let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
let stream = {
let _timer =
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx);
match self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace) {
Ok(stream) => stream,
Err(e) => {
let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
if let Some(s) = e.as_str() {
err.help(&format!("message: {}", s));
}
err.emit();
return ExpandResult::Ready(vec![]);
}
err.emit();
return ExpandResult::Ready(vec![]);
}
};

View file

@ -3298,7 +3298,9 @@ impl<'a> Resolver<'a> {
PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
Some(path_res.base_res())
}
PathResult::NonModule(..) | PathResult::Failed { .. } => None,
PathResult::Module(ModuleOrUniformRoot::ExternPrelude)
| PathResult::NonModule(..)
| PathResult::Failed { .. } => None,
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
}
}

View file

@ -208,6 +208,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
flags.push((sym::_Self, Some("&[]".to_owned())));
}
if self_ty.is_fn() {
let fn_sig = self_ty.fn_sig(self.tcx);
let shortname = match fn_sig.unsafety() {
hir::Unsafety::Normal => "fn",
hir::Unsafety::Unsafe => "unsafe fn",
};
flags.push((sym::_Self, Some(shortname.to_owned())));
}
if let ty::Array(aty, len) = self_ty.kind() {
flags.push((sym::_Self, Some("[]".to_owned())));
flags.push((sym::_Self, Some(format!("[{}]", aty))));

View file

@ -40,6 +40,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.suggest_boxing_when_appropriate(err, expr, expected, expr_ty);
self.suggest_missing_parentheses(err, expr);
self.suggest_block_to_brackets_peeling_refs(err, expr, expr_ty, expected);
self.note_type_is_not_clone(err, expected, expr_ty, expr);
self.note_need_for_fn_pointer(err, expected, expr_ty);
self.note_internal_mutation_in_method(err, expr, expected, expr_ty);
self.report_closure_inferred_return_type(err, expected);
@ -630,7 +631,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MachineApplicable,
true,
));
}
}
_ => {}

View file

@ -2,8 +2,6 @@ use super::FnCtxt;
use crate::astconv::AstConv;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_span::{self, Span};
use rustc_errors::{Applicability, Diagnostic, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind};
@ -13,12 +11,14 @@ use rustc_hir::{
WherePredicate,
};
use rustc_infer::infer::{self, TyCtxtInferExt};
use rustc_infer::traits;
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::{self, Binder, Ty};
use rustc_span::symbol::{kw, sym};
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Binder, ToPredicate, Ty};
use rustc_span::symbol::{kw, sym};
use rustc_span::Span;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use std::iter;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@ -846,4 +846,53 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let node = self.tcx.hir().get(id);
matches!(node, Node::Stmt(Stmt { kind: StmtKind::Local(..), .. }))
}
/// Suggest that `&T` was cloned instead of `T` because `T` does not implement `Clone`,
/// which is a side-effect of autoref.
pub(crate) fn note_type_is_not_clone(
&self,
diag: &mut Diagnostic,
expected_ty: Ty<'tcx>,
found_ty: Ty<'tcx>,
expr: &hir::Expr<'_>,
) {
let hir::ExprKind::MethodCall(segment, &[ref callee_expr], _) = expr.kind else { return; };
let Some(clone_trait_did) = self.tcx.lang_items().clone_trait() else { return; };
let ty::Ref(_, pointee_ty, _) = found_ty.kind() else { return };
let results = self.typeck_results.borrow();
// First, look for a `Clone::clone` call
if segment.ident.name == sym::clone
&& results.type_dependent_def_id(expr.hir_id).map_or(
false,
|did| {
self.tcx.associated_item(did).container
== ty::AssocItemContainer::TraitContainer(clone_trait_did)
},
)
// If that clone call hasn't already dereferenced the self type (i.e. don't give this
// diagnostic in cases where we have `(&&T).clone()` and we expect `T`).
&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..)))
// Check that we're in fact trying to clone into the expected type
&& self.can_coerce(*pointee_ty, expected_ty)
// And the expected type doesn't implement `Clone`
&& !self.predicate_must_hold_considering_regions(&traits::Obligation {
cause: traits::ObligationCause::dummy(),
param_env: self.param_env,
recursion_depth: 0,
predicate: ty::Binder::dummy(ty::TraitRef {
def_id: clone_trait_did,
substs: self.tcx.mk_substs([expected_ty.into()].iter()),
})
.without_const()
.to_predicate(self.tcx),
})
{
diag.span_note(
callee_expr.span,
&format!(
"`{expected_ty}` does not implement `Clone`, so `{found_ty}` was cloned instead"
),
);
}
}
}

View file

@ -991,6 +991,16 @@ extern "rust-intrinsic" {
/// let ptr_num_cast = ptr as *const i32 as usize;
/// ```
///
/// Note that using `transmute` to turn a pointer to a `usize` is (as noted above) [undefined
/// behavior][ub] in `const` contexts. Also outside of consts, this operation might not behave
/// as expected -- this is touching on many unspecified aspects of the Rust memory model.
/// Depending on what the code is doing, the following alternatives are preferrable to
/// pointer-to-integer transmutation:
/// - If the code just wants to store data of arbitrary type in some buffer and needs to pick a
/// type for that buffer, it can use [`MaybeUninit`][mem::MaybeUninit].
/// - If the code actually wants to work on the address the pointer points to, it can use `as`
/// casts or [`ptr.addr()`][pointer::addr].
///
/// Turning a `*mut T` into an `&mut T`:
///
/// ```

View file

@ -60,6 +60,12 @@
Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
),
on(
_Self = "unsafe fn",
note = "unsafe function cannot be called generically without an unsafe block",
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
),
message = "expected a `{Fn}<{Args}>` closure, found `{Self}`",
label = "expected an `Fn<{Args}>` closure, found `{Self}`"
)]
@ -141,6 +147,12 @@ pub trait Fn<Args>: FnMut<Args> {
Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
),
on(
_Self = "unsafe fn",
note = "unsafe function cannot be called generically without an unsafe block",
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
),
message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`",
label = "expected an `FnMut<{Args}>` closure, found `{Self}`"
)]
@ -214,6 +226,12 @@ pub trait FnMut<Args>: FnOnce<Args> {
Args = "()",
note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
),
on(
_Self = "unsafe fn",
note = "unsafe function cannot be called generically without an unsafe block",
// SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
),
message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`",
label = "expected an `FnOnce<{Args}>` closure, found `{Self}`"
)]

View file

@ -10,7 +10,7 @@ use crate::slice::from_raw_parts;
use crate::sys::net::Socket;
// FIXME(#43348): Make libc adapt #[doc(cfg(...))] so we don't need these fake definitions here?
#[cfg(all(doc, not(target_os = "linux"), not(target_os = "android")))]
#[cfg(all(doc, not(target_os = "linux"), not(target_os = "android"), not(target_os = "netbsd")))]
#[allow(non_camel_case_types)]
mod libc {
pub use libc::c_int;
@ -177,13 +177,24 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
}
}
#[cfg(all(doc, not(target_os = "android"), not(target_os = "linux"), not(target_os = "netbsd")))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
#[derive(Clone)]
pub struct SocketCred(());
/// Unix credential.
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(target_os = "android", target_os = "linux",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
#[derive(Clone)]
pub struct SocketCred(libc::ucred);
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(target_os = "netbsd")]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
#[derive(Clone)]
pub struct SocketCred(libc::sockcred);
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
#[cfg(any(target_os = "android", target_os = "linux"))]
impl SocketCred {
/// Create a Unix credential struct.
///
@ -234,6 +245,61 @@ impl SocketCred {
}
}
#[cfg(target_os = "netbsd")]
impl SocketCred {
/// Create a Unix credential struct.
///
/// PID, UID and GID is set to 0.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn new() -> SocketCred {
SocketCred(libc::sockcred {
sc_pid: 0,
sc_uid: 0,
sc_euid: 0,
sc_gid: 0,
sc_egid: 0,
sc_ngroups: 0,
sc_groups: [0u32; 1],
})
}
/// Set the PID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn set_pid(&mut self, pid: libc::pid_t) {
self.0.sc_pid = pid;
}
/// Get the current PID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn get_pid(&self) -> libc::pid_t {
self.0.sc_pid
}
/// Set the UID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn set_uid(&mut self, uid: libc::uid_t) {
self.0.sc_uid = uid;
}
/// Get the current UID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn get_uid(&self) -> libc::uid_t {
self.0.sc_uid
}
/// Set the GID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn set_gid(&mut self, gid: libc::gid_t) {
self.0.sc_gid = gid;
}
/// Get the current GID.
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn get_gid(&self) -> libc::gid_t {
self.0.sc_gid
}
}
/// This control message contains file descriptors.
///
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
@ -249,14 +315,22 @@ impl<'a> Iterator for ScmRights<'a> {
}
}
#[cfg(all(doc, not(target_os = "android"), not(target_os = "linux"), not(target_os = "netbsd")))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, ()>);
/// This control message contains unix credentials.
///
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_CREDENTIALS` or `SCM_CREDS`.
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(target_os = "android", target_os = "linux",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(target_os = "netbsd")]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::sockcred>);
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
impl<'a> Iterator for ScmCredentials<'a> {
type Item = SocketCred;
@ -278,7 +352,7 @@ pub enum AncillaryError {
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub enum AncillaryData<'a> {
ScmRights(ScmRights<'a>),
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
ScmCredentials(ScmCredentials<'a>),
}
@ -300,8 +374,8 @@ impl<'a> AncillaryData<'a> {
/// # Safety
///
/// `data` must contain a valid control message and the control message must be type of
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDENTIALS`.
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
/// `SOL_SOCKET` and level of `SCM_CREDENTIALS` or `SCM_CREDS`.
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
unsafe fn as_credentials(data: &'a [u8]) -> Self {
let ancillary_data_iter = AncillaryDataIter::new(data);
let scm_credentials = ScmCredentials(ancillary_data_iter);
@ -320,6 +394,8 @@ impl<'a> AncillaryData<'a> {
libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
#[cfg(any(target_os = "android", target_os = "linux",))]
libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
#[cfg(target_os = "netbsd")]
libc::SCM_CREDS => Ok(AncillaryData::as_credentials(data)),
cmsg_type => {
Err(AncillaryError::Unknown { cmsg_level: libc::SOL_SOCKET, cmsg_type })
}
@ -531,7 +607,7 @@ impl<'a> SocketAncillary<'a> {
/// Technically, that means this operation adds a control message with the level `SOL_SOCKET`
/// and type `SCM_CREDENTIALS` or `SCM_CREDS`.
///
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool {
self.truncated = false;
@ -540,7 +616,10 @@ impl<'a> SocketAncillary<'a> {
&mut self.length,
creds,
libc::SOL_SOCKET,
#[cfg(not(target_os = "netbsd"))]
libc::SCM_CREDENTIALS,
#[cfg(target_os = "netbsd")]
libc::SCM_CREDS,
)
}

View file

@ -865,7 +865,7 @@ impl UnixDatagram {
/// Ok(())
/// }
/// ```
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
self.0.set_passcred(passcred)
@ -877,7 +877,7 @@ impl UnixDatagram {
/// Get the socket option `SO_PASSCRED`.
///
/// [`set_passcred`]: UnixDatagram::set_passcred
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn passcred(&self) -> io::Result<bool> {
self.0.passcred()

View file

@ -415,7 +415,7 @@ impl UnixStream {
/// Ok(())
/// }
/// ```
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
self.0.set_passcred(passcred)
@ -427,7 +427,7 @@ impl UnixStream {
/// Get the socket option `SO_PASSCRED`.
///
/// [`set_passcred`]: UnixStream::set_passcred
#[cfg(any(doc, target_os = "android", target_os = "linux",))]
#[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "netbsd",))]
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn passcred(&self) -> io::Result<bool> {
self.0.passcred()

View file

@ -419,6 +419,17 @@ impl Socket {
Ok(passcred != 0)
}
#[cfg(target_os = "netbsd")]
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
setsockopt(self, 0 as libc::c_int, libc::LOCAL_CREDS, passcred as libc::c_int)
}
#[cfg(target_os = "netbsd")]
pub fn passcred(&self) -> io::Result<bool> {
let passcred: libc::c_int = getsockopt(self, 0 as libc::c_int, libc::LOCAL_CREDS)?;
Ok(passcred != 0)
}
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
let mut nonblocking = nonblocking as libc::c_int;

View file

@ -0,0 +1,8 @@
// Doc link path with empty prefix that resolves to "extern prelude" instead of a module.
// check-pass
// edition:2018
/// [::Unresolved]
//~^ WARN unresolved link to `::Unresolved`
pub struct Item;

View file

@ -0,0 +1,10 @@
warning: unresolved link to `::Unresolved`
--> $DIR/global-path.rs:6:6
|
LL | /// [::Unresolved]
| ^^^^^^^^^^^^ no item named `` in scope
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: 1 warning emitted

View file

@ -2,11 +2,12 @@ error[E0277]: expected a `FnOnce<(&str,)>` closure, found `unsafe extern "rust-i
--> $DIR/coerce-unsafe-to-closure.rs:2:44
|
LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
| --- ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
| --- ^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `Option::<T>::map`
--> $SRC_DIR/core/src/option.rs:LL:COL
|

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-50716.rs:14:9
--> $DIR/issue-50716.rs:18:9
|
LL | let _x = *s;
| ^^ lifetime mismatch
@ -7,7 +7,7 @@ LL | let _x = *s;
= note: expected type `<<&'a T as A>::X as Sized>`
found type `<<&'static T as A>::X as Sized>`
note: the lifetime `'a` as defined here...
--> $DIR/issue-50716.rs:9:8
--> $DIR/issue-50716.rs:13:8
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-50716.rs:14:14
--> $DIR/issue-50716.rs:18:14
|
LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>)
| -- lifetime `'a` defined here

View file

@ -2,6 +2,10 @@
// Regression test for the issue #50716: NLL ignores lifetimes bounds
// derived from `Sized` requirements
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait A {
type X: ?Sized;
}

View file

@ -1,16 +1,16 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-52742.rs:12:18
--> $DIR/issue-52742.rs:17:18
|
LL | self.y = b.z
| ^^^
|
note: ...the reference is valid for the lifetime `'_` as defined here...
--> $DIR/issue-52742.rs:10:10
--> $DIR/issue-52742.rs:15:10
|
LL | impl Foo<'_, '_> {
| ^^
note: ...but the borrowed content is only valid for the anonymous lifetime defined here
--> $DIR/issue-52742.rs:11:31
--> $DIR/issue-52742.rs:16:31
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
| ^^^^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-52742.rs:12:9
--> $DIR/issue-52742.rs:17:9
|
LL | fn take_bar(&mut self, b: Bar<'_>) {
| --------- -- let's call this `'1`

View file

@ -1,3 +1,8 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
struct Foo<'a, 'b> {
x: &'a u32,
y: &'b u32,

View file

@ -1,26 +1,26 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'s` due to conflicting requirements
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | Foo { bar }
| ^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/issue-55394.rs:8:17
--> $DIR/issue-55394.rs:12:17
|
LL | fn new(bar: &mut Bar) -> Self {
| ^^^^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-55394.rs:9:15
--> $DIR/issue-55394.rs:13:15
|
LL | Foo { bar }
| ^^^
note: but, the lifetime must be valid for the lifetime `'_` as defined here...
--> $DIR/issue-55394.rs:7:10
--> $DIR/issue-55394.rs:11:10
|
LL | impl Foo<'_> {
| ^^
note: ...so that the types are compatible
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | Foo { bar }
| ^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-55394.rs:9:9
--> $DIR/issue-55394.rs:13:9
|
LL | fn new(bar: &mut Bar) -> Self {
| - ---- return type is Foo<'2>

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
struct Bar;
struct Foo<'s> {

View file

@ -1,12 +1,12 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-55401.rs:3:5
--> $DIR/issue-55401.rs:7:5
|
LL | *y
| ^^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/issue-55401.rs:1:47
--> $DIR/issue-55401.rs:5:47
|
LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-55401.rs:3:5
--> $DIR/issue-55401.rs:7:5
|
LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u32 {
let (ref y, _z): (&'a u32, u32) = (&22, 44);
*y //~ ERROR

View file

@ -1,25 +1,25 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-if.rs:28:9
--> $DIR/lub-if.rs:32:9
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-if.rs:23:17
--> $DIR/lub-if.rs:27:17
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-if.rs:35:9
--> $DIR/lub-if.rs:41:9
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-if.rs:32:17
--> $DIR/lub-if.rs:38:17
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lub-if.rs:28:9
--> $DIR/lub-if.rs:32:9
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
@ -8,7 +8,7 @@ LL | s
| ^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/lub-if.rs:35:9
--> $DIR/lub-if.rs:41:9
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here

View file

@ -2,6 +2,10 @@
// of the various arms, particularly in the case where regions are
// involved.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
if maybestr.is_none() {
"(none)"
@ -25,14 +29,18 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
"(none)"
} else {
let s: &'a str = maybestr.as_ref().unwrap();
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
}
pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
if maybestr.is_some() {
let s: &'a str = maybestr.as_ref().unwrap();
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
} else {
"(none)"
}

View file

@ -1,25 +1,25 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-match.rs:30:13
--> $DIR/lub-match.rs:34:13
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-match.rs:25:17
--> $DIR/lub-match.rs:29:17
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/lub-match.rs:39:13
--> $DIR/lub-match.rs:45:13
|
LL | s
| ^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/lub-match.rs:35:17
--> $DIR/lub-match.rs:41:17
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/lub-match.rs:30:13
--> $DIR/lub-match.rs:34:13
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
@ -8,7 +8,7 @@ LL | s
| ^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/lub-match.rs:39:13
--> $DIR/lub-match.rs:45:13
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here

View file

@ -2,6 +2,10 @@
// of the various arms, particularly in the case where regions are
// involved.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
match *maybestr {
Some(ref s) => {
@ -27,7 +31,9 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
None => "(none)",
Some(ref s) => {
let s: &'a str = s;
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
}
}
@ -36,7 +42,9 @@ pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
match *maybestr {
Some(ref s) => {
let s: &'a str = s;
s //~ ERROR E0312
s
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}
None => "(none)",
}

View file

@ -1,28 +1,28 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | C { f: b }
| ^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/type-alias-free-regions.rs:16:24
--> $DIR/type-alias-free-regions.rs:20:24
|
LL | fn from_box(b: Box<B>) -> Self {
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:17:16
--> $DIR/type-alias-free-regions.rs:21:16
|
LL | C { f: b }
| ^
= note: expected `Box<Box<&isize>>`
found `Box<Box<&isize>>`
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/type-alias-free-regions.rs:15:6
--> $DIR/type-alias-free-regions.rs:19:6
|
LL | impl<'a> FromBox<'a> for C<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | C { f: b }
| ^^^^^^^^^^
@ -30,30 +30,30 @@ LL | C { f: b }
found `C<'_>`
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/type-alias-free-regions.rs:27:16
--> $DIR/type-alias-free-regions.rs:31:16
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/type-alias-free-regions.rs:26:23
--> $DIR/type-alias-free-regions.rs:30:23
|
LL | fn from_tuple(b: (B,)) -> Self {
| ^
note: ...so that the expression is assignable
--> $DIR/type-alias-free-regions.rs:27:25
--> $DIR/type-alias-free-regions.rs:31:25
|
LL | C { f: Box::new(b.0) }
| ^^^
= note: expected `Box<&isize>`
found `Box<&isize>`
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/type-alias-free-regions.rs:25:6
--> $DIR/type-alias-free-regions.rs:29:6
|
LL | impl<'a> FromTuple<'a> for C<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/type-alias-free-regions.rs:27:9
--> $DIR/type-alias-free-regions.rs:31:9
|
LL | C { f: Box::new(b.0) }
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/type-alias-free-regions.rs:17:9
--> $DIR/type-alias-free-regions.rs:21:9
|
LL | impl<'a> FromBox<'a> for C<'a> {
| -- lifetime `'a` defined here
@ -9,7 +9,7 @@ LL | C { f: b }
| ^^^^^^^^^^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
error: lifetime may not live long enough
--> $DIR/type-alias-free-regions.rs:27:9
--> $DIR/type-alias-free-regions.rs:31:9
|
LL | impl<'a> FromTuple<'a> for C<'a> {
| -- lifetime `'a` defined here

View file

@ -1,6 +1,10 @@
// Test that we don't assume that type aliases have the same type parameters
// as the type they alias and then panic when we see this.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
type A<'a> = &'a isize;
type B<'a> = Box<A<'a>>;

View file

@ -1,5 +1,5 @@
error[E0759]: `fn` parameter has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/constant-in-expr-inherent-1.rs:8:5
--> $DIR/constant-in-expr-inherent-1.rs:12:5
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| ------- this data with lifetime `'a`...

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/constant-in-expr-inherent-1.rs:8:5
--> $DIR/constant-in-expr-inherent-1.rs:12:5
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
struct Foo<'a> { x: &'a u32 }
impl<'a> Foo<'a> {

View file

@ -1,12 +1,12 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/constant-in-expr-normalize.rs:18:5
--> $DIR/constant-in-expr-normalize.rs:22:5
|
LL | <() as Foo<'a>>::C
| ^^^^^^^^^^^^^^^^^^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/constant-in-expr-normalize.rs:17:8
--> $DIR/constant-in-expr-normalize.rs:21:8
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/constant-in-expr-normalize.rs:18:5
--> $DIR/constant-in-expr-normalize.rs:22:5
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Mirror {
type Me;
}

View file

@ -1,12 +1,12 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/constant-in-expr-trait-item-1.rs:10:5
--> $DIR/constant-in-expr-trait-item-1.rs:14:5
|
LL | <() as Foo<'a>>::C
| ^^^^^^^^^^^^^^^^^^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/constant-in-expr-trait-item-1.rs:9:8
--> $DIR/constant-in-expr-trait-item-1.rs:13:8
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/constant-in-expr-trait-item-1.rs:10:5
--> $DIR/constant-in-expr-trait-item-1.rs:14:5
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Foo<'a> {
const C: &'a u32;
}

View file

@ -1,12 +1,12 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/constant-in-expr-trait-item-2.rs:10:5
--> $DIR/constant-in-expr-trait-item-2.rs:14:5
|
LL | <T as Foo<'a>>::C
| ^^^^^^^^^^^^^^^^^
|
= note: ...the reference is valid for the static lifetime...
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
--> $DIR/constant-in-expr-trait-item-2.rs:9:8
--> $DIR/constant-in-expr-trait-item-2.rs:13:8
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/constant-in-expr-trait-item-2.rs:10:5
--> $DIR/constant-in-expr-trait-item-2.rs:14:5
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Foo<'a> {
const C: &'a u32;
}

View file

@ -1,16 +1,16 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
--> $DIR/constant-in-expr-trait-item-3.rs:14:5
|
LL | T::C
| ^^^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
--> $DIR/constant-in-expr-trait-item-3.rs:9:8
--> $DIR/constant-in-expr-trait-item-3.rs:13:8
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
| ^^
note: ...so that the types are compatible
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
--> $DIR/constant-in-expr-trait-item-3.rs:14:5
|
LL | T::C
| ^^^^
@ -18,7 +18,7 @@ LL | T::C
found `Foo<'a>`
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that reference does not outlive borrowed content
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
--> $DIR/constant-in-expr-trait-item-3.rs:14:5
|
LL | T::C
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/constant-in-expr-trait-item-3.rs:10:5
--> $DIR/constant-in-expr-trait-item-3.rs:14:5
|
LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 {
| -- lifetime `'a` defined here

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Foo<'a> {
const C: &'a u32;
}

View file

@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/rfc1623.rs:28:8
--> $DIR/rfc1623.rs:36:8
|
LL | f: &id,
| ^^^ implementation of `FnOnce` is not general enough

View file

@ -1,11 +1,12 @@
error[E0308]: mismatched types
--> $DIR/rfc1623.rs:25:35
--> $DIR/rfc1623.rs:29:35
|
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
| ___________________________________^
LL | | foo: &Foo { bools: &[false, true] },
LL | | bar: &Bar { bools: &[true, true] },
LL | | f: &id,
LL | |
LL | |
LL | |
... |
LL | |
LL | | };
| |_^ one type is more general than the other
@ -14,13 +15,14 @@ LL | | };
found type `Fn<(&Foo<'_>,)>`
error[E0308]: mismatched types
--> $DIR/rfc1623.rs:25:35
--> $DIR/rfc1623.rs:29:35
|
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
| ___________________________________^
LL | | foo: &Foo { bools: &[false, true] },
LL | | bar: &Bar { bools: &[true, true] },
LL | | f: &id,
LL | |
LL | |
LL | |
... |
LL | |
LL | | };
| |_^ one type is more general than the other
@ -29,13 +31,14 @@ LL | | };
found type `Fn<(&Foo<'_>,)>`
error: implementation of `FnOnce` is not general enough
--> $DIR/rfc1623.rs:25:35
--> $DIR/rfc1623.rs:29:35
|
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
| ___________________________________^
LL | | foo: &Foo { bools: &[false, true] },
LL | | bar: &Bar { bools: &[true, true] },
LL | | f: &id,
LL | |
LL | |
LL | |
... |
LL | |
LL | | };
| |_^ implementation of `FnOnce` is not general enough
@ -44,13 +47,14 @@ LL | | };
= note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2`
error: implementation of `FnOnce` is not general enough
--> $DIR/rfc1623.rs:25:35
--> $DIR/rfc1623.rs:29:35
|
LL | static SOME_STRUCT: &SomeStruct = &SomeStruct {
| ___________________________________^
LL | | foo: &Foo { bools: &[false, true] },
LL | | bar: &Bar { bools: &[true, true] },
LL | | f: &id,
LL | |
LL | |
LL | |
... |
LL | |
LL | | };
| |_^ implementation of `FnOnce` is not general enough

View file

@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
#![allow(dead_code)]
fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 {
@ -23,10 +27,14 @@ fn id<T>(t: T) -> T {
}
static SOME_STRUCT: &SomeStruct = &SomeStruct {
//[nll]~^ ERROR mismatched types
//[nll]~| ERROR mismatched types
//[nll]~| ERROR implementation of `FnOnce` is not general enough
//[nll]~| ERROR implementation of `FnOnce` is not general enough
foo: &Foo { bools: &[false, true] },
bar: &Bar { bools: &[true, true] },
f: &id,
//~^ ERROR implementation of `FnOnce` is not general enough
//[base]~^ ERROR implementation of `FnOnce` is not general enough
};
// very simple test for a 'static static with default lifetime

View file

@ -53,7 +53,7 @@ error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:28:10
|
LL | call(foo_unsafe);
| ---- ^^^^^^^^^^ expected an `Fn<()>` closure, found `unsafe fn() {foo_unsafe}`
| ---- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
@ -70,7 +70,7 @@ error[E0277]: expected a `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:30:14
|
LL | call_mut(foo_unsafe);
| -------- ^^^^^^^^^^ expected an `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}`
| -------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
@ -87,7 +87,7 @@ error[E0277]: expected a `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}`
--> $DIR/fn-traits.rs:32:15
|
LL | call_once(foo_unsafe);
| --------- ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}`
| --------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|

View file

@ -1,23 +1,23 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:10:24
--> $DIR/generic_type_does_not_live_long_enough.rs:14:24
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^
error: non-defining opaque type use in defining scope
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
--> $DIR/generic_type_does_not_live_long_enough.rs:10:18
|
LL | let z: i32 = x;
| ^
|
note: used non-generic type `&'static i32` for generic parameter
--> $DIR/generic_type_does_not_live_long_enough.rs:10:19
--> $DIR/generic_type_does_not_live_long_enough.rs:14:19
|
LL | type WrongGeneric<T> = impl 'static;
| ^
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:14:5
--> $DIR/generic_type_does_not_live_long_enough.rs:18:5
|
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`

View file

@ -1,23 +1,23 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:10:24
--> $DIR/generic_type_does_not_live_long_enough.rs:14:24
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^
error: non-defining opaque type use in defining scope
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
--> $DIR/generic_type_does_not_live_long_enough.rs:10:18
|
LL | let z: i32 = x;
| ^
|
note: used non-generic type `&'static i32` for generic parameter
--> $DIR/generic_type_does_not_live_long_enough.rs:10:19
--> $DIR/generic_type_does_not_live_long_enough.rs:14:19
|
LL | type WrongGeneric<T> = impl 'static;
| ^
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:14:5
--> $DIR/generic_type_does_not_live_long_enough.rs:18:5
|
LL | t
| ^

View file

@ -1,5 +1,9 @@
#![feature(type_alias_impl_trait)]
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn main() {
let y = 42;
let x = wrong_generic(&y);

View file

@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ implementation of `FnOnce` is not general enough

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ one type is more general than the other
@ -7,13 +7,13 @@ LL | |x| x
= note: expected type `for<'r> Fn<(&'r X,)>`
found type `Fn<(&X,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ implementation of `FnOnce` is not general enough

View file

@ -1,6 +1,11 @@
// Regression test for issue #57611
// Ensures that we don't ICE
// FIXME: This should compile, but it currently doesn't
// known-bug
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
@ -18,7 +23,6 @@ impl Foo for X {
fn bar(&self) -> Self::Bar {
|x| x
//~^ ERROR implementation of `FnOnce` is not general enough
}
}

View file

@ -0,0 +1,13 @@
struct NotClone;
fn main() {
clone_thing(&NotClone);
}
fn clone_thing(nc: &NotClone) -> NotClone {
//~^ NOTE expected `NotClone` because of return type
nc.clone()
//~^ ERROR mismatched type
//~| NOTE `NotClone` does not implement `Clone`, so `&NotClone` was cloned instead
//~| NOTE expected struct `NotClone`, found `&NotClone`
}

View file

@ -0,0 +1,18 @@
error[E0308]: mismatched types
--> $DIR/explain_clone_autoref.rs:9:5
|
LL | fn clone_thing(nc: &NotClone) -> NotClone {
| -------- expected `NotClone` because of return type
LL |
LL | nc.clone()
| ^^^^^^^^^^ expected struct `NotClone`, found `&NotClone`
|
note: `NotClone` does not implement `Clone`, so `&NotClone` was cloned instead
--> $DIR/explain_clone_autoref.rs:9:5
|
LL | nc.clone()
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-30906.rs:18:5
--> $DIR/issue-30906.rs:22:5
|
LL | test(Compose(f, |_| {}));
| ^^^^ implementation of `FnOnce` is not general enough

View file

@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-30906.rs:18:5
--> $DIR/issue-30906.rs:22:5
|
LL | test(Compose(f, |_| {}));
| ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough

View file

@ -1,5 +1,9 @@
#![feature(fn_traits, unboxed_closures)]
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}
struct Compose<F, G>(F, G);

View file

@ -1,23 +1,27 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:17:15
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:21:15
|
LL | x.set(y);
| ^
|
note: ...the reference is valid for the anonymous lifetime #2 defined here...
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:20:14
|
LL | doit(0, &|x, y| {
| ______________^
LL | | x.set(y);
LL | |
LL | |
LL | | });
| |_____^
note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined here
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:20:14
|
LL | doit(0, &|x, y| {
| ______________^
LL | | x.set(y);
LL | |
LL | |
LL | | });
| |_____^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:17:9
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:21:9
|
LL | doit(0, &|x, y| {
| - - has type `&'1 i32`

View file

@ -3,6 +3,10 @@
// That a closure whose expected argument types include two distinct
// bound regions.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
use std::cell::Cell;
fn doit<T,F>(val: T, f: &F)
@ -14,6 +18,8 @@ fn doit<T,F>(val: T, f: &F)
pub fn main() {
doit(0, &|x, y| {
x.set(y); //~ ERROR E0312
x.set(y);
//[base]~^ ERROR E0312
//[nll]~^^ lifetime may not live long enough
});
}

View file

@ -2,11 +2,12 @@ error[E0277]: expected a `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r i
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21
|
LL | let x = call_it(&square, 22);
| ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
| ------- ^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> Fn<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:9:15
|
@ -17,11 +18,12 @@ error[E0277]: expected a `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25
|
LL | let y = call_it_mut(&mut square, 22);
| ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
| ----------- ^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> FnMut<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it_mut`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:19
|
@ -32,11 +34,12 @@ error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26
|
LL | let z = call_it_once(square, 22);
| ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
| ------------ ^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> FnOnce<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it_once`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:15:20
|

View file

@ -2,11 +2,12 @@ error[E0277]: expected a `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isi
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:21:21
|
LL | let x = call_it(&square, 22);
| ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
| ------- ^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> Fn<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:10:15
|
@ -17,11 +18,12 @@ error[E0277]: expected a `FnMut<(&isize,)>` closure, found `unsafe fn(isize) ->
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:26:25
|
LL | let y = call_it_mut(&mut square, 22);
| ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
| ----------- ^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> FnMut<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it_mut`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:19
|
@ -32,11 +34,12 @@ error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) ->
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:31:26
|
LL | let z = call_it_once(square, 22);
| ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
| ------------ ^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'r> FnOnce<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
= note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `call_it_once`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:16:20
|

View file

@ -1,5 +1,5 @@
error[E0759]: `items` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/dyn-trait-underscore.rs:8:20
--> $DIR/dyn-trait-underscore.rs:12:20
|
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
| ---- this data with an anonymous lifetime `'_`...
@ -10,7 +10,7 @@ LL | Box::new(items.iter())
| ...is used and required to live as long as `'static` here
|
note: `'static` lifetime requirement introduced by the return type
--> $DIR/dyn-trait-underscore.rs:6:29
--> $DIR/dyn-trait-underscore.rs:10:29
|
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
| ^^^^^^^^^^^^^^^^^^^^^ `'static` requirement introduced here

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/dyn-trait-underscore.rs:8:5
--> $DIR/dyn-trait-underscore.rs:12:5
|
LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
| - let's call the lifetime of this reference `'1`

View file

@ -3,9 +3,15 @@
//
// cc #48468
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
// ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
Box::new(items.iter()) //~ ERROR E0759
Box::new(items.iter())
//[base]~^ ERROR E0759
//[nll]~^^ ERROR lifetime may not live long enough
}
fn b<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> {

View file

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/underscore-lifetime-elison-mismatch.rs:1:49
--> $DIR/underscore-lifetime-elison-mismatch.rs:5:49
|
LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); }
| ------ ------ ^ ...but data from `y` flows into `x` here

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/underscore-lifetime-elison-mismatch.rs:1:42
--> $DIR/underscore-lifetime-elison-mismatch.rs:5:42
|
LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); }
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`

View file

@ -1,3 +1,9 @@
fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); }
//[base]~^ ERROR lifetime mismatch
//[nll]~^^ ERROR lifetime may not live long enough
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-associated-types2.rs:13:42
--> $DIR/variance-associated-types2.rs:17:42
|
LL | let _: Box<dyn Foo<Bar = &'a u32>> = make();
| ^^^^^^ lifetime mismatch
@ -7,7 +7,7 @@ LL | let _: Box<dyn Foo<Bar = &'a u32>> = make();
= note: expected trait object `dyn Foo<Bar = &'a u32>`
found trait object `dyn Foo<Bar = &'static u32>`
note: the lifetime `'a` as defined here...
--> $DIR/variance-associated-types2.rs:12:9
--> $DIR/variance-associated-types2.rs:16:9
|
LL | fn take<'a>(_: &'a u32) {
| ^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-associated-types2.rs:13:12
--> $DIR/variance-associated-types2.rs:17:12
|
LL | fn take<'a>(_: &'a u32) {
| -- lifetime `'a` defined here

View file

@ -1,6 +1,10 @@
// Test that dyn Foo<Bar = T> is invariant with respect to T.
// Failure to enforce invariance here can be weaponized, see #71550 for details.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Foo {
type Bar;
}
@ -11,7 +15,8 @@ fn make() -> Box<dyn Foo<Bar = &'static u32>> {
fn take<'a>(_: &'a u32) {
let _: Box<dyn Foo<Bar = &'a u32>> = make();
//~^ ERROR mismatched types [E0308]
//[base]~^ ERROR mismatched types [E0308]
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:4:5
--> $DIR/variance-btree-invariant-types.rs:8:5
|
LL | v
| ^ lifetime mismatch
@ -7,164 +7,164 @@ LL | v
= note: expected struct `std::collections::btree_map::IterMut<'_, &'new (), _>`
found struct `std::collections::btree_map::IterMut<'_, &'static (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:3:21
--> $DIR/variance-btree-invariant-types.rs:7:21
|
LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:7:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::IterMut<'_, _, &'new ()>`
found struct `std::collections::btree_map::IterMut<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:6:21
|
LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:10:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::IterMut<'_, &'static (), _>`
found struct `std::collections::btree_map::IterMut<'_, &'new (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:9:24
|
LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:13:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::IterMut<'_, _, &'static ()>`
found struct `std::collections::btree_map::IterMut<'_, _, &'new ()>`
= note: expected struct `std::collections::btree_map::IterMut<'_, _, &'new ()>`
found struct `std::collections::btree_map::IterMut<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:12:24
--> $DIR/variance-btree-invariant-types.rs:12:21
|
LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> {
LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:18:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::IterMut<'_, &'static (), _>`
found struct `std::collections::btree_map::IterMut<'_, &'new (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:17:24
|
LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:17:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, &'new (), _>`
found struct `RangeMut<'_, &'static (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:16:22
|
LL | fn range_cov_key<'a, 'new>(v: RangeMut<'a, &'static (), ()>) -> RangeMut<'a, &'new (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:20:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, _, &'new ()>`
found struct `RangeMut<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:19:22
|
LL | fn range_cov_val<'a, 'new>(v: RangeMut<'a, (), &'static ()>) -> RangeMut<'a, (), &'new ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:23:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, &'static (), _>`
found struct `RangeMut<'_, &'new (), _>`
= note: expected struct `std::collections::btree_map::IterMut<'_, _, &'static ()>`
found struct `std::collections::btree_map::IterMut<'_, _, &'new ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:22:25
--> $DIR/variance-btree-invariant-types.rs:22:24
|
LL | fn range_contra_key<'a, 'new>(v: RangeMut<'a, &'new (), ()>) -> RangeMut<'a, &'static (), ()> {
| ^^^^
LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:26:5
--> $DIR/variance-btree-invariant-types.rs:29:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, _, &'static ()>`
found struct `RangeMut<'_, _, &'new ()>`
= note: expected struct `RangeMut<'_, &'new (), _>`
found struct `RangeMut<'_, &'static (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:25:25
--> $DIR/variance-btree-invariant-types.rs:28:22
|
LL | fn range_contra_val<'a, 'new>(v: RangeMut<'a, (), &'new ()>) -> RangeMut<'a, (), &'static ()> {
| ^^^^
LL | fn range_cov_key<'a, 'new>(v: RangeMut<'a, &'static (), ()>) -> RangeMut<'a, &'new (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:31:5
--> $DIR/variance-btree-invariant-types.rs:34:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, &'new (), _>`
found struct `std::collections::btree_map::OccupiedEntry<'_, &'static (), _>`
= note: expected struct `RangeMut<'_, _, &'new ()>`
found struct `RangeMut<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:29:20
--> $DIR/variance-btree-invariant-types.rs:33:22
|
LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:35:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, _, &'new ()>`
found struct `std::collections::btree_map::OccupiedEntry<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:33:20
|
LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>)
| ^^^^
LL | fn range_cov_val<'a, 'new>(v: RangeMut<'a, (), &'static ()>) -> RangeMut<'a, (), &'new ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:39:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, &'static (), _>`
found struct `RangeMut<'_, &'new (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:38:25
|
LL | fn range_contra_key<'a, 'new>(v: RangeMut<'a, &'new (), ()>) -> RangeMut<'a, &'static (), ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:44:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `RangeMut<'_, _, &'static ()>`
found struct `RangeMut<'_, _, &'new ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:43:25
|
LL | fn range_contra_val<'a, 'new>(v: RangeMut<'a, (), &'new ()>) -> RangeMut<'a, (), &'static ()> {
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:51:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, &'new (), _>`
found struct `std::collections::btree_map::OccupiedEntry<'_, &'static (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:49:20
|
LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:57:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, _, &'new ()>`
found struct `std::collections::btree_map::OccupiedEntry<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:55:20
|
LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:63:5
|
LL | v
| ^ lifetime mismatch
|
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, &'static (), _>`
found struct `std::collections::btree_map::OccupiedEntry<'_, &'new (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:37:23
--> $DIR/variance-btree-invariant-types.rs:61:23
|
LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:43:5
--> $DIR/variance-btree-invariant-types.rs:69:5
|
LL | v
| ^ lifetime mismatch
@ -172,14 +172,14 @@ LL | v
= note: expected struct `std::collections::btree_map::OccupiedEntry<'_, _, &'static ()>`
found struct `std::collections::btree_map::OccupiedEntry<'_, _, &'new ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:41:23
--> $DIR/variance-btree-invariant-types.rs:67:23
|
LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:48:5
--> $DIR/variance-btree-invariant-types.rs:76:5
|
LL | v
| ^ lifetime mismatch
@ -187,14 +187,14 @@ LL | v
= note: expected struct `std::collections::btree_map::VacantEntry<'_, &'new (), _>`
found struct `std::collections::btree_map::VacantEntry<'_, &'static (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:46:20
--> $DIR/variance-btree-invariant-types.rs:74:20
|
LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:52:5
--> $DIR/variance-btree-invariant-types.rs:82:5
|
LL | v
| ^ lifetime mismatch
@ -202,14 +202,14 @@ LL | v
= note: expected struct `std::collections::btree_map::VacantEntry<'_, _, &'new ()>`
found struct `std::collections::btree_map::VacantEntry<'_, _, &'static ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:50:20
--> $DIR/variance-btree-invariant-types.rs:80:20
|
LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:56:5
--> $DIR/variance-btree-invariant-types.rs:88:5
|
LL | v
| ^ lifetime mismatch
@ -217,14 +217,14 @@ LL | v
= note: expected struct `std::collections::btree_map::VacantEntry<'_, &'static (), _>`
found struct `std::collections::btree_map::VacantEntry<'_, &'new (), _>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:54:23
--> $DIR/variance-btree-invariant-types.rs:86:23
|
LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>)
| ^^^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> $DIR/variance-btree-invariant-types.rs:60:5
--> $DIR/variance-btree-invariant-types.rs:94:5
|
LL | v
| ^ lifetime mismatch
@ -232,7 +232,7 @@ LL | v
= note: expected struct `std::collections::btree_map::VacantEntry<'_, _, &'static ()>`
found struct `std::collections::btree_map::VacantEntry<'_, _, &'new ()>`
note: the lifetime `'new` as defined here...
--> $DIR/variance-btree-invariant-types.rs:58:23
--> $DIR/variance-btree-invariant-types.rs:92:23
|
LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>)
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:4:5
--> $DIR/variance-btree-invariant-types.rs:8:5
|
LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> {
| ---- lifetime `'new` defined here
@ -11,7 +11,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:7:5
--> $DIR/variance-btree-invariant-types.rs:13:5
|
LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> {
| ---- lifetime `'new` defined here
@ -23,7 +23,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:10:5
--> $DIR/variance-btree-invariant-types.rs:18:5
|
LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> {
| ---- lifetime `'new` defined here
@ -35,7 +35,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:13:5
--> $DIR/variance-btree-invariant-types.rs:23:5
|
LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> {
| ---- lifetime `'new` defined here
@ -47,7 +47,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:17:5
--> $DIR/variance-btree-invariant-types.rs:29:5
|
LL | fn range_cov_key<'a, 'new>(v: RangeMut<'a, &'static (), ()>) -> RangeMut<'a, &'new (), ()> {
| ---- lifetime `'new` defined here
@ -59,7 +59,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:20:5
--> $DIR/variance-btree-invariant-types.rs:34:5
|
LL | fn range_cov_val<'a, 'new>(v: RangeMut<'a, (), &'static ()>) -> RangeMut<'a, (), &'new ()> {
| ---- lifetime `'new` defined here
@ -71,7 +71,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:23:5
--> $DIR/variance-btree-invariant-types.rs:39:5
|
LL | fn range_contra_key<'a, 'new>(v: RangeMut<'a, &'new (), ()>) -> RangeMut<'a, &'static (), ()> {
| ---- lifetime `'new` defined here
@ -83,7 +83,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:26:5
--> $DIR/variance-btree-invariant-types.rs:44:5
|
LL | fn range_contra_val<'a, 'new>(v: RangeMut<'a, (), &'new ()>) -> RangeMut<'a, (), &'static ()> {
| ---- lifetime `'new` defined here
@ -95,7 +95,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:31:5
--> $DIR/variance-btree-invariant-types.rs:51:5
|
LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>)
| ---- lifetime `'new` defined here
@ -108,7 +108,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:35:5
--> $DIR/variance-btree-invariant-types.rs:57:5
|
LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>)
| ---- lifetime `'new` defined here
@ -121,7 +121,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:39:5
--> $DIR/variance-btree-invariant-types.rs:63:5
|
LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>)
| ---- lifetime `'new` defined here
@ -134,7 +134,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:43:5
--> $DIR/variance-btree-invariant-types.rs:69:5
|
LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>)
| ---- lifetime `'new` defined here
@ -147,7 +147,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:48:5
--> $DIR/variance-btree-invariant-types.rs:76:5
|
LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>)
| ---- lifetime `'new` defined here
@ -160,7 +160,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:52:5
--> $DIR/variance-btree-invariant-types.rs:82:5
|
LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>)
| ---- lifetime `'new` defined here
@ -173,7 +173,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:56:5
--> $DIR/variance-btree-invariant-types.rs:88:5
|
LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>)
| ---- lifetime `'new` defined here
@ -186,7 +186,7 @@ LL | v
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/variance-btree-invariant-types.rs:60:5
--> $DIR/variance-btree-invariant-types.rs:94:5
|
LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>)
| ---- lifetime `'new` defined here

View file

@ -1,63 +1,99 @@
use std::collections::btree_map::{IterMut, OccupiedEntry, RangeMut, VacantEntry};
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn range_cov_key<'a, 'new>(v: RangeMut<'a, &'static (), ()>) -> RangeMut<'a, &'new (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn range_cov_val<'a, 'new>(v: RangeMut<'a, (), &'static ()>) -> RangeMut<'a, (), &'new ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn range_contra_key<'a, 'new>(v: RangeMut<'a, &'new (), ()>) -> RangeMut<'a, &'static (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn range_contra_val<'a, 'new>(v: RangeMut<'a, (), &'new ()>) -> RangeMut<'a, (), &'static ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>)
-> OccupiedEntry<'a, &'new (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>)
-> OccupiedEntry<'a, (), &'new ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>)
-> OccupiedEntry<'a, &'static (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>)
-> OccupiedEntry<'a, (), &'static ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>)
-> VacantEntry<'a, &'new (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>)
-> VacantEntry<'a, (), &'new ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>)
-> VacantEntry<'a, &'static (), ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}
fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>)
-> VacantEntry<'a, (), &'static ()> {
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ lifetime may not live long enough
}

View file

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/variance-cell-is-invariant.rs:14:25
--> $DIR/variance-cell-is-invariant.rs:18:25
|
LL | fn use_<'short,'long>(c: Foo<'short>,
| ----------- these two types are declared with different lifetimes...

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-cell-is-invariant.rs:14:12
--> $DIR/variance-cell-is-invariant.rs:18:12
|
LL | fn use_<'short,'long>(c: Foo<'short>,
| ------ ----- lifetime `'long` defined here

View file

@ -1,6 +1,10 @@
// Test that Cell is considered invariant with respect to its
// type.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
use std::cell::Cell;
struct Foo<'a> {
@ -11,7 +15,9 @@ fn use_<'short,'long>(c: Foo<'short>,
s: &'short isize,
l: &'long isize,
_where:Option<&'short &'long ()>) {
let _: Foo<'long> = c; //~ ERROR E0623
let _: Foo<'long> = c;
//[base]~^ ERROR E0623
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() {

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-contravariant-arg-object.rs:14:5
--> $DIR/variance-contravariant-arg-object.rs:18:5
|
LL | v
| ^ lifetime mismatch
@ -7,18 +7,18 @@ LL | v
= note: expected trait object `dyn Get<&'min i32>`
found trait object `dyn Get<&'max i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-arg-object.rs:10:21
--> $DIR/variance-contravariant-arg-object.rs:14:21
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-arg-object.rs:10:27
--> $DIR/variance-contravariant-arg-object.rs:14:27
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ^^^^
error[E0308]: mismatched types
--> $DIR/variance-contravariant-arg-object.rs:22:5
--> $DIR/variance-contravariant-arg-object.rs:28:5
|
LL | v
| ^ lifetime mismatch
@ -26,12 +26,12 @@ LL | v
= note: expected trait object `dyn Get<&'max i32>`
found trait object `dyn Get<&'min i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-arg-object.rs:17:21
--> $DIR/variance-contravariant-arg-object.rs:23:21
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-arg-object.rs:17:27
--> $DIR/variance-contravariant-arg-object.rs:23:27
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-contravariant-arg-object.rs:14:5
--> $DIR/variance-contravariant-arg-object.rs:18:5
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ---- ---- lifetime `'max` defined here
@ -12,7 +12,7 @@ LL | v
= help: consider adding the following bound: `'min: 'max`
error: lifetime may not live long enough
--> $DIR/variance-contravariant-arg-object.rs:22:5
--> $DIR/variance-contravariant-arg-object.rs:28:5
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ---- ---- lifetime `'max` defined here

View file

@ -3,6 +3,10 @@
// Test that even when `T` is only used in contravariant position, it
// is treated as invariant.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Get<T> : 'static {
fn get(&self, t: T);
}
@ -11,7 +15,9 @@ fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
-> Box<dyn Get<&'min i32>>
where 'max : 'min
{
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
@ -19,7 +25,9 @@ fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
where 'max : 'min
{
// Previously OK:
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() { }

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-contravariant-arg-trait-match.rs:13:5
--> $DIR/variance-contravariant-arg-trait-match.rs:17:5
|
LL | impls_get::<G,&'min i32>()
| ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -7,18 +7,18 @@ LL | impls_get::<G,&'min i32>()
= note: expected type `Get<&'min i32>`
found type `Get<&'max i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-arg-trait-match.rs:10:21
--> $DIR/variance-contravariant-arg-trait-match.rs:14:21
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-arg-trait-match.rs:10:27
--> $DIR/variance-contravariant-arg-trait-match.rs:14:27
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
error[E0308]: mismatched types
--> $DIR/variance-contravariant-arg-trait-match.rs:21:5
--> $DIR/variance-contravariant-arg-trait-match.rs:27:5
|
LL | impls_get::<G,&'max i32>()
| ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -26,12 +26,12 @@ LL | impls_get::<G,&'max i32>()
= note: expected type `Get<&'max i32>`
found type `Get<&'min i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-arg-trait-match.rs:16:21
--> $DIR/variance-contravariant-arg-trait-match.rs:22:21
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-arg-trait-match.rs:16:27
--> $DIR/variance-contravariant-arg-trait-match.rs:22:27
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-contravariant-arg-trait-match.rs:13:5
--> $DIR/variance-contravariant-arg-trait-match.rs:17:5
|
LL | fn get_min_from_max<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here
@ -12,7 +12,7 @@ LL | impls_get::<G,&'min i32>()
= help: consider adding the following bound: `'min: 'max`
error: lifetime may not live long enough
--> $DIR/variance-contravariant-arg-trait-match.rs:21:5
--> $DIR/variance-contravariant-arg-trait-match.rs:27:5
|
LL | fn get_max_from_min<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here

View file

@ -3,6 +3,10 @@
// Test that even when `T` is only used in contravariant position, it
// is treated as invariant.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Get<T> {
fn get(&self, t: T);
}
@ -10,7 +14,9 @@ trait Get<T> {
fn get_min_from_max<'min, 'max, G>()
where 'max : 'min, G : Get<&'max i32>
{
impls_get::<G,&'min i32>() //~ ERROR mismatched types
impls_get::<G,&'min i32>()
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn get_max_from_min<'min, 'max, G>()
@ -18,7 +24,9 @@ fn get_max_from_min<'min, 'max, G>()
{
// Previously OK, but now an error because traits are invariant:
impls_get::<G,&'max i32>() //~ ERROR mismatched types
impls_get::<G,&'max i32>()
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn impls_get<G,T>() where G : Get<T> { }

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-contravariant-self-trait-match.rs:13:5
--> $DIR/variance-contravariant-self-trait-match.rs:17:5
|
LL | impls_get::<&'min G>();
| ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -7,18 +7,18 @@ LL | impls_get::<&'min G>();
= note: expected type `<&'min G as Get>`
found type `<&'max G as Get>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-self-trait-match.rs:10:21
--> $DIR/variance-contravariant-self-trait-match.rs:14:21
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-self-trait-match.rs:10:27
--> $DIR/variance-contravariant-self-trait-match.rs:14:27
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
error[E0308]: mismatched types
--> $DIR/variance-contravariant-self-trait-match.rs:22:5
--> $DIR/variance-contravariant-self-trait-match.rs:28:5
|
LL | impls_get::<&'max G>();
| ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -26,12 +26,12 @@ LL | impls_get::<&'max G>();
= note: expected type `<&'max G as Get>`
found type `<&'min G as Get>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-contravariant-self-trait-match.rs:16:21
--> $DIR/variance-contravariant-self-trait-match.rs:22:21
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-contravariant-self-trait-match.rs:16:27
--> $DIR/variance-contravariant-self-trait-match.rs:22:27
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-contravariant-self-trait-match.rs:13:5
--> $DIR/variance-contravariant-self-trait-match.rs:17:5
|
LL | fn get_min_from_max<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here
@ -12,7 +12,7 @@ LL | impls_get::<&'min G>();
= help: consider adding the following bound: `'min: 'max`
error: lifetime may not live long enough
--> $DIR/variance-contravariant-self-trait-match.rs:22:5
--> $DIR/variance-contravariant-self-trait-match.rs:28:5
|
LL | fn get_max_from_min<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here

View file

@ -3,6 +3,10 @@
// Test that even when `Self` is only used in contravariant position, it
// is treated as invariant.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Get {
fn get(&self);
}
@ -10,7 +14,9 @@ trait Get {
fn get_min_from_max<'min, 'max, G>()
where 'max : 'min, G : 'max, &'max G : Get
{
impls_get::<&'min G>(); //~ ERROR mismatched types
impls_get::<&'min G>();
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn get_max_from_min<'min, 'max, G>()
@ -19,7 +25,9 @@ fn get_max_from_min<'min, 'max, G>()
// Previously OK, but now error because traits are invariant with
// respect to all inputs.
impls_get::<&'max G>(); //~ ERROR mismatched types
impls_get::<&'max G>();
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn impls_get<G>() where G : Get { }

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-invariant-arg-object.rs:11:5
--> $DIR/variance-covariant-arg-object.rs:19:5
|
LL | v
| ^ lifetime mismatch
@ -7,18 +7,18 @@ LL | v
= note: expected trait object `dyn Get<&'min i32>`
found trait object `dyn Get<&'max i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-invariant-arg-object.rs:7:21
--> $DIR/variance-covariant-arg-object.rs:14:21
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-invariant-arg-object.rs:7:27
--> $DIR/variance-covariant-arg-object.rs:14:27
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ^^^^
error[E0308]: mismatched types
--> $DIR/variance-invariant-arg-object.rs:18:5
--> $DIR/variance-covariant-arg-object.rs:28:5
|
LL | v
| ^ lifetime mismatch
@ -26,12 +26,12 @@ LL | v
= note: expected trait object `dyn Get<&'max i32>`
found trait object `dyn Get<&'min i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-invariant-arg-object.rs:14:21
--> $DIR/variance-covariant-arg-object.rs:24:21
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-invariant-arg-object.rs:14:27
--> $DIR/variance-covariant-arg-object.rs:24:27
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-covariant-arg-object.rs:15:5
--> $DIR/variance-covariant-arg-object.rs:19:5
|
LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
| ---- ---- lifetime `'max` defined here
@ -12,7 +12,7 @@ LL | v
= help: consider adding the following bound: `'min: 'max`
error: lifetime may not live long enough
--> $DIR/variance-covariant-arg-object.rs:22:5
--> $DIR/variance-covariant-arg-object.rs:28:5
|
LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
| ---- ---- lifetime `'max` defined here

View file

@ -3,6 +3,10 @@
// Test that even when `T` is only used in covariant position, it
// is treated as invariant.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
trait Get<T> : 'static {
fn get(&self) -> T;
}
@ -12,14 +16,18 @@ fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
where 'max : 'min
{
// Previously OK, now an error as traits are invariant.
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>)
-> Box<dyn Get<&'max i32>>
where 'max : 'min
{
v //~ ERROR mismatched types
v
//[base]~^ ERROR mismatched types
//[nll]~^^ ERROR lifetime may not live long enough
}
fn main() { }

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/variance-invariant-arg-trait-match.rs:10:5
--> $DIR/variance-covariant-arg-trait-match.rs:18:5
|
LL | impls_get::<G,&'min i32>()
| ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -7,18 +7,18 @@ LL | impls_get::<G,&'min i32>()
= note: expected type `Get<&'min i32>`
found type `Get<&'max i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-invariant-arg-trait-match.rs:7:21
--> $DIR/variance-covariant-arg-trait-match.rs:14:21
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-invariant-arg-trait-match.rs:7:27
--> $DIR/variance-covariant-arg-trait-match.rs:14:27
|
LL | fn get_min_from_max<'min, 'max, G>()
| ^^^^
error[E0308]: mismatched types
--> $DIR/variance-invariant-arg-trait-match.rs:16:5
--> $DIR/variance-covariant-arg-trait-match.rs:26:5
|
LL | impls_get::<G,&'max i32>()
| ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@ -26,12 +26,12 @@ LL | impls_get::<G,&'max i32>()
= note: expected type `Get<&'max i32>`
found type `Get<&'min i32>`
note: the lifetime `'min` as defined here...
--> $DIR/variance-invariant-arg-trait-match.rs:13:21
--> $DIR/variance-covariant-arg-trait-match.rs:23:21
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^
note: ...does not necessarily outlive the lifetime `'max` as defined here
--> $DIR/variance-invariant-arg-trait-match.rs:13:27
--> $DIR/variance-covariant-arg-trait-match.rs:23:27
|
LL | fn get_max_from_min<'min, 'max, G>()
| ^^^^

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/variance-covariant-arg-trait-match.rs:14:5
--> $DIR/variance-covariant-arg-trait-match.rs:18:5
|
LL | fn get_min_from_max<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here
@ -12,7 +12,7 @@ LL | impls_get::<G,&'min i32>()
= help: consider adding the following bound: `'min: 'max`
error: lifetime may not live long enough
--> $DIR/variance-covariant-arg-trait-match.rs:20:5
--> $DIR/variance-covariant-arg-trait-match.rs:26:5
|
LL | fn get_max_from_min<'min, 'max, G>()
| ---- ---- lifetime `'max` defined here

Some files were not shown because too many files have changed in this diff Show more