Warn about more ignored bounds on type aliases
This commit is contained in:
parent
c83dd03062
commit
2aae22746e
5 changed files with 68 additions and 22 deletions
|
|
@ -13,7 +13,7 @@
|
|||
#![feature(unsized_tuple_coercion)]
|
||||
|
||||
type Fat<T: ?Sized> = (isize, &'static str, T);
|
||||
//~^ WARNING trait bounds are not (yet) enforced
|
||||
//~^ WARNING bounds are ignored
|
||||
|
||||
#[derive(PartialEq,Eq)]
|
||||
struct Bar;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ mod traits {
|
|||
pub trait PubTr {}
|
||||
|
||||
pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
|
||||
//~^ WARN trait bounds are not (yet) enforced in type definitions
|
||||
//~^ WARN bounds are ignored in type aliases
|
||||
//~| WARNING hard error
|
||||
pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
|
||||
//~^ WARNING hard error
|
||||
|
|
|
|||
33
src/test/ui/param-bounds-ignored.rs
Normal file
33
src/test/ui/param-bounds-ignored.rs
Normal file
|
|
@ -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 <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.
|
||||
|
||||
// must-compile-successfully
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
type SVec<T: Send> = Vec<T>;
|
||||
type VVec<'b, 'a: 'b> = Vec<&'a i32>;
|
||||
type WVec<'b, T: 'b> = Vec<T>;
|
||||
|
||||
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);
|
||||
}
|
||||
18
src/test/ui/param-bounds-ignored.stderr
Normal file
18
src/test/ui/param-bounds-ignored.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
warning[E0122]: bounds are ignored in type aliases
|
||||
--> $DIR/param-bounds-ignored.rs:15:1
|
||||
|
|
||||
15 | type SVec<T: Send> = Vec<T>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
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<T>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue