Auto merge of #60171 - matthewjasper:full-nll-compare-mode, r=pnkfelix

Use -Zborrowck=mir for NLL compare mode

closes #56993

r? @pnkfelix
This commit is contained in:
bors 2019-05-17 13:01:23 +00:00
commit b982867a73
496 changed files with 5216 additions and 978 deletions

View File

@ -13,7 +13,6 @@
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
#![feature(never_type)]
#![feature(nll)]
#[derive(Copy, Clone)]
pub struct Entity {

View File

@ -49,14 +49,14 @@ pub fn add_parameter() {
// Change parameter pattern ----------------------------------------------------
#[cfg(cfail1)]
pub fn change_parameter_pattern() {
let _ = |x: &u32| x;
let _ = |x: (u32,)| x;
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody, mir_built, typeck_tables_of")]
#[rustc_clean(cfg="cfail3")]
pub fn change_parameter_pattern() {
let _ = |&x: &u32| x;
let _ = |(x,): (u32,)| x;
}

View File

@ -2,8 +2,6 @@
// ignore-wasm32-bare
#![feature(nll)]
fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
match x {
Some(0) if c => 0,

View File

@ -1,7 +1,5 @@
// error-pattern: thread 'main' panicked at 'explicit panic'
#![feature(nll)]
fn main() {
let mut vec = vec![];
vec.push((vec.len(), panic!()));

View File

@ -3,8 +3,6 @@
#![allow(unused_variables)]
// Test case from #39963.
#![feature(nll)]
#[derive(Clone)]
struct Foo(Option<Box<Foo>>, Option<Box<Foo>>);

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(nll)]
#![deny(unused_mut)]
#[derive(Debug)]

View File

@ -1,8 +1,4 @@
// run-pass
// revisions: lxl nll
#![cfg_attr(nll, feature(nll))]
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};

View File

@ -5,7 +5,6 @@
// See further discussion on rust-lang/rust#24535,
// rust-lang/rfcs#1006, and rust-lang/rfcs#107
#![feature(nll)]
#![feature(bind_by_move_pattern_guards)]
fn main() {

View File

@ -1,7 +1,6 @@
// run-pass
#![allow(unused_must_use)]
// Test that we are able to reinitialize box with moved referent
#![feature(nll)]
static mut ORDER: [usize; 3] = [0, 0, 0];
static mut INDEX: usize = 0;

View File

@ -1,6 +1,5 @@
// run-pass
#![allow(unreachable_code)]
#![feature(nll)]
fn main() {
let mut v = Vec::new();

View File

@ -3,7 +3,6 @@
// Regression test for #47153: constants in a generic context (such as
// a trait) used to ICE.
#![feature(nll)]
#![allow(warnings)]
trait Foo {

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(nll)]
pub struct DescriptorSet<'a> {
pub slots: Vec<AttachInfo<'a, Resources>>
}

View File

@ -2,8 +2,6 @@
#![allow(path_statements)]
#![allow(dead_code)]
#![feature(nll)]
struct WithDrop;
impl Drop for WithDrop {

View File

@ -2,7 +2,6 @@
#![allow(path_statements)]
#![allow(dead_code)]
#![feature(nll)]
#![feature(generators, generator_trait)]
struct WithDrop;

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(nll)]
#![deny(unused_mut)]
fn main() {

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(nll)]
#![deny(unused_mut)]
struct Foo {

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(nll)]
#![allow(unused_variables)]
pub trait TryTransform {

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(nll)]
struct List<T> {
value: T,
next: Option<Box<List<T>>>,

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(nll)]
use std::collections::HashMap;
fn process_or_insert_default(map: &mut HashMap<usize, String>, key: usize) {

View File

@ -6,8 +6,6 @@
// `x`. The lexical checker makes this very painful. The NLL checker
// does not.
#![feature(nll)]
use std::rc::Rc;
#[derive(Debug, PartialEq, Eq)]

View File

@ -0,0 +1,24 @@
error: lifetime may not live long enough
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:29
|
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let z: I::A = if cond { x } else { y };
| ^ assignment requires that `'a` must outlive `'b`
error: lifetime may not live long enough
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40
|
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let z: I::A = if cond { x } else { y };
| ^ assignment requires that `'b` must outlive `'a`
error: aborting due to 2 previous errors

View File

@ -0,0 +1,24 @@
error: lifetime may not live long enough
--> $DIR/associated-types-subtyping-1.rs:24:12
|
LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let a: <T as Trait<'a>>::Type = make_any();
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a`
error: lifetime may not live long enough
--> $DIR/associated-types-subtyping-1.rs:35:13
|
LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T)
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let _c: <T as Trait<'a>>::Type = b;
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a`
error: aborting due to 2 previous errors

View File

@ -0,0 +1,24 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-contravariant.rs:45:4
|
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
error: lifetime may not live long enough
--> $DIR/project-fn-ret-contravariant.rs:45:4
|
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
error: aborting due to 2 previous errors

View File

@ -0,0 +1,10 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-contravariant.rs:38:4
|
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here
LL | bar(foo, x)
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: aborting due to previous error

View File

@ -0,0 +1,24 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:55:4
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:55:4
|
LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | (a, b)
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
error: aborting due to 2 previous errors

View File

@ -0,0 +1,24 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:38:12
|
LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | let f = foo; // <-- No consistent type can be inferred for `f` here.
LL | let a = bar(f, x);
| ^^^^^^^^^ argument requires that `'a` must outlive `'b`
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:39:12
|
LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let b = bar(f, y);
| ^^^^^^^^^ argument requires that `'b` must outlive `'a`
error: aborting due to 2 previous errors

View File

@ -0,0 +1,11 @@
error: lifetime may not live long enough
--> $DIR/project-fn-ret-invariant.rs:48:4
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
| -- lifetime `'a` defined here
...
LL | bar(foo, x)
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: aborting due to previous error

View File

@ -0,0 +1,40 @@
error[E0503]: cannot use `y` because it was mutably borrowed
--> $DIR/borrowck-anon-fields-variant.rs:17:7
|
LL | Foo::Y(ref mut a, _) => a,
| --------- borrow of `y.0` occurs here
...
LL | Foo::Y(_, ref mut b) => b,
| ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0`
...
LL | *a += 1;
| ------- borrow later used here
error[E0503]: cannot use `y` because it was mutably borrowed
--> $DIR/borrowck-anon-fields-variant.rs:37:7
|
LL | Foo::Y(ref mut a, _) => a,
| --------- borrow of `y.0` occurs here
...
LL | Foo::Y(ref mut b, _) => b,
| ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0`
...
LL | *a += 1;
| ------- borrow later used here
error[E0499]: cannot borrow `y.0` as mutable more than once at a time
--> $DIR/borrowck-anon-fields-variant.rs:37:14
|
LL | Foo::Y(ref mut a, _) => a,
| --------- first mutable borrow occurs here
...
LL | Foo::Y(ref mut b, _) => b,
| ^^^^^^^^^ second mutable borrow occurs here
...
LL | *a += 1;
| ------- first borrow later used here
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0499, E0503.
For more information about an error, try `rustc --explain E0499`.

View File

@ -0,0 +1,366 @@
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-describe-lvalue.rs:262:13
|
LL | let y = &mut x;
| ------ first mutable borrow occurs here
LL | &mut x;
| ^^^^^^ second mutable borrow occurs here
LL | *y = 1;
| ------ first borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-describe-lvalue.rs:272:20
|
LL | let y = &mut x;
| ------ first mutable borrow occurs here
LL | &mut x;
| ^^^^^^ second mutable borrow occurs here
LL | *y = 1;
| ------ first borrow later used here
error: captured variable cannot escape `FnMut` closure body
--> $DIR/borrowck-describe-lvalue.rs:270:16
|
LL | || {
| - inferred to be a `FnMut` closure
LL | / || {
LL | | let y = &mut x;
LL | | &mut x;
LL | | *y = 1;
LL | | drop(y);
LL | | }
| |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
|
= note: `FnMut` closures only have access to their captured variables while they are executing...
= note: ...therefore, they cannot allow references to captured variables to escape
error[E0503]: cannot use `f.x` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:41:9
|
LL | let x = f.x();
| - borrow of `f` occurs here
LL | f.x;
| ^^^ use of borrowed `f`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `g.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:48:9
|
LL | let x = g.x();
| - borrow of `g` occurs here
LL | g.0;
| ^^^ use of borrowed `g`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `h.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:55:9
|
LL | let x = &mut h.0;
| -------- borrow of `h.0` occurs here
LL | h.0;
| ^^^ use of borrowed `h.0`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `e.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:63:20
|
LL | let x = e.x();
| - borrow of `e` occurs here
LL | match e {
LL | Baz::X(value) => value
| ^^^^^ use of borrowed `e`
LL | };
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `u.a` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:71:9
|
LL | let x = &mut u.a;
| -------- borrow of `u.a` occurs here
LL | u.a;
| ^^^ use of borrowed `u.a`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `f.x` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:78:9
|
LL | let x = f.x();
| - borrow of `*f` occurs here
LL | f.x;
| ^^^ use of borrowed `*f`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `g.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:85:9
|
LL | let x = g.x();
| - borrow of `*g` occurs here
LL | g.0;
| ^^^ use of borrowed `*g`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `h.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:92:9
|
LL | let x = &mut h.0;
| -------- borrow of `h.0` occurs here
LL | h.0;
| ^^^ use of borrowed `h.0`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `e.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:100:20
|
LL | let x = e.x();
| - borrow of `*e` occurs here
LL | match *e {
LL | Baz::X(value) => value
| ^^^^^ use of borrowed `*e`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `u.a` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:109:9
|
LL | let x = &mut u.a;
| -------- borrow of `u.a` occurs here
LL | u.a;
| ^^^ use of borrowed `u.a`
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:117:15
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
LL | match v {
LL | &[x, _, .., _, _] => println!("{}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:122:18
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, x, .., _, _] => println!("{}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:127:25
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, _, .., x, _] => println!("{}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:132:28
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, _, .., _, x] => println!("{}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:143:15
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
LL | match v {
LL | &[x..] => println!("{:?}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:148:18
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, x..] => println!("{:?}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:153:15
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[x.., _] => println!("{:?}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[..]` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:158:18
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, x.., _] => println!("{:?}", x),
| ^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `e` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:171:13
|
LL | let x = &mut e;
| ------ borrow of `e` occurs here
LL | match e {
LL | E::A(ref ax) =>
| ^^^^^^^^^^^^ use of borrowed `e`
...
LL | drop(x);
| - borrow later used here
error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:171:18
|
LL | let x = &mut e;
| ------ mutable borrow occurs here
LL | match e {
LL | E::A(ref ax) =>
| ^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:175:23
|
LL | let x = &mut e;
| ------ mutable borrow occurs here
...
LL | E::B { x: ref bx } =>
| ^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:188:22
|
LL | let x = &mut s;
| ------ mutable borrow occurs here
LL | match s {
LL | S { y: (ref y0, _), .. } =>
| ^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:194:28
|
LL | let x = &mut s;
| ------ mutable borrow occurs here
...
LL | S { x: F { y: ref x0, .. }, .. } =>
| ^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0503]: cannot use `*v` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:240:9
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
LL | v[0].y;
| ^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0503]: cannot use `v[_].y` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:240:9
|
LL | let x = &mut v;
| ------ borrow of `v` occurs here
LL | v[0].y;
| ^^^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:251:24
|
LL | let x = &mut v;
| ------ mutable borrow occurs here
LL | match v {
LL | &[_, F {x: ref xf, ..}] => println!("{}", xf),
| ^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:210:29
|
LL | let x = &mut block;
| ---------- mutable borrow occurs here
LL | let p: &'a u8 = &*block.current;
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-describe-lvalue.rs:227:33
|
LL | let x = &mut block;
| ---------- mutable borrow occurs here
LL | let p : *const u8 = &*(*block).current;
| ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
...
LL | drop(x);
| - mutable borrow later used here
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-describe-lvalue.rs:282:22
|
LL | drop(x);
| - value moved here
LL | drop(x);
| ^ value used here after move
|
= note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
error: aborting due to 32 previous errors
Some errors have detailed explanations: E0382, E0499, E0502, E0503.
For more information about an error, try `rustc --explain E0382`.

View File

@ -0,0 +1,27 @@
error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-for-loop-head-linkage.rs:7:9
|
LL | for &x in &vector {
| -------
| |
| immutable borrow occurs here
| immutable borrow later used here
LL | let cap = vector.capacity();
LL | vector.extend(repeat(0));
| ^^^^^^ mutable borrow occurs here
error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-for-loop-head-linkage.rs:8:9
|
LL | for &x in &vector {
| -------
| |
| immutable borrow occurs here
| immutable borrow later used here
...
LL | vector[1] = 5;
| ^^^^^^ mutable borrow occurs here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0502`.

View File

@ -1,5 +1,3 @@
#![feature(nll)]
struct Node {
elem: i32,
next: Option<Box<Node>>,

View File

@ -1,5 +1,5 @@
error[E0382]: use of moved value: `src`
--> $DIR/borrowck-issue-48962.rs:16:5
--> $DIR/borrowck-issue-48962.rs:14:5
|
LL | let mut src = &mut node;
| ------- move occurs because `src` has type `&mut Node`, which does not implement the `Copy` trait
@ -9,7 +9,7 @@ LL | src.next = None;
| ^^^^^^^^ value used here after move
error[E0382]: use of moved value: `src`
--> $DIR/borrowck-issue-48962.rs:22:5
--> $DIR/borrowck-issue-48962.rs:20:5
|
LL | let mut src = &mut (22, 44);
| ------- move occurs because `src` has type `&mut (i32, i32)`, which does not implement the `Copy` trait

View File

@ -0,0 +1,41 @@
error[E0302]: cannot assign in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:10:25
|
LL | Enum::A(_) if { x = Enum::B(false); false } => 1,
| ^^^^^^^^^^^^^^^^^^ assignment in pattern guard
error[E0301]: cannot mutably borrow in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:15:38
|
LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
| ^ borrowed mutably in pattern guard
|
= help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
error[E0302]: cannot assign in a pattern guard
--> $DIR/borrowck-mutate-in-guard.rs:15:41
|
LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
| ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard
error[E0510]: cannot assign `x` in match guard
--> $DIR/borrowck-mutate-in-guard.rs:10:25
|
LL | match x {
| - value is immutable in match guard
LL | Enum::A(_) if { x = Enum::B(false); false } => 1,
| ^^^^^^^^^^^^^^^^^^ cannot assign
error[E0510]: cannot mutably borrow `x` in match guard
--> $DIR/borrowck-mutate-in-guard.rs:15:33
|
LL | match x {
| - value is immutable in match guard
...
LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
| ^^^^^^ cannot mutably borrow
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0301, E0302, E0510.
For more information about an error, try `rustc --explain E0301`.

View File

@ -0,0 +1,23 @@
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-object-lifetime.rs:20:13
|
LL | let y = x.borrowed();
| - immutable borrow occurs here
LL | let z = x.mut_borrowed();
| ^ mutable borrow occurs here
LL | y.use_ref();
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-object-lifetime.rs:26:13
|
LL | let y = x.borrowed();
| - immutable borrow occurs here
LL | let z = &mut x;
| ^^^^^^ mutable borrow occurs here
LL | y.use_ref();
| - immutable borrow later used here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0502`.

View File

@ -0,0 +1,12 @@
error: lifetime may not live long enough
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5
|
LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | S { pointer: &mut *p.pointer }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
error: aborting due to previous error

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(nll)]
enum Nat {
S(Box<Nat>),
Z

View File

@ -8,8 +8,6 @@
// run-pass
#![feature(nll)]
fn foo(x: &mut Result<(u32, u32), (u32, u32)>) -> u32 {
match *x {
Ok((ref mut v, _)) | Err((_, ref mut v)) if *v > 0 => { *v }

View File

@ -2,8 +2,6 @@
// computing liveness that wound up accidentally causing the program
// below to be accepted.
#![feature(nll)]
fn foo<'a>(x: &'a mut u32) -> u32 {
let mut x = 22;
let y = &x;

View File

@ -1,5 +1,5 @@
error[E0506]: cannot assign to `x` because it is borrowed
--> $DIR/issue-52713-bug.rs:14:5
--> $DIR/issue-52713-bug.rs:12:5
|
LL | let y = &x;
| -- borrow of `x` occurs here

View File

@ -1,5 +1,3 @@
#![feature(nll)]
#![allow(dead_code)]
#[derive(Debug)]

View File

@ -1,5 +1,5 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:16:13
--> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:14:13
|
LL | *array
| ^^^^^^

View File

@ -1,19 +1,11 @@
// ignore-compare-mode-nll
// revisions: migrate nll
#![cfg_attr(nll, feature(nll))]
fn main() {
let mut greeting = "Hello world!".to_string();
let res = (|| (|| &greeting)())();
greeting = "DEALLOCATED".to_string();
//[migrate]~^ ERROR cannot assign
//[nll]~^^ ERROR cannot assign
//~^ ERROR cannot assign
drop(greeting);
//[migrate]~^ ERROR cannot move
//[nll]~^^ ERROR cannot move
//~^ ERROR cannot move
println!("thread result: {:?}", res);
}

View File

@ -1,5 +1,5 @@
error[E0506]: cannot assign to `greeting` because it is borrowed
--> $DIR/issue-58776-borrowck-scans-children.rs:11:5
--> $DIR/issue-58776-borrowck-scans-children.rs:5:5
|
LL | let res = (|| (|| &greeting)())();
| -- -------- borrow occurs due to use in closure
@ -13,7 +13,7 @@ LL | println!("thread result: {:?}", res);
| --- borrow later used here
error[E0505]: cannot move out of `greeting` because it is borrowed
--> $DIR/issue-58776-borrowck-scans-children.rs:14:10
--> $DIR/issue-58776-borrowck-scans-children.rs:7:10
|
LL | let res = (|| (|| &greeting)())();
| -- -------- borrow occurs due to use in closure

View File

@ -0,0 +1,14 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/issue-7573.rs:21:9
|
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| ---------------- `lines_to_use` is declared here, outside of the closure body
LL |
LL | let push_id = |installed_id: &CrateId| {
| ------------ `installed_id` is a reference that is only valid in the closure body
...
LL | lines_to_use.push(installed_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
error: aborting due to previous error

View File

@ -0,0 +1,12 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn-2.rs:8:18
|
LL | let mut x = None;
| ----- `x` is declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View File

@ -0,0 +1,12 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-bound-fn.rs:8:18
|
LL | let mut x: Option<&isize> = None;
| ----- `x` is declared here, outside of the closure body
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View File

@ -0,0 +1,12 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/regions-escape-unboxed-closure.rs:6:23
|
LL | let mut x: Option<&isize> = None;
| ----- `x` is declared here, outside of the closure body
LL | with_int(&mut |y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
error: aborting due to previous error

View File

@ -1,8 +1,6 @@
// Test that a borrow which starts as a 2-phase borrow and gets
// carried around a loop winds up conflicting with itself.
#![feature(nll)]
struct Foo { x: String }
impl Foo {

View File

@ -1,5 +1,5 @@
error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> $DIR/two-phase-across-loop.rs:19:22
--> $DIR/two-phase-across-loop.rs:17:22
|
LL | strings.push(foo.get_string());
| ^^^ mutable borrow starts here in previous iteration of loop

View File

@ -1,5 +1,3 @@
#![feature(nll)]
struct Foo {
}

View File

@ -1,5 +1,5 @@
error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> $DIR/two-phase-multi-mut.rs:13:5
--> $DIR/two-phase-multi-mut.rs:11:5
|
LL | foo.method(&mut foo);
| ^^^^------^--------^
@ -9,7 +9,7 @@ LL | foo.method(&mut foo);
| second mutable borrow occurs here
error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> $DIR/two-phase-multi-mut.rs:13:16
--> $DIR/two-phase-multi-mut.rs:11:16
|
LL | foo.method(&mut foo);
| --- ------ ^^^^^^^^ second mutable borrow occurs here

View File

@ -0,0 +1,36 @@
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-reservation-sharing-interference-future-compat-lint.rs:13:9
|
LL | let shared = &v;
| -- immutable borrow occurs here
LL |
LL | v.push(shared.len());
| ^ ------ immutable borrow later used here
| |
| mutable borrow occurs here
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-reservation-sharing-interference-future-compat-lint.rs:24:9
|
LL | let shared = &v;
| -- immutable borrow occurs here
LL |
LL | v.push(shared.len());
| ^ ------ immutable borrow later used here
| |
| mutable borrow occurs here
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
--> $DIR/two-phase-reservation-sharing-interference-future-compat-lint.rs:37:9
|
LL | let shared = &v;
| -- immutable borrow occurs here
LL |
LL | v.push(shared.len());
| ^ ------ immutable borrow later used here
| |
| mutable borrow occurs here
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0502`.

View File

@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `ap`
--> $DIR/variadic-ffi-5.rs:11:5
--> $DIR/variadic-ffi-4.rs:8:5
|
LL | pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
| --- help: add explicit lifetime `'a` to the type of `ap`: `core::ffi::VaList<'a>`
@ -7,7 +7,7 @@ LL | ap
| ^^ lifetime `'a` required
error[E0621]: explicit lifetime required in the type of `ap`
--> $DIR/variadic-ffi-5.rs:15:5
--> $DIR/variadic-ffi-4.rs:12:5
|
LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
| --- help: add explicit lifetime `'static` to the type of `ap`: `core::ffi::VaList<'static>`
@ -15,7 +15,7 @@ LL | ap
| ^^ lifetime `'static` required
error: lifetime may not live long enough
--> $DIR/variadic-ffi-5.rs:19:33
--> $DIR/variadic-ffi-4.rs:16:33
|
LL | let _ = ap.with_copy(|ap| { ap });
| --- ^^ returning this value requires that `'1` must outlive `'2`
@ -24,40 +24,48 @@ LL | let _ = ap.with_copy(|ap| { ap });
| has type `core::ffi::VaList<'1>`
error: lifetime may not live long enough
--> $DIR/variadic-ffi-5.rs:23:5
--> $DIR/variadic-ffi-4.rs:20:5
|
LL | pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {
| --- ------- has type `core::ffi::VaList<'1>`
LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
| ------- ------- has type `core::ffi::VaList<'1>`
| |
| has type `&mut core::ffi::VaList<'2>`
LL | *ap0 = ap1;
| ^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
error: lifetime may not live long enough
--> $DIR/variadic-ffi-5.rs:27:5
--> $DIR/variadic-ffi-4.rs:24:5
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
| ------- ------- has type `core::ffi::VaList<'2>`
LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
| --- ------- has type `core::ffi::VaList<'2>`
| |
| has type `&mut core::ffi::VaList<'1>`
LL | ap0 = &mut ap1;
| ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
error: lifetime may not live long enough
--> $DIR/variadic-ffi-5.rs:27:5
--> $DIR/variadic-ffi-4.rs:24:5
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
| ------- ------- has type `core::ffi::VaList<'1>`
LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
| --- ------- has type `core::ffi::VaList<'1>`
| |
| has type `&mut core::ffi::VaList<'2>`
LL | ap0 = &mut ap1;
| ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
error[E0597]: `ap1` does not live long enough
--> $DIR/variadic-ffi-5.rs:27:11
error[E0384]: cannot assign to immutable argument `ap0`
--> $DIR/variadic-ffi-4.rs:24:5
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
| - let's call the lifetime of this reference `'1`
LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
| --- help: make this binding mutable: `mut ap0`
LL | ap0 = &mut ap1;
| ^^^^^^^^^^^^^^ cannot assign to immutable argument
error[E0597]: `ap1` does not live long enough
--> $DIR/variadic-ffi-4.rs:24:11
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
| - let's call the lifetime of this reference `'1`
LL | ap0 = &mut ap1;
| ------^^^^^^^^
| | |
@ -67,7 +75,7 @@ LL | ap0 = &mut ap1;
LL | }
| - `ap1` dropped here while still borrowed
error: aborting due to 7 previous errors
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0597, E0621.
For more information about an error, try `rustc --explain E0597`.
Some errors have detailed explanations: E0384, E0597, E0621.
For more information about an error, try `rustc --explain E0384`.

View File

@ -1,31 +0,0 @@
#![crate_type="lib"]
#![no_std]
#![feature(c_variadic)]
// The tests in this file are similar to that of variadic-ffi-4, but this
// one enables nll.
#![feature(nll)]
use core::ffi::VaList;
pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
ap //~ ERROR: explicit lifetime required
}
pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
ap //~ ERROR: explicit lifetime required
}
pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
let _ = ap.with_copy(|ap| { ap }); //~ ERROR: lifetime may not live long enough
}
pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {
*ap0 = ap1; //~ ERROR: lifetime may not live long enough
}
pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
ap0 = &mut ap1;
//~^ ERROR: lifetime may not live long enough
//~^^ ERROR: lifetime may not live long enough
//~^^^ ERROR: `ap1` does not live long enough
}

View File

@ -0,0 +1,53 @@
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:30:5
|
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _`
| |
| expected signature of `fn(fn(&'a u32), &i32) -> _`
|
note: required by `with_closure_expecting_fn_with_free_region`
--> $DIR/expect-fn-supply-fn.rs:1:1
|
LL | / fn with_closure_expecting_fn_with_free_region<F>(_: F)
LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32)
LL | | {
LL | | }
| |_^
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:37:5
|
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
|
note: required by `with_closure_expecting_fn_with_bound_region`
--> $DIR/expect-fn-supply-fn.rs:6:1
|
LL | / fn with_closure_expecting_fn_with_bound_region<F>(_: F)
LL | | where F: FnOnce(fn(&u32), &i32)
LL | | {
LL | | }
| |_^
error[E0631]: type mismatch in closure arguments
--> $DIR/expect-fn-supply-fn.rs:46:5
|
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
| |
| expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _`
|
note: required by `with_closure_expecting_fn_with_bound_region`
--> $DIR/expect-fn-supply-fn.rs:6:1
|
LL | / fn with_closure_expecting_fn_with_bound_region<F>(_: F)
LL | | where F: FnOnce(fn(&u32), &i32)
LL | | {
LL | | }
| |_^
error: aborting due to 3 previous errors

View File

@ -0,0 +1,37 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
|
LL | fn foo(x: &()) {
| --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()`
LL | / bar(|| {
LL | |
LL | | let _ = x;
LL | | })
| |______^ lifetime `'static` required
error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
|
LL | bar(|| {
| ^^ may outlive borrowed value `x`
LL |
LL | let _ = x;
| - `x` is borrowed here
|
note: function requires argument type to outlive `'static`
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
|
LL | / bar(|| {
LL | |
LL | | let _ = x;
LL | | })
| |______^
help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword
|
LL | bar(move || {
| ^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0373, E0621.
For more information about an error, try `rustc --explain E0373`.

View File

@ -0,0 +1,42 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:18:9
|
LL | let mut f: Option<&u32> = None;
| ----- `f` is declared here, outside of the closure body
LL | closure_expecting_bound(|x| {
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here
error[E0521]: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:28:9
|
LL | let mut f: Option<&u32> = None;
| ----- `f` is declared here, outside of the closure body
LL | closure_expecting_bound(|x: &u32| {
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here
error: lifetime may not live long enough
--> $DIR/expect-region-supply-region.rs:37:30
|
LL | fn expect_bound_supply_named<'x>() {
| -- lifetime `'x` defined here
...
LL | closure_expecting_bound(|x: &'x u32| {
| ^ - let's call the lifetime of this reference `'1`
| |
| requires that `'1` must outlive `'x`
error: lifetime may not live long enough
--> $DIR/expect-region-supply-region.rs:37:30
|
LL | fn expect_bound_supply_named<'x>() {
| -- lifetime `'x` defined here
...
LL | closure_expecting_bound(|x: &'x u32| {
| ^ requires that `'x` must outlive `'static`
error: aborting due to 4 previous errors

View File

@ -1,7 +1,5 @@
// compile-pass
#![feature(nll)]
pub fn main() {
let y: &'static mut [u8; 0] = &mut [];
}

View File

@ -0,0 +1,31 @@
error[E0005]: refutable pattern in function argument: `&[]` not covered
--> $DIR/const_let_refutable.rs:3:16
|
LL | const fn slice([a, b]: &[i32]) -> i32 {
| ^^^^^^ pattern `&[]` not covered
error[E0723]: can only call other `const fn` within a `const fn`, but `const std::ops::Add::add` is not stable as `const fn`
--> $DIR/const_let_refutable.rs:4:5
|
LL | a + b
| ^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0381]: use of possibly uninitialized variable: `a`
--> $DIR/const_let_refutable.rs:4:5
|
LL | a + b
| ^ use of possibly uninitialized `a`
error[E0381]: use of possibly uninitialized variable: `b`
--> $DIR/const_let_refutable.rs:4:9
|
LL | a + b
| ^ use of possibly uninitialized `b`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0005, E0381, E0723.
For more information about an error, try `rustc --explain E0005`.

View File

@ -1,5 +1,3 @@
#![feature(nll)]
const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed
use std::borrow::Cow;

View File

@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/issue-54224.rs:3:39
--> $DIR/issue-54224.rs:1:39
|
LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]);
| ------^^^^^^^^^-
@ -9,7 +9,7 @@ LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]);
| using this value as a constant requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/issue-54224.rs:11:57
--> $DIR/issue-54224.rs:9:57
|
LL | pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]);
| ---------------^^^^^^^^^-

View File

@ -0,0 +1,328 @@
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:37:25
|
LL | const fn into_inner(self) -> T { self.0 }
| ^^^^ constant functions cannot evaluate destructors
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:39:36
|
LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:44:28
|
LL | const fn into_inner_lt(self) -> T { self.0 }
| ^^^^ constant functions cannot evaluate destructors
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:46:42
|
LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:51:27
|
LL | const fn into_inner_s(self) -> T { self.0 }
| ^^^^ constant functions cannot evaluate destructors
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:53:38
|
LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:58:39
|
LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:76:16
|
LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:78:18
|
LL | const fn foo11_2<T: Send>(t: T) -> T { t }
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: only int, `bool` and `char` operations are stable in const fn
--> $DIR/min_const_fn.rs:80:33
|
LL | const fn foo19(f: f32) -> f32 { f * 2.0 }
| ^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: only int, `bool` and `char` operations are stable in const fn
--> $DIR/min_const_fn.rs:82:35
|
LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f }
| ^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: only int and `bool` operations are stable in const fn
--> $DIR/min_const_fn.rs:84:35
|
LL | const fn foo19_3(f: f32) -> f32 { -f }
| ^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: only int, `bool` and `char` operations are stable in const fn
--> $DIR/min_const_fn.rs:86:43
|
LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g }
| ^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: cannot access `static` items in const fn
--> $DIR/min_const_fn.rs:90:27
|
LL | const fn foo25() -> u32 { BAR }
| ^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: cannot access `static` items in const fn
--> $DIR/min_const_fn.rs:91:36
|
LL | const fn foo26() -> &'static u32 { &BAR }
| ^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: casting pointers to ints is unstable in const fn
--> $DIR/min_const_fn.rs:92:42
|
LL | const fn foo30(x: *const u32) -> usize { x as usize }
| ^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: casting pointers to ints is unstable in const fn
--> $DIR/min_const_fn.rs:94:63
|
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: casting pointers to ints is unstable in const fn
--> $DIR/min_const_fn.rs:96:42
|
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
| ^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: casting pointers to ints is unstable in const fn
--> $DIR/min_const_fn.rs:98:63
|
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
| ^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/min_const_fn.rs:100:38
|
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/min_const_fn.rs:102:29
|
LL | const fn foo30_5(b: bool) { while b { } }
| ^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/min_const_fn.rs:104:44
|
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/min_const_fn.rs:106:44
|
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
| ^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:108:14
|
LL | const fn inc(x: &mut i32) { *x += 1 }
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:113:6
|
LL | impl<T: std::fmt::Debug> Foo<T> {
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:118:6
|
LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:123:6
|
LL | impl<T: Sync + Sized> Foo<T> {
| ^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `impl Trait` in const fn is unstable
--> $DIR/min_const_fn.rs:129:24
|
LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:131:34
|
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
| ^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:133:22
|
LL | const fn no_apit(_x: impl std::fmt::Debug) {}
| ^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: `impl Trait` in const fn is unstable
--> $DIR/min_const_fn.rs:134:23
|
LL | const fn no_rpit() -> impl std::fmt::Debug {}
| ^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:135:23
|
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
| ^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:136:32
|
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0515]: cannot return reference to temporary value
--> $DIR/min_const_fn.rs:136:63
|
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^--
| ||
| |temporary value created here
| returns a reference to data owned by the current function
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:144:41
|
LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable
--> $DIR/min_const_fn.rs:147:21
|
LL | const fn no_fn_ptrs(_x: fn()) {}
| ^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable
--> $DIR/min_const_fn.rs:149:27
|
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
| ^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error: aborting due to 37 previous errors
Some errors have detailed explanations: E0515, E0723.
For more information about an error, try `rustc --explain E0515`.

View File

@ -0,0 +1,31 @@
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn_dyn.rs:9:5
|
LL | x.0.field;
| ^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn_dyn.rs:12:66
|
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
| ^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable
error[E0716]: temporary value dropped while borrowed
--> $DIR/min_const_fn_dyn.rs:12:67
|
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
| -^ - temporary value is freed at the end of this statement
| ||
| |creates a temporary which is freed while still in use
| cast requires that borrow lasts for `'static`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0716, E0723.
For more information about an error, try `rustc --explain E0716`.

View File

@ -1,7 +1,5 @@
//compile-pass
#![feature(nll)]
fn main() {
let _: &'static usize = &(loop {}, 1).1;

View File

@ -1,8 +1,6 @@
// compile-pass
// aux-build:promotable_const_fn_lib.rs
#![feature(nll)]
extern crate promotable_const_fn_lib;
use promotable_const_fn_lib::{foo, Foo};

View File

@ -1,7 +1,5 @@
// compile-pass
#![feature(nll)]
fn main() {
let x: &'static u8 = &u8::max_value();
let x: &'static u16 = &u16::max_value();

View File

@ -0,0 +1,7 @@
error[E0601]: `main` function not found in crate `continue_after_missing_main`
|
= note: consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0601`.

View File

@ -0,0 +1,23 @@
error[E0005]: refutable pattern in local binding: `T(_, _)` not covered
--> $DIR/empty-never-array.rs:10:9
|
LL | / enum Helper<T, U> {
LL | | T(T, [!; 0]),
LL | | #[allow(dead_code)]
LL | | U(U),
LL | | }
| |_- `Helper<T, U>` defined here
...
LL | let Helper::U(u) = Helper::T(t, []);
| ^^^^^^^^^^^^ pattern `T(_, _)` not covered
error[E0381]: use of possibly uninitialized variable: `u`
--> $DIR/empty-never-array.rs:12:5
|
LL | u
| ^ use of possibly uninitialized `u`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.

View File

@ -0,0 +1,13 @@
error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable
--> $DIR/E0502.rs:4:9
|
LL | let ref y = a;
| ----- immutable borrow occurs here
LL | bar(a);
| ^ mutable borrow occurs here
LL | y.use_ref();
| - immutable borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0502`.

View File

@ -0,0 +1,11 @@
error: lifetime may not live long enough
--> $DIR/E0621-does-not-trigger-for-closures.rs:15:45
|
LL | invoke(&x, |a, b| if a > b { a } else { b });
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is &'2 i32
| has type `&'1 i32`
error: aborting due to previous error

View File

@ -0,0 +1,18 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:9:35
|
LL | existential type WrongGeneric<T>: 'static;
| ^^^^^^^
error[E0308]: mismatched types
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
|
LL | let z: i32 = x;
| ^ expected i32, found opaque type
|
= note: expected type `i32`
found type `WrongGeneric::<&{integer}>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -0,0 +1,41 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/auto-trait-regions.rs:44:24
|
LL | let a = A(&mut true, &mut true, No);
| ^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary which is freed while still in use
LL | yield;
LL | assert_foo(a);
| - borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
error[E0716]: temporary value dropped while borrowed
--> $DIR/auto-trait-regions.rs:44:35
|
LL | let a = A(&mut true, &mut true, No);
| ^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary which is freed while still in use
LL | yield;
LL | assert_foo(a);
| - borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
error: higher-ranked subtype error
--> $DIR/auto-trait-regions.rs:30:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/auto-trait-regions.rs:48:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0716`.

View File

@ -1,8 +1,4 @@
// revisions: migrate nll
// ignore-compare-mode-nll
#![feature(generators, generator_trait)]
#![cfg_attr(nll, feature(nll))]
use std::ops::{Generator, GeneratorState};
use std::pin::Pin;
@ -14,8 +10,7 @@ fn dangle(x: &mut i32) -> &'static mut i32 {
loop {
match Pin::new(&mut g).resume() {
GeneratorState::Complete(c) => return c,
//[nll]~^ ERROR explicit lifetime required
//[migrate]~^^ ERROR explicit lifetime required
//~^ ERROR explicit lifetime required
GeneratorState::Yielded(_) => (),
}
}

View File

@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/generator-region-requirements.rs:16:51
--> $DIR/generator-region-requirements.rs:12:51
|
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
| -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`

View File

@ -1,5 +1,4 @@
#![feature(generators)]
#![feature(nll)]
fn main() {
|| {

View File

@ -1,5 +1,5 @@
error[E0626]: borrow may still be in use when generator yields
--> $DIR/generator-with-nll.rs:8:17
--> $DIR/generator-with-nll.rs:7:17
|
LL | let b = &mut true;
| ^^^^^^^^^

View File

@ -0,0 +1,15 @@
error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable
--> $DIR/hashmap-iter-value-lifetime.rs:7:5
|
LL | let (_, thing) = my_stuff.iter().next().unwrap();
| -------- immutable borrow occurs here
LL |
LL | my_stuff.clear();
| ^^^^^^^^ mutable borrow occurs here
LL |
LL | println!("{}", *thing);
| ------ immutable borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0502`.

View File

@ -0,0 +1,13 @@
error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable
--> $DIR/hashmap-lifetimes.rs:6:5
|
LL | let mut it = my_stuff.iter();
| -------- immutable borrow occurs here
LL | my_stuff.insert(1, 43);
| ^^^^^^^^ mutable borrow occurs here
LL | it;
| -- immutable borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0502`.

View File

@ -0,0 +1,30 @@
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:33:13
|
LL | fn subtype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t2>(None::<$t1>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:39:13
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
LL | | fn(Inv<'y>)) }
| |__________________________________________________- in this macro invocation
error: aborting due to 2 previous errors

View File

@ -0,0 +1,16 @@
error: lifetime may not live long enough
--> $DIR/hr-subtype.rs:39:13
|
LL | fn supertype<'x,'y:'x,'z:'y>() {
| -- -- lifetime `'y` defined here
| |
| lifetime `'x` defined here
LL | gimme::<$t1>(None::<$t2>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y`
...
LL | / check! { free_x_vs_free_y: (fn(&'x u32),
LL | | fn(&'y u32)) }
| |__________________________________________- in this macro invocation
error: aborting due to previous error

View File

@ -0,0 +1,8 @@
error: higher-ranked subtype error
--> $DIR/hrtb-cache-issue-54302.rs:19:5
|
LL | assert_deserialize_owned::<&'static str>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -0,0 +1,77 @@
warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:22:1
|
LL | / fn no_hrtb<'b,T>(mut t: T)
LL | | where T : Bar<&'b isize>
LL | | {
LL | | // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that
LL | | // `&mut T : Bar<&'b isize>`.
LL | | no_hrtb(&mut t);
| | --------------- recursive call site
LL | | }
| |_^ cannot return without recursing
|
= note: #[warn(unconditional_recursion)] on by default
= help: a `loop` may express intention better if this is on purpose
warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:30:1
|
LL | / fn bar_hrtb<T>(mut t: T)
LL | | where T : for<'b> Bar<&'b isize>
LL | | {
LL | | // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above
... |
LL | | bar_hrtb(&mut t);
| | ---------------- recursive call site
LL | | }
| |_^ cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose
warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:39:1
|
LL | / fn foo_hrtb_bar_not<'b,T>(mut t: T)
LL | | where T : for<'a> Foo<&'a isize> + Bar<&'b isize>
LL | | {
LL | | // Not OK -- The forwarding impl for `Foo` requires that `Bar` also
... |
LL | | foo_hrtb_bar_not(&mut t);
| | ------------------------ recursive call site
LL | | }
| |_^ cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose
error: higher-ranked subtype error
--> $DIR/hrtb-perfect-forwarding.rs:46:5
|
LL | foo_hrtb_bar_not(&mut t);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: lifetime may not live long enough
--> $DIR/hrtb-perfect-forwarding.rs:46:5
|
LL | fn foo_hrtb_bar_not<'b,T>(mut t: T)
| -- lifetime `'b` defined here
...
LL | foo_hrtb_bar_not(&mut t);
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:49:1
|
LL | / fn foo_hrtb_bar_hrtb<T>(mut t: T)
LL | | where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>
LL | | {
LL | | // OK -- now we have `T : for<'b> Bar&'b isize>`.
LL | | foo_hrtb_bar_hrtb(&mut t);
| | ------------------------- recursive call site
LL | | }
| |_^ cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose
error: aborting due to 2 previous errors

View File

@ -0,0 +1,10 @@
error[E0521]: borrowed data escapes outside of function
--> $DIR/dyn-trait.rs:20:5
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| - `x` is a reference that is only valid in the function body
LL | static_val(x);
| ^^^^^^^^^^^^^ `x` escapes the function body here
error: aborting due to previous error

View File

@ -1,5 +1,3 @@
#![feature(nll)]
// Regression test for #54593: the MIR type checker was going wrong
// when a closure returns the `impl Copy` from its parent fn. It was
// (incorrectly) replacing the `impl Copy` in its return type with the

View File

@ -0,0 +1,51 @@
error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:3:23
|
LL | fn elided(x: &i32) -> impl Copy { x }
| - ^^^^^^^^^ opaque type requires that `'1` must outlive `'static`
| |
| let's call the lifetime of this reference `'1`
help: to allow this impl Trait to capture borrowed data with lifetime `'1`, add `'_` as a constraint
|
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
| ^^^^^^^^^^^^^^
error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:6:32
|
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
| -- ^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
| |
| lifetime `'a` defined here
help: to allow this impl Trait to capture borrowed data with lifetime `'a`, add `'a` as a constraint
|
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
| ^^^^^^^^^^^^^^
error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:12:69
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`
error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:17:61
|
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
| -- -- lifetime `'b` defined here ^^^^^^^^^^^^^^^^ opaque type requires that `'b` must outlive `'a`
| |
| lifetime `'a` defined here
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:22:51
|
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
| ^^^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0310`.

View File

@ -9,7 +9,6 @@
#![allow(dead_code)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
fn foo(x: &'x u32) -> impl Fn() -> &'y u32
where 'x: 'y

View File

@ -9,7 +9,6 @@
#![allow(dead_code)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
trait Trait<'a> { }

View File

@ -5,7 +5,6 @@
#![allow(dead_code)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
use std::cell::Cell;

View File

@ -1,11 +1,11 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> $DIR/region-escape-via-bound.rs:16:29
--> $DIR/region-escape-via-bound.rs:15:29
|
LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y>
| ^^^^^^^^^^^^^^
|
note: hidden type `std::cell::Cell<&'x u32>` captures the lifetime 'x as defined on the function body at 18:7
--> $DIR/region-escape-via-bound.rs:18:7
note: hidden type `std::cell::Cell<&'x u32>` captures the lifetime 'x as defined on the function body at 17:7
--> $DIR/region-escape-via-bound.rs:17:7
|
LL | where 'x: 'y
| ^^

View File

@ -0,0 +1,26 @@
error: lifetime may not live long enough
--> $DIR/static-return-lifetime-infered.rs:6:35
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
| - ^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'1` must outlive `'static`
| |
| let's call the lifetime of this reference `'1`
help: to allow this impl Trait to capture borrowed data with lifetime `'1`, add `'_` as a constraint
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: lifetime may not live long enough
--> $DIR/static-return-lifetime-infered.rs:10:37
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
| -- ^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
| |
| lifetime `'a` defined here
help: to allow this impl Trait to capture borrowed data with lifetime `'a`, add `'a` as a constraint
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -0,0 +1,11 @@
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/type_parameters_captured.rs:7:20
|
LL | fn foo<T>(x: T) -> impl Any + 'static {
| ^^^^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0310`.

View File

@ -0,0 +1,20 @@
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/mismatched.rs:4:42
|
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y }
| ---- ^ lifetime `'a` required
| |
| help: add explicit lifetime `'a` to the type of `y`: `&'a u32`
error: lifetime may not live long enough
--> $DIR/mismatched.rs:6:46
|
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y }
| -- -- ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
| | |
| | lifetime `'b` defined here
| lifetime `'a` defined here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0621`.

View File

@ -0,0 +1,24 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 9:5...
--> $DIR/mismatched_trait_impl.rs:9:5
|
LL | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
LL | | x
LL | | }
| |_____^
note: ...but the lifetime must also be valid for the lifetime 'a as defined on the method body at 9:32...
--> $DIR/mismatched_trait_impl.rs:9:32
|
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
| ^^
= note: ...so that the method type is compatible with trait:
expected fn(&i32, &'a u32, &u32) -> &'a u32
found fn(&i32, &u32, &u32) -> &u32
error: aborting due to previous error

View File

@ -0,0 +1,11 @@
error: lifetime may not live long enough
--> $DIR/issue-10291.rs:3:9
|
LL | fn test<'x>(x: &'x isize) {
| -- lifetime `'x` defined here
LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
LL | x
| ^ returning this value requires that `'x` must outlive `'static`
error: aborting due to previous error

View File

@ -0,0 +1,12 @@
error[E0621]: explicit lifetime required in the type of `cont`
--> $DIR/issue-13058.rs:14:21
|
LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
| -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
LL | {
LL | let cont_iter = cont.iter();
| ^^^^^^^^^^^ lifetime `'r` required
error: aborting due to previous error
For more information about this error, try `rustc --explain E0621`.

View File

@ -0,0 +1,11 @@
error[E0621]: explicit lifetime required in the type of `lexer`
--> $DIR/issue-15034.rs:17:9
|
LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
| ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
LL | Parser { lexer: lexer }
| ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
error: aborting due to previous error
For more information about this error, try `rustc --explain E0621`.

View File

@ -0,0 +1,16 @@
error[E0005]: refutable pattern in `for` loop binding: `&[]` not covered
--> $DIR/issue-15381.rs:4:9
|
LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
| ^^^^^^^^ pattern `&[]` not covered
error[E0381]: borrow of possibly uninitialized variable: `y`
--> $DIR/issue-15381.rs:6:26
|
LL | println!("y={}", y);
| ^ use of possibly uninitialized `y`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0005, E0381.
For more information about an error, try `rustc --explain E0005`.

View File

@ -0,0 +1,10 @@
error[E0521]: borrowed data escapes outside of function
--> $DIR/issue-16683.rs:4:9
|
LL | fn b(&self) {
| ----- `self` is a reference that is only valid in the function body
LL | self.a();
| ^^^^^^^^ `self` escapes the function body here
error: aborting due to previous error

View File

@ -0,0 +1,21 @@
error[E0308]: match arms have incompatible types
--> $DIR/issue-17728.rs:109:14
|
LL | / match to_parse {
LL | | "w" | "west" => RoomDirection::West,
LL | | "e" | "east" => RoomDirection::East,
LL | | "n" | "north" => RoomDirection::North,
... |
LL | | "down" => RoomDirection::Down,
| | ------------------- this and all prior arms are found to be of type `RoomDirection`
LL | | _ => None
| | ^^^^ expected enum `RoomDirection`, found enum `std::option::Option`
LL | | }
| |_____- `match` arms have incompatible types
|
= note: expected type `RoomDirection`
found type `std::option::Option<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -0,0 +1,10 @@
error[E0521]: borrowed data escapes outside of function
--> $DIR/issue-17758.rs:7:9
|
LL | fn bar(&self) {
| ----- `self` is a reference that is only valid in the function body
LL | self.foo();
| ^^^^^^^^^^ `self` escapes the function body here
error: aborting due to previous error

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