Auto merge of #120550 - oli-obk:track_errors8, r=estebank

Continue to borrowck even if there were previous errors

but only from the perspective of the whole compiler. Individual items should not get borrowcked if their MIR is tainted by errors.

r? `@estebank` `@nnethercote`
This commit is contained in:
bors 2024-02-08 10:05:39 +00:00
commit af88f7db51
214 changed files with 3287 additions and 685 deletions

View File

@ -111,14 +111,16 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
let (input_body, promoted) = tcx.mir_promoted(def);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
if input_body.borrow().should_skip() {
debug!("Skipping borrowck because of injected body");
let input_body: &Body<'_> = &input_body.borrow();
if input_body.should_skip() || input_body.tainted_by_errors.is_some() {
debug!("Skipping borrowck because of injected body or tainted body");
// Let's make up a borrowck result! Fun times!
let result = BorrowCheckResult {
concrete_opaque_types: FxIndexMap::default(),
closure_requirements: None,
used_mut_upvars: SmallVec::new(),
tainted_by_errors: None,
tainted_by_errors: input_body.tainted_by_errors,
};
return tcx.arena.alloc(result);
}
@ -127,7 +129,6 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
let infcx =
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build();
let input_body: &Body<'_> = &input_body.borrow();
let promoted: &IndexSlice<_, _> = &promoted.borrow();
let opt_closure_req = do_mir_borrowck(&infcx, input_body, promoted, None).0;
debug!("mir_borrowck done");

View File

@ -163,10 +163,6 @@ impl Lifetime {
(LifetimeSuggestionPosition::Normal, self.ident.span)
}
}
pub fn is_static(&self) -> bool {
self.res == LifetimeName::Static
}
}
/// A `Path` is essentially Rust's notion of a name; for instance,

View File

@ -12,7 +12,7 @@ use crate::astconv::errors::prohibit_assoc_ty_binding;
use crate::astconv::generics::{check_generic_arg_count, create_args_for_parent_generic_args};
use crate::bounds::Bounds;
use crate::collect::HirPlaceholderCollector;
use crate::errors::{AmbiguousLifetimeBound, TypeofReservedKeywordUsed};
use crate::errors::AmbiguousLifetimeBound;
use crate::middle::resolve_bound_vars as rbv;
use crate::require_c_abi_if_c_variadic;
use rustc_ast::TraitObjectSyntax;
@ -30,8 +30,8 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::ObligationCause;
use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::ty::{
self, Const, GenericArgKind, GenericArgsRef, GenericParamDefKind, IsSuggestable, ParamEnv, Ty,
TyCtxt, TypeVisitableExt,
self, Const, GenericArgKind, GenericArgsRef, GenericParamDefKind, ParamEnv, Ty, TyCtxt,
TypeVisitableExt,
};
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc_span::edit_distance::find_best_match_for_name;
@ -2539,21 +2539,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
Ty::new_array_with_const_len(tcx, self.ast_ty_to_ty(ty), length)
}
hir::TyKind::Typeof(e) => {
let ty_erased = tcx.type_of(e.def_id).instantiate_identity();
let ty = tcx.fold_regions(ty_erased, |r, _| {
if r.is_erased() { tcx.lifetimes.re_static } else { r }
});
let span = ast_ty.span;
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) {
(ty, Some((span, Applicability::MachineApplicable)))
} else {
(ty, None)
};
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
ty
}
hir::TyKind::Typeof(e) => tcx.type_of(e.def_id).instantiate_identity(),
hir::TyKind::Infer => {
// Infer also appears as the type of arguments or return
// values in an ExprKind::Closure, or as

View File

@ -9,6 +9,8 @@ use rustc_middle::ty::{self, ImplTraitInTraitData, IsSuggestable, Ty, TyCtxt, Ty
use rustc_span::symbol::Ident;
use rustc_span::{Span, DUMMY_SP};
use crate::errors::TypeofReservedKeywordUsed;
use super::bad_placeholder;
use super::ItemCtxt;
pub use opaque::test_opaque_hidden_types;
@ -39,8 +41,18 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
{
return tcx.types.usize;
}
Node::Ty(&hir::Ty { kind: TyKind::Typeof(ref e), .. }) if e.hir_id == hir_id => {
return tcx.typeck(def_id).node_type(e.hir_id);
Node::Ty(&hir::Ty { kind: TyKind::Typeof(ref e), span, .. }) if e.hir_id == hir_id => {
let ty = tcx.typeck(def_id).node_type(e.hir_id);
let ty = tcx.fold_regions(ty, |r, _| {
if r.is_erased() { ty::Region::new_error_misc(tcx) } else { r }
});
let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) {
(ty, Some((span, Applicability::MachineApplicable)))
} else {
(ty, None)
};
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
return ty;
}
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })

View File

@ -209,7 +209,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
tcx.ensure().check_unused_traits(());
if let Some(reported) = tcx.dcx().has_errors() { Err(reported) } else { Ok(()) }
Ok(())
}
/// A quasi-deprecated helper used in rustdoc and clippy to get

View File

@ -666,7 +666,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
let yield_ty = args.yield_ty();
let return_ty = args.return_ty();
(
vec![closure_ty, args.resume_ty()],
vec![closure_ty, resume_ty],
return_ty,
Some(Box::new(CoroutineInfo::initial(
tcx.coroutine_kind(def_id).unwrap(),
@ -675,8 +675,23 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
))),
)
}
_ => {
span_bug!(span, "expected type of closure body to be a closure or coroutine");
ty::CoroutineClosure(did, _args) => {
// FIXME(async_closures): Recover the proper error signature
let inputs = tcx
.closure_user_provided_sig(did.expect_local())
.value
.skip_binder()
.inputs();
let err = Ty::new_error(tcx, guar);
(inputs.iter().map(|_| err).collect(), err, None)
}
ty::Error(_) => (vec![closure_ty, closure_ty], closure_ty, None),
kind => {
span_bug!(
span,
"expected type of closure body to be a closure or coroutine, got {kind:?}"
);
}
}
}

View File

@ -655,7 +655,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let drops = if destination.is_some() {
&mut self.scopes.breakable_scopes[break_index].break_drops
} else {
self.scopes.breakable_scopes[break_index].continue_drops.as_mut().unwrap()
let Some(drops) = self.scopes.breakable_scopes[break_index].continue_drops.as_mut()
else {
self.tcx.dcx().span_delayed_bug(
source_info.span,
"unlabelled `continue` within labelled block",
);
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
return self.cfg.start_new_block().unit();
};
drops
};
let drop_idx = self.scopes.scopes[scope_index + 1..]

View File

@ -59,6 +59,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
ty::Closure(..) => Abi::RustCall,
ty::CoroutineClosure(..) => Abi::RustCall,
ty::Coroutine(..) => Abi::Rust,
ty::Error(_) => return false,
_ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty),
};
let body_can_unwind = layout::fn_can_unwind(tcx, Some(def_id), body_abi);

View File

