add ui test for fn items, tidy fixes

This commit is contained in:
gaurikholkar 2017-09-12 16:48:01 +05:30
parent a128051f87
commit 93529b40ca
4 changed files with 25 additions and 5 deletions

View File

@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
self.depth -= 1;
return;
}
hir::TyRptr(ref lifetime, _) => {
// the lifetime of the TyRptr
let hir_id = self.infcx.tcx.hir.node_to_hir_id(lifetime.id);

View File

@ -11,11 +11,7 @@
struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
fn foo(mut y: Ref, x: &u32) {
<<<<<<< HEAD
y.b = x;
=======
x = y.b;
>>>>>>> Adding E0623 for structs
}
fn main() { }

View File

@ -0,0 +1,14 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
y.push(z);
}
fn main() { }

View File

@ -0,0 +1,10 @@
error[E0623]: lifetime mismatch
--> src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs:11:10
|
10 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
| --- --- these two types are declared with different lifetimes...
11 | y.push(z);
| ^ ...but data from `z` flows into `y` here
error: aborting due to previous error