From 2aae22746e70eea96b0959f6e7b603576e14f3bb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 5 Feb 2018 21:20:57 +0100 Subject: Warn about more ignored bounds on type aliases --- src/test/ui/param-bounds-ignored.rs | 33 +++++++++++++++++++++++++++++++++ src/test/ui/param-bounds-ignored.stderr | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/test/ui/param-bounds-ignored.rs create mode 100644 src/test/ui/param-bounds-ignored.stderr (limited to 'src/test/ui') diff --git a/src/test/ui/param-bounds-ignored.rs b/src/test/ui/param-bounds-ignored.rs new file mode 100644 index 00000000000..9e09102f2d4 --- /dev/null +++ b/src/test/ui/param-bounds-ignored.rs @@ -0,0 +1,33 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +use std::rc::Rc; + +type SVec = Vec; +type VVec<'b, 'a: 'b> = Vec<&'a i32>; +type WVec<'b, T: 'b> = Vec; + +fn foo<'a>(y: &'a i32) { + // If the bounds above would matter, the code below would be rejected. + let mut x : SVec<_> = Vec::new(); + x.push(Rc::new(42)); + + let mut x : VVec<'static, 'a> = Vec::new(); + x.push(y); + + let mut x : WVec<'static, & 'a i32> = Vec::new(); + x.push(y); +} + +fn main() { + foo(&42); +} diff --git a/src/test/ui/param-bounds-ignored.stderr b/src/test/ui/param-bounds-ignored.stderr new file mode 100644 index 00000000000..a14d416aaa7 --- /dev/null +++ b/src/test/ui/param-bounds-ignored.stderr @@ -0,0 +1,18 @@ +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:15:1 + | +15 | type SVec = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:16:1 + | +16 | type VVec<'b, 'a: 'b> = Vec<&'a i32>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:17:1 + | +17 | type WVec<'b, T: 'b> = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + -- cgit 1.4.1-3-g733a5