@ -2911,12 +2911,22 @@ impl<'a> Parser<'a> {
Ok(arm) => arms.push(arm),
Err(e) => {
// Recover by skipping to the end of the block.
e.emit();
let guar = e.emit();
self.recover_stmt();
let span = lo.to(self.token.span);
if self.token == token::CloseDelim(Delimiter::Brace) {
self.bump();
}
// Always push at least one arm to make the match non-empty
arms.push(Arm {
attrs: Default::default(),
pat: self.mk_pat(span, ast::PatKind::Err(guar)),
guard: None,
body: Some(self.mk_expr_err(span)),
span,
id: DUMMY_NODE_ID,
is_placeholder: false,
});
return Ok(self.mk_expr_with_attrs(
span,
ExprKind::Match(scrutinee, arms),

View File

@ -123,6 +123,7 @@ enum LiveNodeKind {
VarDefNode(Span, HirId),
ClosureNode,
ExitNode,
ErrNode,
}
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
@ -133,6 +134,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
VarDefNode(s, _) => format!("Var def node [{}]", sm.span_to_diagnostic_string(s)),
ClosureNode => "Closure node".to_owned(),
ExitNode => "Exit node".to_owned(),
ErrNode => "Error node".to_owned(),
}
}
@ -967,10 +969,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// Now that we know the label we're going to,
// look it up in the continue loop nodes table
self.cont_ln
.get(&sc)
.cloned()
.unwrap_or_else(|| span_bug!(expr.span, "continue to unknown label"))
self.cont_ln.get(&sc).cloned().unwrap_or_else(|| {
self.ir.tcx.dcx().span_delayed_bug(expr.span, "continue to unknown label");
self.ir.add_live_node(ErrNode)
})
}
hir::ExprKind::Assign(ref l, ref r, _) => {

View File

@ -176,7 +176,7 @@ fn check_fn_inner<'tcx>(
_ => None,
});
for bound in lifetimes {
if !bound.is_static() && !bound.is_elided() {
if bound.res != LifetimeName::Static && !bound.is_elided() {
return;
}
}

View File

@ -1,4 +1,7 @@
// revisions:cfail1
#![allow(unused_variables)]
struct S<T, const N: usize>([T; N]);
fn f<T, const N: usize>(x: T) -> S<T, {N}> { panic!() }

View File

@ -1,6 +1,6 @@
// revisions: cfail
#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused_braces)]
#![allow(incomplete_features, unused_braces, unused_variables)]
trait Delegates<T> {}

View File

@ -6,6 +6,7 @@
// [cfail2] compile-flags: -Z query-dep-graph -Z assert-incr-state=loaded
#![feature(rustc_attrs)]
#![allow(unused_variables)]
#[cfg(rpass1)]
pub struct X {

View File

@ -6,8 +6,8 @@ LL | y: (typeof("hey"),),
|
help: consider replacing `typeof(...)` with an actual type
|
LL | y: (&'static str,),
| ~~~~~~~~~~~~
LL | y: (&str,),
| ~~~~
error: aborting due to 1 previous error

View File

@ -1,5 +1,5 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:27:15
--> $DIR/bad-template.rs:30:15
|
LL | asm!("{}");
| ^^ from here
@ -7,7 +7,7 @@ LL | asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:29:15
--> $DIR/bad-template.rs:32:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:29:21
--> $DIR/bad-template.rs:32:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:32:16
--> $DIR/bad-template.rs:35:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:34:15
--> $DIR/bad-template.rs:37:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:34:20
--> $DIR/bad-template.rs:37:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:34:20
--> $DIR/bad-template.rs:37:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:37:15
--> $DIR/bad-template.rs:40:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:37:21
--> $DIR/bad-template.rs:40:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:44:15
--> $DIR/bad-template.rs:47:15
|
LL | asm!("{}", in("x0") foo);
| ^^ ------------ explicit register argument
@ -77,24 +77,24 @@ LL | asm!("{}", in("x0") foo);
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:44:20
--> $DIR/bad-template.rs:47:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:44:20
--> $DIR/bad-template.rs:47:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:46:17
--> $DIR/bad-template.rs:49:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:49:18
--> $DIR/bad-template.rs:52:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:55:14
--> $DIR/bad-template.rs:58:14
|
LL | global_asm!("{}");
| ^^ from here
@ -112,7 +112,7 @@ LL | global_asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:57:14
--> $DIR/bad-template.rs:60:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:57:20
--> $DIR/bad-template.rs:60:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:60:15
--> $DIR/bad-template.rs:63:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:62:14
--> $DIR/bad-template.rs:65:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:62:19
--> $DIR/bad-template.rs:65:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:62:19
--> $DIR/bad-template.rs:65:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:65:14
--> $DIR/bad-template.rs:68:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:65:20
--> $DIR/bad-template.rs:68:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:68:16
--> $DIR/bad-template.rs:71:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:70:17
--> $DIR/bad-template.rs:73:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:46:15
--> $DIR/bad-template.rs:49:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument

View File

@ -21,6 +21,9 @@ macro_rules! global_asm {
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
fn main() {
let mut foo = 0;
unsafe {

View File

@ -1,5 +1,5 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:27:15
--> $DIR/bad-template.rs:30:15
|
LL | asm!("{}");
| ^^ from here
@ -7,7 +7,7 @@ LL | asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:29:15
--> $DIR/bad-template.rs:32:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
@ -15,7 +15,7 @@ LL | asm!("{1}", in(reg) foo);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:29:21
--> $DIR/bad-template.rs:32:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
@ -23,13 +23,13 @@ LL | asm!("{1}", in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:32:16
--> $DIR/bad-template.rs:35:16
|
LL | asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:34:15
--> $DIR/bad-template.rs:37:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
@ -38,13 +38,13 @@ LL | asm!("{}", a = in(reg) foo);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:34:20
--> $DIR/bad-template.rs:37:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:34:20
--> $DIR/bad-template.rs:37:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -52,7 +52,7 @@ LL | asm!("{}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:37:15
--> $DIR/bad-template.rs:40:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
@ -60,7 +60,7 @@ LL | asm!("{1}", a = in(reg) foo);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:37:21
--> $DIR/bad-template.rs:40:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
@ -68,7 +68,7 @@ LL | asm!("{1}", a = in(reg) foo);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:41:15
--> $DIR/bad-template.rs:44:15
|
LL | asm!("{}", in("eax") foo);
| ^^ ------------- explicit register argument
@ -77,24 +77,24 @@ LL | asm!("{}", in("eax") foo);
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:41:20
--> $DIR/bad-template.rs:44:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:41:20
--> $DIR/bad-template.rs:44:20
|
LL | asm!("{}", in("eax") foo);
| ^^^^^^^^^^^^^
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:46:17
--> $DIR/bad-template.rs:49:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:49:18
--> $DIR/bad-template.rs:52:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -104,7 +104,7 @@ LL | asm!("", in(reg) 0, in(reg) 1);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:55:14
--> $DIR/bad-template.rs:58:14
|
LL | global_asm!("{}");
| ^^ from here
@ -112,7 +112,7 @@ LL | global_asm!("{}");
= note: no arguments were given
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:57:14
--> $DIR/bad-template.rs:60:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
@ -120,7 +120,7 @@ LL | global_asm!("{1}", const FOO);
= note: there is 1 argument
error: argument never used
--> $DIR/bad-template.rs:57:20
--> $DIR/bad-template.rs:60:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
@ -128,13 +128,13 @@ LL | global_asm!("{1}", const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
error: there is no argument named `a`
--> $DIR/bad-template.rs:60:15
--> $DIR/bad-template.rs:63:15
|
LL | global_asm!("{a}");
| ^
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:62:14
--> $DIR/bad-template.rs:65:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
@ -143,13 +143,13 @@ LL | global_asm!("{}", a = const FOO);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:62:19
--> $DIR/bad-template.rs:65:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^
error: named argument never used
--> $DIR/bad-template.rs:62:19
--> $DIR/bad-template.rs:65:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -157,7 +157,7 @@ LL | global_asm!("{}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:65:14
--> $DIR/bad-template.rs:68:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
@ -165,7 +165,7 @@ LL | global_asm!("{1}", a = const FOO);
= note: no positional arguments were given
error: named argument never used
--> $DIR/bad-template.rs:65:20
--> $DIR/bad-template.rs:68:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
@ -173,13 +173,13 @@ LL | global_asm!("{1}", a = const FOO);
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
error: asm template modifier must be a single character
--> $DIR/bad-template.rs:68:16
--> $DIR/bad-template.rs:71:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^
error: multiple unused asm arguments
--> $DIR/bad-template.rs:70:17
--> $DIR/bad-template.rs:73:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:46:15
--> $DIR/bad-template.rs:49:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument

View File

@ -81,13 +81,15 @@ pub extern "C" fn missing_assembly() {
#[naked]
pub extern "C" fn too_many_asm_blocks() {
//~^ ERROR naked functions must contain a single asm block
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("", options(noreturn));
unsafe {
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("");
//~^ ERROR asm in naked functions must use `noreturn` option
asm!("", options(noreturn));
}
}
pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {

View File

@ -1,23 +1,23 @@
error: asm with the `pure` option must have at least one output
--> $DIR/naked-functions.rs:111:14
--> $DIR/naked-functions.rs:113:14
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
error: this is a user specified error
--> $DIR/naked-functions.rs:203:5
--> $DIR/naked-functions.rs:205:5
|
LL | compile_error!("this is a user specified error")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this is a user specified error
--> $DIR/naked-functions.rs:209:5
--> $DIR/naked-functions.rs:211:5
|
LL | compile_error!("this is a user specified error");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: asm template must be a string literal
--> $DIR/naked-functions.rs:216:10
--> $DIR/naked-functions.rs:218:10
|
LL | asm!(invalid_syntax)
| ^^^^^^^^^^^^^^
@ -142,37 +142,37 @@ LL | pub extern "C" fn missing_assembly() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0787]: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:84:5
--> $DIR/naked-functions.rs:85:9
|
LL | asm!("");
| ^^^^^^^^
LL | asm!("");
| ^^^^^^^^
|
help: consider specifying that the asm block is responsible for returning from the function
|
LL | asm!("", options(noreturn));
| +++++++++++++++++++
LL | asm!("", options(noreturn));
| +++++++++++++++++++
error[E0787]: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:86:5
--> $DIR/naked-functions.rs:87:9
|
LL | asm!("");
| ^^^^^^^^
LL | asm!("");
| ^^^^^^^^
|
help: consider specifying that the asm block is responsible for returning from the function
|
LL | asm!("", options(noreturn));
| +++++++++++++++++++
LL | asm!("", options(noreturn));
| +++++++++++++++++++
error[E0787]: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:88:5
--> $DIR/naked-functions.rs:89:9
|
LL | asm!("");
| ^^^^^^^^
LL | asm!("");
| ^^^^^^^^
|
help: consider specifying that the asm block is responsible for returning from the function
|
LL | asm!("", options(noreturn));
| +++++++++++++++++++
LL | asm!("", options(noreturn));
| +++++++++++++++++++
error[E0787]: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:82:1
@ -180,17 +180,17 @@ error[E0787]: naked functions must contain a single asm block
LL | pub extern "C" fn too_many_asm_blocks() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | asm!("");
| -------- multiple asm blocks are unsupported in naked functions
LL | asm!("");
| -------- multiple asm blocks are unsupported in naked functions
LL |
LL | asm!("");
| -------- multiple asm blocks are unsupported in naked functions
LL | asm!("");
| -------- multiple asm blocks are unsupported in naked functions
LL |
LL | asm!("", options(noreturn));
| --------------------------- multiple asm blocks are unsupported in naked functions
LL | asm!("", options(noreturn));
| --------------------------- multiple asm blocks are unsupported in naked functions
error: referencing function parameters is not allowed in naked functions
--> $DIR/naked-functions.rs:97:11
--> $DIR/naked-functions.rs:99:11
|
LL | *&y
| ^
@ -198,7 +198,7 @@ LL | *&y
= help: follow the calling convention in asm block to use parameters
error[E0787]: naked functions must contain a single asm block
--> $DIR/naked-functions.rs:95:5
--> $DIR/naked-functions.rs:97:5
|
LL | pub extern "C" fn inner(y: usize) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -207,19 +207,19 @@ LL | *&y
| --- non-asm is unsupported in naked functions
error[E0787]: asm options unsupported in naked functions: `nomem`, `preserves_flags`
--> $DIR/naked-functions.rs:105:5
--> $DIR/naked-functions.rs:107:5
|
LL | asm!("", options(nomem, preserves_flags, noreturn));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0787]: asm options unsupported in naked functions: `nostack`, `pure`, `readonly`
--> $DIR/naked-functions.rs:111:5
--> $DIR/naked-functions.rs:113:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0787]: asm in naked functions must use `noreturn` option
--> $DIR/naked-functions.rs:111:5
--> $DIR/naked-functions.rs:113:5
|
LL | asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -230,13 +230,13 @@ LL | asm!("", options(noreturn), options(readonly, nostack), options(pure));
| +++++++++++++++++++
error[E0787]: asm options unsupported in naked functions: `may_unwind`
--> $DIR/naked-functions.rs:119:5
--> $DIR/naked-functions.rs:121:5
|
LL | asm!("", options(noreturn, may_unwind));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:124:1
--> $DIR/naked-functions.rs:126:1
|
LL | pub unsafe fn default_abi() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -244,43 +244,43 @@ LL | pub unsafe fn default_abi() {
= note: `#[warn(undefined_naked_function_abi)]` on by default
warning: Rust ABI is unsupported in naked functions
--> $DIR/naked-functions.rs:130:1
--> $DIR/naked-functions.rs:132:1
|
LL | pub unsafe fn rust_abi() {
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:170:1
--> $DIR/naked-functions.rs:172:1
|
LL | #[inline]
| ^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:177:1
--> $DIR/naked-functions.rs:179:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:184:1
--> $DIR/naked-functions.rs:186:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:191:1
--> $DIR/naked-functions.rs:193:1
|
LL | #[inline]
| ^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:193:1
--> $DIR/naked-functions.rs:195:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
error: naked functions cannot be inlined
--> $DIR/naked-functions.rs:195:1
--> $DIR/naked-functions.rs:197:1
|
LL | #[inline(never)]
| ^^^^^^^^^^^^^^^^

View File

@ -94,10 +94,18 @@ pub fn call_bar() {
pub fn call_tuple_one() {
tuple_one::<Tuple>();
//~^ ERROR not general enough
//~| ERROR not general enough
//~| ERROR not general enough
//~| ERROR not general enough
}
pub fn call_tuple_two() {
tuple_two::<Tuple>();
//~^ ERROR not general enough
//~| ERROR not general enough
//~| ERROR mismatched types
//~| ERROR mismatched types
}
pub fn call_tuple_three() {
@ -106,6 +114,8 @@ pub fn call_tuple_three() {
pub fn call_tuple_four() {
tuple_four::<Tuple>();
//~^ ERROR not general enough
//~| ERROR not general enough
}
fn main() {}

View File

@ -42,6 +42,113 @@ LL | where
LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
| ^^^^^^^^^^^^^ required by this bound in `bar`
error: aborting due to 2 previous errors
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
For more information about this error, try `rustc --explain E0271`.
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:96:5
|
LL | tuple_one::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:104:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:104:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
--> $DIR/associated-types-eq-hr.rs:104:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&'x _`
found reference `&'y _`
note: the lifetime requirement is introduced here
--> $DIR/associated-types-eq-hr.rs:66:53
|
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
| ^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/associated-types-eq-hr.rs:104:5
|
LL | tuple_two::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&'x _`
found reference `&'y _`
note: the lifetime requirement is introduced here
--> $DIR/associated-types-eq-hr.rs:66:53
|
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
| ^^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:116:5
|
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
error: implementation of `TheTrait` is not general enough
--> $DIR/associated-types-eq-hr.rs:116:5
|
LL | tuple_four::<Tuple>();
| ^^^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.

View File

@ -14,6 +14,7 @@ async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
fn foo(x: NotSync) -> impl Future + Send {
//~^ ERROR `*mut ()` cannot be shared between threads safely
//~| ERROR `*mut ()` cannot be shared between threads safely
async move {
baz(|| async {
foo(x.clone());

View File

@ -4,7 +4,7 @@ error[E0277]: `*mut ()` cannot be shared between threads safely
LL | fn foo(x: NotSync) -> impl Future + Send {
| ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely
|
= help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:17:5: 21:6}: Send`
= help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 22:6}: Send`
note: required because it appears within the type `PhantomData<*mut ()>`
--> $SRC_DIR/core/src/marker.rs:LL:COL
note: required because it appears within the type `NotSync`
@ -14,7 +14,7 @@ LL | struct NotSync(PhantomData<*mut ()>);
| ^^^^^^^
= note: required for `&NotSync` to implement `Send`
note: required because it's used within this closure
--> $DIR/issue-70935-complex-spans.rs:18:13
--> $DIR/issue-70935-complex-spans.rs:19:13
|
LL | baz(|| async {
| ^^
@ -27,7 +27,7 @@ LL | | }
| |_^
= note: required because it captures the following types: `impl Future<Output = ()>`
note: required because it's used within this `async` block
--> $DIR/issue-70935-complex-spans.rs:17:5
--> $DIR/issue-70935-complex-spans.rs:18:5
|
LL | / async move {
LL | | baz(|| async {
@ -36,6 +36,45 @@ LL | | }).await;
LL | | }
| |_____^
error: aborting due to 1 previous error
error[E0277]: `*mut ()` cannot be shared between threads safely
--> $DIR/issue-70935-complex-spans.rs:15:23
|
LL | fn foo(x: NotSync) -> impl Future + Send {
| ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely
|
= help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`, which is required by `{async block@$DIR/issue-70935-complex-spans.rs:18:5: 22:6}: Send`
note: required because it appears within the type `PhantomData<*mut ()>`
--> $SRC_DIR/core/src/marker.rs:LL:COL
note: required because it appears within the type `NotSync`
--> $DIR/issue-70935-complex-spans.rs:9:8
|
LL | struct NotSync(PhantomData<*mut ()>);
| ^^^^^^^
= note: required for `&NotSync` to implement `Send`
note: required because it's used within this closure
--> $DIR/issue-70935-complex-spans.rs:19:13
|
LL | baz(|| async {
| ^^
note: required because it's used within this `async` fn body
--> $DIR/issue-70935-complex-spans.rs:12:67
|
LL | async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
| ___________________________________________________________________^
LL | | }
| |_^
= note: required because it captures the following types: `impl Future<Output = ()>`
note: required because it's used within this `async` block
--> $DIR/issue-70935-complex-spans.rs:18:5
|
LL | / async move {
LL | | baz(|| async {
LL | | foo(x.clone());
LL | | }).await;
LL | | }
| |_____^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -6,6 +6,7 @@ auto trait Magic : Sized where Option<Self> : Magic {} //~ ERROR E0568
impl<T:Magic> Magic for T {}
fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
//~^ ERROR: use of moved value
#[derive(Debug)]
struct NoClone;

View File

@ -14,6 +14,21 @@ LL | auto trait Magic : Sized where Option<Self> : Magic {}
| |
| auto traits cannot have super traits or lifetime bounds
error: aborting due to 2 previous errors
error[E0382]: use of moved value: `x`
--> $DIR/typeck-auto-trait-no-supertraits-2.rs:8:41
|
LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
| - - ^ value used here after move
| | |
| | value moved here
| move occurs because `x` has type `T`, which does not implement the `Copy` trait
|
help: consider further restricting this bound
|
LL | fn copy<T: Magic + Copy>(x: T) -> (T, T) { (x, x) }
| ++++++
For more information about this error, try `rustc --explain E0568`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0382, E0568.
For more information about an error, try `rustc --explain E0382`.

View File

@ -1,6 +1,6 @@
fn foo(s: &i32) -> &i32 {
let xs;
xs
xs //~ ERROR: isn't initialized
}
fn main() {
let y;

View File

@ -22,7 +22,20 @@ LL | assert_eq!(foo, y);
= help: use parentheses to call this function: `foo(/* &i32 */)`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error[E0381]: used binding `xs` isn't initialized
--> $DIR/issue-77910-1.rs:3:5
|
LL | let xs;
| -- binding declared here but left uninitialized
LL | xs
| ^^ `xs` used here but it isn't initialized
|
help: consider assigning a value
|
LL | let xs = todo!();
| +++++++++
Some errors have detailed explanations: E0277, E0369.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0369, E0381.
For more information about an error, try `rustc --explain E0277`.

View File

@ -1,6 +1,6 @@
fn foo(s: &i32) -> &i32 {
let xs;
xs
xs //~ ERROR: isn't initialized
}
fn main() {
let y;

View File

@ -11,6 +11,20 @@ help: use parentheses to call this function
LL | if foo(/* &i32 */) == y {}
| ++++++++++++
error: aborting due to 1 previous error
error[E0381]: used binding `xs` isn't initialized
--> $DIR/issue-77910-2.rs:3:5
|
LL | let xs;
| -- binding declared here but left uninitialized
LL | xs
| ^^ `xs` used here but it isn't initialized
|
help: consider assigning a value
|
LL | let xs = todo!();
| +++++++++
For more information about this error, try `rustc --explain E0369`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0369, E0381.
For more information about an error, try `rustc --explain E0369`.

View File

@ -1,5 +1,5 @@
trait Noisy {
fn speak(&self);
fn speak(&mut self);
}
struct Cat {
@ -10,7 +10,7 @@ struct Cat {
}
impl Cat {
pub fn eat(&self) -> bool {
pub fn eat(&mut self) -> bool {
if self.how_hungry > 0 {
println!("OM NOM NOM");
self.how_hungry -= 2;
@ -24,12 +24,12 @@ impl Cat {
}
impl Noisy for Cat {
fn speak(&self) { self.meow(); }
fn speak(&mut self) { self.meow(); }
}
impl Cat {
fn meow(&self) {
fn meow(&mut self) {
println!("Meow");
self.meows += 1;
if self.meows % 5 == 0 {

View File

@ -15,6 +15,6 @@ fn foo () -> impl FnMut()->() {
c
}
fn main() {
let c = foo();
let mut c = foo();
c();
}

View File

@ -24,4 +24,5 @@ fn main() {
//~| ERROR `'_` cannot be used here
let _ = for<'a> |x: &()| -> &'a () { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here
let _ = for<'a> |x: &'a ()| -> &() { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here
//~^ ERROR: lifetime may not live long enough
}

View File

@ -102,6 +102,15 @@ LL | let _ = for<'a> |x: &'a _, y, z: _| -> &'a _ {
| |
| `for<...>` is here
error: aborting due to 15 previous errors
error: lifetime may not live long enough
--> $DIR/implicit-stuff.rs:26:42
|
LL | let _ = for<'a> |x: &'a ()| -> &() { x };
| -- - ^ returning this value requires that `'a` must outlive `'1`
| | |
| | let's call the lifetime of this reference `'1`
| lifetime `'a` defined here
error: aborting due to 16 previous errors
For more information about this error, try `rustc --explain E0637`.

View File

@ -7,13 +7,13 @@ struct X(Y);
struct Y;
fn consume_fnmut(f: &dyn FnMut()) {
fn consume_fnmut(f: &mut dyn FnMut()) {
f();
}
fn move_into_fnmut() {
let x = move_into_fnmut();
consume_fnmut(&|| {
consume_fnmut(&mut || {
let Either::One(_t) = x; //~ ERROR mismatched types
let Either::Two(_t) = x; //~ ERROR mismatched types
});

View File

@ -2,8 +2,11 @@
// needs-llvm-components: arm
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[no_mangle]
#[cmse_nonsecure_entry]

View File

@ -1,5 +1,5 @@
error[E0776]: `#[cmse_nonsecure_entry]` requires C ABI
--> $DIR/wrong-abi.rs:9:1
--> $DIR/wrong-abi.rs:12:1
|
LL | #[cmse_nonsecure_entry]
| ^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -13,6 +13,7 @@ fn consume<T: 'static>(_val: T)
where
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
//~^ overly complex generic constant
//~| ERROR: cannot call
{
}
@ -20,6 +21,7 @@ fn test<T: 'static>()
where
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
//~^ overly complex generic constant
//~| ERROR: cannot call
{
}

View File

@ -10,7 +10,7 @@ LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
= note: this operation may be supported in the future
error: overly complex generic constant
--> $DIR/issue-90318.rs:21:8
--> $DIR/issue-90318.rs:22:8
|
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
@ -20,5 +20,28 @@ LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to 2 previous errors
error[E0015]: cannot call non-const operator in constants
--> $DIR/issue-90318.rs:14:10
|
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error[E0015]: cannot call non-const operator in constants
--> $DIR/issue-90318.rs:22:10
|
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0015`.

View File

@ -13,5 +13,37 @@ LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: aborting due to 2 previous errors
error[E0391]: cycle detected when evaluating type-level constant
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires caching mir of `bug::{constant#0}` for CTFE...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires elaborating drops for `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires borrow-checking `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `Binder { value: ConstEvaluatable(UnevaluatedConst { def: DefId(0:8 ~ late_bound_in_return_issue_77357[9394]::bug::{constant#0}), args: [T/#0] }: usize), bound_vars: [] }`...
= note: ...which again requires evaluating type-level constant, completing the cycle
= note: cycle used when normalizing `&dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]>`
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0391`.

View File

@ -3,6 +3,9 @@
const _: () = {
for _ in 0..5 {}
//~^ error: `for` is not allowed in a `const`
//~| ERROR: cannot convert
//~| ERROR: cannot call
//~| ERROR: mutable references
};
fn main() {}

View File

@ -8,6 +8,37 @@ LL | for _ in 0..5 {}
= help: add `#![feature(const_for)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
--> $DIR/const-for-feature-gate.rs:4:14
|
LL | for _ in 0..5 {}
| ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0658`.
error[E0658]: mutable references are not allowed in constants
--> $DIR/const-for-feature-gate.rs:4:14
|
LL | for _ in 0..5 {}
| ^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/const-for-feature-gate.rs:4:14
|
LL | for _ in 0..5 {}
| ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View File

@ -3,6 +3,8 @@
const fn t() -> Option<()> {
Some(())?;
//~^ error: `?` is not allowed in a `const fn`
//~| ERROR: cannot convert
//~| ERROR: cannot determine
None
}

View File

@ -8,6 +8,29 @@ LL | Some(())?;
= help: add `#![feature(const_try)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0015]: `?` cannot determine the branch of `Option<()>` in constant functions
--> $DIR/const-try-feature-gate.rs:4:5
|
LL | Some(())?;
| ^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0658`.
error[E0015]: `?` cannot convert from residual of `Option<()>` in constant functions
--> $DIR/const-try-feature-gate.rs:4:5
|
LL | Some(())?;
| ^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View File

@ -51,10 +51,16 @@ const _: i32 = {
let mut x = 0;
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
//~^ ERROR: cannot call
//~| ERROR: mutable references
//~| ERROR: cannot convert
x += i;
}
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
//~^ ERROR: cannot call
//~| ERROR: mutable references
//~| ERROR: cannot convert
x += i;
}

View File

@ -2,6 +2,9 @@ error[E0658]: `for` is not allowed in a `const`
--> $DIR/loop.rs:53:5
|
LL | / for i in 0..4 {
LL | |
LL | |
LL | |
LL | | x += i;
LL | | }
| |_____^
@ -11,9 +14,12 @@ LL | | }
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `for` is not allowed in a `const`
--> $DIR/loop.rs:57:5
--> $DIR/loop.rs:60:5
|
LL | / for i in 0..4 {
LL | |
LL | |
LL | |
LL | | x += i;
LL | | }
| |_____^
@ -22,6 +28,67 @@ LL | | }
= help: add `#![feature(const_for)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
--> $DIR/loop.rs:53:14
|
LL | for i in 0..4 {
| ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0658`.
error[E0658]: mutable references are not allowed in constants
--> $DIR/loop.rs:53:14
|
LL | for i in 0..4 {
| ^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/loop.rs:53:14
|
LL | for i in 0..4 {
| ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
--> $DIR/loop.rs:60:14
|
LL | for i in 0..4 {
| ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constants
--> $DIR/loop.rs:60:14
|
LL | for i in 0..4 {
| ^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/loop.rs:60:14
|
LL | for i in 0..4 {
| ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View File

@ -4,6 +4,8 @@
const fn opt() -> Option<i32> {
let x = Some(2);
x?; //~ ERROR `?` is not allowed in a `const fn`
//~^ ERROR: cannot convert
//~| ERROR: cannot determine
None
}

View File

@ -8,6 +8,29 @@ LL | x?;
= help: add `#![feature(const_try)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0015]: `?` cannot determine the branch of `Option<i32>` in constant functions
--> $DIR/try.rs:6:5
|
LL | x?;
| ^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0658`.
error[E0015]: `?` cannot convert from residual of `Option<i32>` in constant functions
--> $DIR/try.rs:6:5
|
LL | x?;
| ^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View File

@ -74,6 +74,100 @@ LL | T: ~const FnMut<()> + ~const Destruct,
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 11 previous errors
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:17:5
|
LL | f()
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
help: consider further restricting this bound
|
LL | T: ~const Fn<()> + ~const Destruct + ~const std::ops::Fn<()>,
| +++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0635`.
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:13:23
|
LL | const fn tester_fn<T>(f: T) -> T::Output
| ^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:24:5
|
LL | f()
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
help: consider further restricting this bound
|
LL | T: ~const FnMut<()> + ~const Destruct + ~const std::ops::FnMut<()>,
| ++++++++++++++++++++++++++++
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:20:27
|
LL | const fn tester_fn_mut<T>(mut f: T) -> T::Output
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:31:5
|
LL | f()
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
help: consider further restricting this bound
|
LL | T: ~const FnOnce<()> + ~const std::ops::FnOnce<()>,
| +++++++++++++++++++++++++++++
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:34:21
|
LL | const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output)
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:48:25
|
LL | const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output)
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0015]: cannot call non-const operator in constants
--> $DIR/fn_trait_refs.rs:72:17
|
LL | assert!(test_one == (1, 1, 1));
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error[E0015]: cannot call non-const operator in constants
--> $DIR/fn_trait_refs.rs:75:17
|
LL | assert!(test_two == (2, 2));
| ^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error: aborting due to 20 previous errors
Some errors have detailed explanations: E0015, E0493, E0635.
For more information about an error, try `rustc --explain E0015`.

View File

@ -6,26 +6,6 @@ LL | let _: &'static _ = &id(&Panic);
| |
| the destructor for this type cannot be evaluated in constants
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:11:26
|
LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:11:30
|
LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^ - temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:17:26
|
@ -68,7 +48,7 @@ LL | let _: &'static _ = &&(Panic, 0).1;
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 7 previous errors
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.

View File

@ -2,13 +2,14 @@ pub const fn id<T>(x: T) -> T { x }
pub const C: () = {
let _: &'static _ = &String::new();
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
//~| ERROR: temporary value dropped while borrowed
};
pub const _: () = {
let _: &'static _ = &id(&String::new());
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
//~| ERROR: temporary value dropped while borrowed
//~| ERROR: temporary value dropped while borrowed
};
pub const _: () = {
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
//~^ ERROR: temporary value dropped while borrowed
};

View File

@ -1,53 +1,22 @@
error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/promoted_const_call3.rs:7:30
--> $DIR/promoted_const_call3.rs:3:26
|
LL | let _: &'static _ = &String::new();
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
LL |
LL | };
| - value is dropped here
error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/promoted_const_call3.rs:8:30
|
LL | let _: &'static _ = &id(&String::new());
| ^^^^^^^^^^^^^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constants
error[E0493]: destructor of `String` cannot be evaluated at compile-time
--> $DIR/promoted_const_call3.rs:3:26
|
LL | let _: &'static _ = &String::new();
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
...
LL | };
| - value is dropped here
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:3:26
|
LL | let _: &'static _ = &String::new();
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:7:26
|
LL | let _: &'static _ = &id(&String::new());
| ---------- ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:7:30
|
LL | let _: &'static _ = &id(&String::new());
| ---------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:12:26
--> $DIR/promoted_const_call3.rs:13:26
|
LL | let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -58,7 +27,7 @@ LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:17:26
--> $DIR/promoted_const_call3.rs:18:26
|
LL | let _: &'static _ = &String::new();
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -69,7 +38,7 @@ LL | }
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:20:26
--> $DIR/promoted_const_call3.rs:21:26
|
LL | let _: &'static _ = &id(&String::new());
| ---------- ^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -80,7 +49,7 @@ LL | }
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:20:30
--> $DIR/promoted_const_call3.rs:21:30
|
LL | let _: &'static _ = &id(&String::new());
| ---------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
@ -89,7 +58,7 @@ LL | let _: &'static _ = &id(&String::new());
| type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call3.rs:24:26
--> $DIR/promoted_const_call3.rs:25:26
|
LL | let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@ -99,7 +68,7 @@ LL |
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 10 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.

View File

@ -25,9 +25,9 @@ pub const fn new_manually_drop<T>(t: T) -> std::mem::ManuallyDrop<T> {
const C: () = {
let _: &'static _ = &id(&new_string());
//~^ ERROR destructor of `String` cannot be evaluated at compile-time
//~| ERROR: temporary value dropped while borrowed
//~| ERROR: temporary value dropped while borrowed
};
const _: () = {
let _: &'static _ = &new_manually_drop(new_string());
//~^ ERROR: temporary value dropped while borrowed
};

View File

@ -6,26 +6,6 @@ LL | let _: &'static _ = &id(&new_string());
| |
| the destructor for this type cannot be evaluated in constants
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call5.rs:26:26
|
LL | let _: &'static _ = &id(&new_string());
| ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call5.rs:26:30
|
LL | let _: &'static _ = &id(&new_string());
| ----^^^^^^^^^^^^-- temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call5.rs:31:26
|
@ -68,7 +48,7 @@ LL |
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 7 previous errors
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.

View File

@ -5,7 +5,7 @@
fn main() {
match &b""[..] {
ZST => {}
ZST => {} //~ ERROR: could not evaluate constant pattern
}
}

View File

@ -7,6 +7,12 @@ LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) };
= note: source type: `usize` (word size)
= note: target type: `&[u8]` (2 * word size)
error: aborting due to 1 previous error
error: could not evaluate constant pattern
--> $DIR/transmute-size-mismatch-before-typeck.rs:8:9
|
LL | ZST => {}
| ^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0512`.

View File

@ -4,6 +4,51 @@ error[E0635]: unknown feature `const_convert`
LL | #![feature(const_convert)]
| ^^^^^^^^^^^^^
error: aborting due to 1 previous error
error[E0015]: `?` cannot determine the branch of `Result<(), ()>` in constant functions
--> $DIR/try-operator.rs:10:9
|
LL | Err(())?;
| ^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/result.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0635`.
error[E0015]: `?` cannot convert from residual of `Result<bool, ()>` in constant functions
--> $DIR/try-operator.rs:10:9
|
LL | Err(())?;
| ^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/result.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error[E0015]: `?` cannot determine the branch of `Option<()>` in constant functions
--> $DIR/try-operator.rs:18:9
|
LL | None?;
| ^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error[E0015]: `?` cannot convert from residual of `Option<()>` in constant functions
--> $DIR/try-operator.rs:18:9
|
LL | None?;
| ^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/option.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0015, E0635.
For more information about an error, try `rustc --explain E0015`.

View File

@ -4,5 +4,38 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
| ^^^^^^^^^^^^^
error: aborting due to 1 previous error
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/unstable-const-fn-in-libcore.rs:24:26
|
LL | Opt::None => f(),
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(effects)]` to the crate attributes to enable
help: consider further restricting this bound
|
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T + ~const std::ops::FnOnce<()>>(self, f: F) -> T {
| +++++++++++++++++++++++++++++
error[E0493]: destructor of `F` cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:60
|
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
| ^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0493]: destructor of `Opt<T>` cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:54
|
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
| ^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0015, E0493.
For more information about an error, try `rustc --explain E0015`.

View File

@ -8,6 +8,7 @@
match money {
v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
//~^ ERROR variable `v` is not bound in all patterns
//~| ERROR possibly-uninitialized
v => println!("Enough money {}", v),
}
}

View File

@ -7,6 +7,18 @@ LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Lon
| | pattern doesn't bind `v`
| variable not in all patterns
error: aborting due to 1 previous error
error[E0381]: used binding `v` is possibly-uninitialized
--> $DIR/tabs-trimming.rs:9:67
|
LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
| - ^ `v` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
|
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0408`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.

View File

@ -5,6 +5,7 @@ enum Foo {
mod Foo { //~ ERROR the name `Foo` is defined multiple times
pub static X: isize = 42;
fn f() { f() } // Check that this does not result in a resolution error
//~^ WARN cannot return without recursing
}
fn main() {}

View File

@ -9,6 +9,17 @@ LL | mod Foo {
|
= note: `Foo` must be defined only once in the type namespace of this module
error: aborting due to 1 previous error
warning: function cannot return without recursing
--> $DIR/enum-and-module-in-same-scope.rs:7:5
|
LL | fn f() { f() } // Check that this does not result in a resolution error
| ^^^^^^ --- recursive call site
| |
| cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0428`.

View File

@ -19,7 +19,7 @@ fn mk_unexpected_char_err<'a>() -> Option<&'a i32> {
}
fn foo<'a>(data: &mut Chars<'a>) {
bar(mk_unexpected_char_err)
bar(mk_unexpected_char_err) //~ ERROR mismatched types
}
fn bar<F>(t: F)

View File

@ -10,6 +10,21 @@ error[E0582]: binding for associated type `Item` references lifetime `'a`, which
LL | where F: for<'a> Iterator<Item=&'a i32>
| ^^^^^^^^^^^^
error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/E0582.rs:22:5
|
LL | bar(mk_unexpected_char_err)
| ^^^ one type is more general than the other
|
= note: expected enum `Option<&_>`
found enum `Option<&'a _>`
note: the lifetime requirement is introduced here
--> $DIR/E0582.rs:28:30
|
LL | where F: for<'a> Fn() -> Option<&'a i32>
| ^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0582`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0582.
For more information about an error, try `rustc --explain E0308`.

View File

@ -2,9 +2,9 @@ fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
//~^ ERROR: `'_` cannot be used here [E0637]
//~| ERROR: missing lifetime specifier
if str1.len() > str2.len() {
str1
str1 //~ ERROR: lifetime may not live long enough
} else {
str2
str2 //~ ERROR: lifetime may not live long enough
}
}

View File

@ -27,7 +27,25 @@ help: consider introducing a higher-ranked lifetime here
LL | T: for<'a> Into<&'a u32>,
| +++++++ ++
error: aborting due to 3 previous errors
error: lifetime may not live long enough
--> $DIR/E0637.rs:5:9
|
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
| - let's call the lifetime of this reference `'1`
...
LL | str1
| ^^^^ returning this value requires that `'1` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/E0637.rs:7:9
|
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
| - let's call the lifetime of this reference `'2`
...
LL | str2
| ^^^^ returning this value requires that `'2` must outlive `'static`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0106, E0637.
For more information about an error, try `rustc --explain E0106`.

View File

@ -13,7 +13,7 @@ fn _f1() {
become _g1(); //~ error: mismatched types
}
fn _g1() -> ! {
fn _g1() -> ! { //~ WARN: cannot return without recursing
become _g1();
}

View File

@ -22,6 +22,17 @@ error[E0308]: mismatched types
LL | become _g2();
| ^^^^^^^^^^^^ expected `u32`, found `u16`
error: aborting due to 3 previous errors
warning: function cannot return without recursing
--> $DIR/return-mismatches.rs:16:1
|
LL | fn _g1() -> ! {
| ^^^^^^^^^^^^^ cannot return without recursing
LL | become _g1();
| ----- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0308`.

View File

@ -6,6 +6,7 @@
fn b_ref<'a>() -> &'a bool { &true }
fn b_mut_ref<'a>() -> &'a mut bool { &mut true }
//~^ ERROR: cannot return reference to temporary
fn main() {
// This is OK:

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:18:8
--> $DIR/if-no-match-bindings.rs:19:8
|
LL | if b_ref() {}
| ^^^^^^^ expected `bool`, found `&bool`
@ -10,7 +10,7 @@ LL | if *b_ref() {}
| +
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:19:8
--> $DIR/if-no-match-bindings.rs:20:8
|
LL | if b_mut_ref() {}
| ^^^^^^^^^^^ expected `bool`, found `&mut bool`
@ -21,7 +21,7 @@ LL | if *b_mut_ref() {}
| +
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:20:8
--> $DIR/if-no-match-bindings.rs:21:8
|
LL | if &true {}
| ^^^^^ expected `bool`, found `&bool`
@ -33,7 +33,7 @@ LL + if true {}
|
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:21:8
--> $DIR/if-no-match-bindings.rs:22:8
|
LL | if &mut true {}
| ^^^^^^^^^ expected `bool`, found `&mut bool`
@ -45,7 +45,7 @@ LL + if true {}
|
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:24:11
--> $DIR/if-no-match-bindings.rs:25:11
|
LL | while b_ref() {}
| ^^^^^^^ expected `bool`, found `&bool`
@ -56,7 +56,7 @@ LL | while *b_ref() {}
| +
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:25:11
--> $DIR/if-no-match-bindings.rs:26:11
|
LL | while b_mut_ref() {}
| ^^^^^^^^^^^ expected `bool`, found `&mut bool`
@ -67,7 +67,7 @@ LL | while *b_mut_ref() {}
| +
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:26:11
--> $DIR/if-no-match-bindings.rs:27:11
|
LL | while &true {}
| ^^^^^ expected `bool`, found `&bool`
@ -79,7 +79,7 @@ LL + while true {}
|
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:27:11
--> $DIR/if-no-match-bindings.rs:28:11
|
LL | while &mut true {}
| ^^^^^^^^^ expected `bool`, found `&mut bool`
@ -90,6 +90,16 @@ LL - while &mut true {}
LL + while true {}
|
error: aborting due to 8 previous errors
error[E0515]: cannot return reference to temporary value
--> $DIR/if-no-match-bindings.rs:8:38
|
LL | fn b_mut_ref<'a>() -> &'a mut bool { &mut true }
| ^^^^^----
| | |
| | temporary value created here
| returns a reference to data owned by the current function
For more information about this error, try `rustc --explain E0308`.
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0308, E0515.
For more information about an error, try `rustc --explain E0308`.

View File

@ -13,4 +13,5 @@ extern "C" {
fn main() {
assert_eq!(FOO, 3);
//~^ ERROR extern static is unsafe
}

View File

@ -8,6 +8,15 @@ LL | #[cfg_attr(target_thread_local, thread_local)]
= help: add `#![feature(cfg_target_thread_local)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/feature-gate-cfg-target-thread-local.rs:15:16
|
LL | assert_eq!(FOO, 3);
| ^^^ use of extern static
|
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0133, E0658.
For more information about an error, try `rustc --explain E0133`.

View File

@ -1,10 +1,15 @@
#![feature(core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*; //~ custom_mir
#[custom_mir(dialect = "built")] //~ ERROR the `#[custom_mir]` attribute is just used for the Rust test suite
pub fn foo(_x: i32) -> i32 {
0
mir! {
{
Return() //~ custom_mir
}
}
}
fn main() {

View File

@ -1,5 +1,5 @@
error[E0658]: the `#[custom_mir]` attribute is just used for the Rust test suite
--> $DIR/feature-gate-custom_mir.rs:5:1
--> $DIR/feature-gate-custom_mir.rs:6:1
|
LL | #[custom_mir(dialect = "built")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,6 +7,24 @@ LL | #[custom_mir(dialect = "built")]
= help: add `#![feature(custom_mir)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0658]: use of unstable library feature 'custom_mir': MIR is an implementation detail and extremely unstable
--> $DIR/feature-gate-custom_mir.rs:4:5
|
LL | use core::intrinsics::mir::*;
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(custom_mir)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'custom_mir': MIR is an implementation detail and extremely unstable
--> $DIR/feature-gate-custom_mir.rs:10:13
|
LL | Return()
| ^^^^^^
|
= help: add `#![feature(custom_mir)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -6,12 +6,14 @@ use std::arch::asm;
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked() {
asm!("", options(noreturn))
//~^ ERROR: requires unsafe
}
#[naked]
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked_2() -> isize {
asm!("", options(noreturn))
//~^ ERROR: requires unsafe
}
fn main() {}

View File

@ -9,7 +9,7 @@ LL | #[naked]
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: the `#[naked]` attribute is an experimental feature
--> $DIR/feature-gate-naked_functions.rs:11:1
--> $DIR/feature-gate-naked_functions.rs:12:1
|
LL | #[naked]
| ^^^^^^^^
@ -18,6 +18,23 @@ LL | #[naked]
= help: add `#![feature(naked_functions)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:8:5
|
LL | asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
For more information about this error, try `rustc --explain E0658`.
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:15:5
|
LL | asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0133, E0658.
For more information about an error, try `rustc --explain E0133`.

View File

@ -8,7 +8,7 @@ fn main() {
extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change
fn atomic_fence();
}
atomic_fence();
atomic_fence(); //~ ERROR: is unsafe
42
});
}

View File

@ -7,6 +7,15 @@ LL | extern "rust-intrinsic" {
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0133]: call to unsafe function `main::atomic_fence` is unsafe and requires unsafe function or block
--> $DIR/feature-gated-feature-in-macro-arg.rs:11:9
|
LL | atomic_fence();
| ^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0133, E0658.
For more information about an error, try `rustc --explain E0133`.

View File

@ -17,10 +17,16 @@ fn fn_mut() -> _ {
//~| SUGGESTION impl FnMut(char)
//~| NOTE for more information on `Fn` traits and closure types
let x = String::new();
|c| {
//~^ HELP: consider changing this to be mutable
|c| { //~ NOTE: value captured here
x.push(c);
//~^ ERROR: does not live long enough
//~| NOTE: does not live long enough
//~| NOTE: cannot borrow as mutable
//~| ERROR: not declared as mutable
}
}
} //~ NOTE: borrow later used here
//~^ NOTE: dropped here
fn fun() -> _ {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]

View File

@ -21,7 +21,7 @@ LL | fn fn_mut() -> _ {
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/suggest-return-closure.rs:25:13
--> $DIR/suggest-return-closure.rs:31:13
|
LL | fn fun() -> _ {
| ^
@ -31,6 +31,29 @@ LL | fn fun() -> _ {
|
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
error: aborting due to 3 previous errors
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/suggest-return-closure.rs:22:9
|
LL | let x = String::new();
| - help: consider changing this to be mutable: `mut x`
...
LL | x.push(c);
| ^ cannot borrow as mutable
For more information about this error, try `rustc --explain E0121`.
error[E0597]: `x` does not live long enough
--> $DIR/suggest-return-closure.rs:22:9
|
LL | |c| {
| --- value captured here
LL | x.push(c);
| ^ borrowed value does not live long enough
...
LL | }
| -- borrow later used here
| |
| `x` dropped here while still borrowed
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0121, E0596, E0597.
For more information about an error, try `rustc --explain E0121`.

View File

@ -7,6 +7,12 @@ LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self
LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self {
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x`
error: aborting due to 1 previous error
error: `Self` does not live long enough
--> $DIR/lending_iterator.rs:34:9
|
LL | <B as FromLendingIterator<A>>::from_iter(self)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0276`.

View File

@ -32,6 +32,7 @@ pub trait LendingIterator {
Self: for<'q> LendingIterator<Item<'q> = A>,
{
<B as FromLendingIterator<A>>::from_iter(self)
//[base]~^ ERROR: does not live long enough
}
}

View File

@ -52,4 +52,5 @@ fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> {
pub fn main() {
let doc = create_doc();
let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc);
//~^ ERROR: `doc` does not live long enough
}

View File

@ -27,7 +27,21 @@ LL | type Cursor<'a>: DocCursor<'a>;
= note: this bound is currently required to ensure that impls have maximum flexibility
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
error: aborting due to 3 previous errors
error[E0597]: `doc` does not live long enough
--> $DIR/issue-70304.rs:54:59
|
LL | let doc = create_doc();
| --- binding `doc` declared here
LL | let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc);
| ------------^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `doc` is borrowed for `'static`
LL |
LL | }
| - `doc` dropped here while still borrowed
Some errors have detailed explanations: E0106, E0637.
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0106, E0597, E0637.
For more information about an error, try `rustc --explain E0106`.

View File

@ -10,7 +10,7 @@ impl <T> Fun for T {
fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
let a = [0; 1];
let x = T::identity(&a);
let x = T::identity(&a); //~ ERROR: does not live long enough
todo!()
}

View File

@ -17,6 +17,23 @@ note: required by a bound in `bug`
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
| ^^^^^^^^^^^^ required by this bound in `bug`
error: aborting due to 1 previous error
error[E0597]: `a` does not live long enough
--> $DIR/issue-74684-2.rs:13:25
|
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
| -- lifetime `'a` defined here
LL | let a = [0; 1];
| - binding `a` declared here
LL | let x = T::identity(&a);
| ------------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `a` is borrowed for `'a`
LL | todo!()
LL | }
| - `a` dropped here while still borrowed
For more information about this error, try `rustc --explain E0271`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0271, E0597.
For more information about an error, try `rustc --explain E0271`.

View File

@ -22,11 +22,12 @@ fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
//~^ ERROR missing generics for associated type
{
for n in 0i16..100 {
*dst.test_mut() = n.into();
*dst.test_mut() = n.into(); //~ ERROR: cannot borrow
//~^ ERROR: borrowed data escapes outside of function
}
}
fn main() {
let mut t1: E<f32> = Default::default();
test_simpler(&mut t1);
test_simpler(&mut t1); //~ ERROR does not live long enough
}

View File

@ -25,6 +25,43 @@ LL | type Output<'a>;
= note: this bound is currently required to ensure that impls have maximum flexibility
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
error: aborting due to 2 previous errors
error[E0499]: cannot borrow `*dst` as mutable more than once at a time
--> $DIR/issue-80433.rs:25:10
|
LL | *dst.test_mut() = n.into();
| ^^^-----------
| |
| `*dst` was mutably borrowed here in the previous iteration of the loop
| argument requires that `*dst` is borrowed for `'static`
For more information about this error, try `rustc --explain E0107`.
error[E0521]: borrowed data escapes outside of function
--> $DIR/issue-80433.rs:25:10
|
LL | fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
| -- --- `dst` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
...
LL | *dst.test_mut() = n.into();
| ^^^^^^^^^^^^^^
| |
| `dst` escapes the function body here
| argument requires that `'a` must outlive `'static`
error[E0597]: `t1` does not live long enough
--> $DIR/issue-80433.rs:32:18
|
LL | let mut t1: E<f32> = Default::default();
| ------ binding `t1` declared here
LL | test_simpler(&mut t1);
| -------------^^^^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `t1` is borrowed for `'static`
LL | }
| - `t1` dropped here while still borrowed
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0107, E0499, E0521, E0597.
For more information about an error, try `rustc --explain E0107`.

View File

@ -3,5 +3,5 @@ extern "C" {
}
fn main() {
foo::<i32>();
foo::<i32>(); //~ ERROR requires unsafe
}

View File

@ -6,6 +6,15 @@ LL | fn foo<T>();
|
= help: replace the type parameters with concrete types like `u32`
error: aborting due to 1 previous error
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
--> $DIR/generic-extern.rs:6:5
|
LL | foo::<i32>();
| ^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
For more information about this error, try `rustc --explain E0044`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0044, E0133.
For more information about an error, try `rustc --explain E0044`.

View File

@ -4,4 +4,5 @@ fn main() {
let xs = [13, 1, 5, 2, 3, 1, 21, 8];
let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
//~^ `X..` patterns in slices are experimental
//~| ERROR: refutable pattern
}

View File

@ -8,6 +8,21 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
= help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error
error[E0005]: refutable pattern in local binding
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:5:9
|
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `[i32::MIN..=2_i32, ..]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `[i32; 8]`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { todo!() };
| ++++++++++++++++
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0005, E0658.
For more information about an error, try `rustc --explain E0005`.

View File

@ -23,6 +23,7 @@ fn syntax2() {
macro_rules! mac {
($e:expr) => {
let ...$e; //~ ERROR range-to patterns with `...` are not allowed
//~^ ERROR refutable pattern in local binding
}
}

View File

@ -33,5 +33,24 @@ LL | mac!(0);
|
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 5 previous errors
error[E0005]: refutable pattern in local binding
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:25:17
|
LL | let ...$e;
| ^^^^^ pattern `1_i32..=i32::MAX` not covered
...
LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let ...$e; { todo!() }
| ++ +++++++++++
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0005`.

View File

@ -1,6 +1,9 @@
fn main() {
let x = 42;
match x {
//~^ ERROR: non-exhaustive patterns
//~| NOTE: not covered
//~| NOTE: matched value is of type
0..=73 => {},
74..=> {},
//~^ ERROR unexpected `>` after inclusive range

View File

@ -1,5 +1,5 @@
error: unexpected `>` after inclusive range
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:8:14
|
LL | 74..=> {},
| ---^
@ -11,5 +11,19 @@ help: add a space between the pattern and `=>`
LL | 74.. => {},
| +
error: aborting due to 1 previous error
error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` not covered
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:3:11
|
LL | match x {
| ^ pattern `i32::MIN..=-1_i32` not covered
|
= note: the matched value is of type `i32`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 74..=> {},
LL ~ i32::MIN..=-1_i32 => todo!(),
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0004`.

View File

@ -16,7 +16,9 @@ fn bar() {
macro_rules! mac {
($e:expr) => {
let $e...; //~ ERROR inclusive range with no end
//~^ ERROR: refutable pattern
let $e..=; //~ ERROR inclusive range with no end
//~^ ERROR: refutable pattern
}
}

View File

@ -43,7 +43,7 @@ LL | mac!(0);
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:19:19
--> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19
|
LL | let $e..=;
| ^^^ help: use `..` instead
@ -54,6 +54,43 @@ LL | mac!(0);
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 6 previous errors
error[E0005]: refutable pattern in local binding
--> $DIR/half-open-range-pats-inclusive-no-end.rs:18:17
|
LL | let $e...;
| ^^^^^ pattern `i32::MIN..=-1_i32` not covered
...
LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let $e...; { todo!() }
| ++ +++++++++++
For more information about this error, try `rustc --explain E0586`.
error[E0005]: refutable pattern in local binding
--> $DIR/half-open-range-pats-inclusive-no-end.rs:20:17
|
LL | let $e..=;
| ^^^^^ pattern `i32::MIN..=-1_i32` not covered
...
LL | mac!(0);
| ------- in this macro invocation
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `i32`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | if let $e..=; { todo!() }
| ++ +++++++++++
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0005, E0586.
For more information about an error, try `rustc --explain E0005`.

View File

@ -5,4 +5,5 @@ fn main() {
//~^ `X..` patterns in slices are experimental
//~| exclusive range pattern syntax is experimental
//~| exclusive range pattern syntax is experimental
//~| ERROR: refutable pattern
}

View File

@ -30,6 +30,21 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: use an inclusive range pattern, like N..=M
error: aborting due to 3 previous errors
error[E0005]: refutable pattern in local binding
--> $DIR/slice_pattern_syntax_problem1.rs:4:9
|
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `[i32::MIN..=2_i32, ..]` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
= note: the matched value is of type `[i32; 8]`
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { todo!() };
| ++++++++++++++++
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0005, E0658.
For more information about an error, try `rustc --explain E0005`.

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