Rollup merge of #58111 - Centril:libterm-2018, r=oli-obk
libterm => 2018
Transitions `libterm` to Rust 2018; cc #58099
r? @oli-obk
diff --git a/src/libarena/Cargo.toml b/src/libarena/Cargo.toml
index e2af67d..82fc64b 100644
--- a/src/libarena/Cargo.toml
+++ b/src/libarena/Cargo.toml
@@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "arena"
version = "0.0.0"
+edition = "2018"
[lib]
name = "arena"
@@ -9,4 +10,4 @@
crate-type = ["dylib"]
[dependencies]
-rustc_data_structures = { path = "../librustc_data_structures" }
\ No newline at end of file
+rustc_data_structures = { path = "../librustc_data_structures" }
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs
index aa522d8..8ae046c 100644
--- a/src/libarena/lib.rs
+++ b/src/libarena/lib.rs
@@ -11,17 +11,17 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
test(no_crate_inject, attr(deny(warnings))))]
+#![deny(rust_2018_idioms)]
+
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
-#![feature(nll)]
#![feature(raw_vec_internals)]
#![cfg_attr(test, feature(test))]
#![allow(deprecated)]
extern crate alloc;
-extern crate rustc_data_structures;
use rustc_data_structures::sync::MTLock;
@@ -476,7 +476,7 @@
#[cfg(test)]
mod tests {
extern crate test;
- use self::test::Bencher;
+ use test::Bencher;
use super::TypedArena;
use std::cell::Cell;
@@ -511,15 +511,15 @@
impl<'a> Wrap<'a> {
fn alloc_inner<F: Fn() -> Inner>(&self, f: F) -> &Inner {
- let r: &EI = self.0.alloc(EI::I(f()));
+ let r: &EI<'_> = self.0.alloc(EI::I(f()));
if let &EI::I(ref i) = r {
i
} else {
panic!("mismatch");
}
}
- fn alloc_outer<F: Fn() -> Outer<'a>>(&self, f: F) -> &Outer {
- let r: &EI = self.0.alloc(EI::O(f()));
+ fn alloc_outer<F: Fn() -> Outer<'a>>(&self, f: F) -> &Outer<'_> {
+ let r: &EI<'_> = self.0.alloc(EI::O(f()));
if let &EI::O(ref o) = r {
o
} else {
@@ -609,7 +609,7 @@
count: &'a Cell<u32>,
}
- impl<'a> Drop for DropCounter<'a> {
+ impl Drop for DropCounter<'_> {
fn drop(&mut self) {
self.count.set(self.count.get() + 1);
}
@@ -619,7 +619,7 @@
fn test_typed_arena_drop_count() {
let counter = Cell::new(0);
{
- let arena: TypedArena<DropCounter> = TypedArena::default();
+ let arena: TypedArena<DropCounter<'_>> = TypedArena::default();
for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak.
arena.alloc(DropCounter { count: &counter });
@@ -631,7 +631,7 @@
#[test]
fn test_typed_arena_drop_on_clear() {
let counter = Cell::new(0);
- let mut arena: TypedArena<DropCounter> = TypedArena::default();
+ let mut arena: TypedArena<DropCounter<'_>> = TypedArena::default();
for i in 0..10 {
for _ in 0..100 {
// Allocate something with drop glue to make sure it doesn't leak.
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
index e214814..3bb22d3 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
@@ -681,10 +681,13 @@
let (return_span, mir_description) = match tcx.hir().get(mir_node_id) {
hir::Node::Expr(hir::Expr {
- node: hir::ExprKind::Closure(_, _, _, span, gen_move),
+ node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
..
}) => (
- tcx.sess.source_map().end_point(*span),
+ match return_ty.output {
+ hir::FunctionRetTy::DefaultReturn(_) => tcx.sess.source_map().end_point(*span),
+ hir::FunctionRetTy::Return(_) => return_ty.output.span(),
+ },
if gen_move.is_some() {
" of generator"
} else {
diff --git a/src/test/ui/nll/issue-58053.rs b/src/test/ui/nll/issue-58053.rs
new file mode 100644
index 0000000..d433890
--- /dev/null
+++ b/src/test/ui/nll/issue-58053.rs
@@ -0,0 +1,14 @@
+#![allow(warnings)]
+#![feature(nll)]
+
+fn main() {
+ let i = &3;
+
+ let f = |x: &i32| -> &i32 { x };
+ //~^ ERROR lifetime may not live long enough
+ let j = f(i);
+
+ let g = |x: &i32| { x };
+ //~^ ERROR lifetime may not live long enough
+ let k = g(i);
+}
diff --git a/src/test/ui/nll/issue-58053.stderr b/src/test/ui/nll/issue-58053.stderr
new file mode 100644
index 0000000..9048983
--- /dev/null
+++ b/src/test/ui/nll/issue-58053.stderr
@@ -0,0 +1,20 @@
+error: lifetime may not live long enough
+ --> $DIR/issue-58053.rs:7:33
+ |
+LL | let f = |x: &i32| -> &i32 { x };
+ | - ---- ^ returning this value requires that `'1` must outlive `'2`
+ | | |
+ | | return type of closure is &'2 i32
+ | let's call the lifetime of this reference `'1`
+
+error: lifetime may not live long enough
+ --> $DIR/issue-58053.rs:11:25
+ |
+LL | let g = |x: &i32| { x };
+ | - - ^ returning this value requires that `'1` must outlive `'2`
+ | | |
+ | | return type of closure is &'2 i32
+ | let's call the lifetime of this reference `'1`
+
+error: aborting due to 2 previous errors
+