From 9b0dfe184e0d3a5fd607c01e0c861a4b601f32a7 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 6 May 2018 22:54:00 +0100 Subject: [PATCH] Add tests for trivial bounds --- ...ounds-inconsistent-associated-functions.rs | 29 +++++ ...s-inconsistent-associated-functions.stderr | 0 ...unds-inconsistent-copy-reborrow.nll.stderr | 19 +++ ...ivial-bounds-inconsistent-copy-reborrow.rs | 23 ++++ ...l-bounds-inconsistent-copy-reborrow.stderr | 19 +++ .../ui/trivial-bounds-inconsistent-copy.rs | 43 +++++++ .../trivial-bounds-inconsistent-copy.stderr | 41 +++++++ .../ui/trivial-bounds-inconsistent-sized.rs | 34 ++++++ .../trivial-bounds-inconsistent-sized.stderr | 24 ++++ ...trivial-bounds-inconsistent-well-formed.rs | 22 ++++ ...ial-bounds-inconsistent-well-formed.stderr | 20 ++++ src/test/ui/trivial-bounds-inconsistent.rs | 81 +++++++++++++ .../ui/trivial-bounds-inconsistent.stderr | 112 ++++++++++++++++++ src/test/ui/trivial-bounds-leak-copy.rs | 22 ++++ src/test/ui/trivial-bounds-leak-copy.stderr | 9 ++ src/test/ui/trivial-bounds-leak.rs | 42 +++++++ src/test/ui/trivial-bounds-leak.stderr | 47 ++++++++ 17 files changed, 587 insertions(+) create mode 100644 src/test/ui/trivial-bounds-inconsistent-associated-functions.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent-associated-functions.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent-copy-reborrow.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent-copy-reborrow.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent-copy.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent-copy.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent-sized.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent-sized.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent-well-formed.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent-well-formed.stderr create mode 100644 src/test/ui/trivial-bounds-inconsistent.rs create mode 100644 src/test/ui/trivial-bounds-inconsistent.stderr create mode 100644 src/test/ui/trivial-bounds-leak-copy.rs create mode 100644 src/test/ui/trivial-bounds-leak-copy.stderr create mode 100644 src/test/ui/trivial-bounds-leak.rs create mode 100644 src/test/ui/trivial-bounds-leak.stderr diff --git a/src/test/ui/trivial-bounds-inconsistent-associated-functions.rs b/src/test/ui/trivial-bounds-inconsistent-associated-functions.rs new file mode 100644 index 00000000000..49c9df95bc7 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-associated-functions.rs @@ -0,0 +1,29 @@ +// Copyright 2018 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. + +// run-pass +// Inconsistent bounds with trait implementations + +#![feature(trivial_bounds)] +#![allow(unused)] + +trait A { + fn foo(&self) -> Self where Self: Copy; +} + +impl A for str { + fn foo(&self) -> Self where Self: Copy { *"" } +} + +impl A for i32 { + fn foo(&self) -> Self { 3 } +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent-associated-functions.stderr b/src/test/ui/trivial-bounds-inconsistent-associated-functions.stderr new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr new file mode 100644 index 00000000000..66547863db2 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.nll.stderr @@ -0,0 +1,19 @@ +error[E0596]: cannot borrow immutable item `**t` as mutable + --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:16:5 + | +LL | *t //~ ERROR + | ^^ cannot borrow as mutable + | + = note: the value which is causing this path not to be mutable is...: `*t` + +error[E0596]: cannot borrow immutable item `**t` as mutable + --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:20:6 + | +LL | {*t} //~ ERROR + | ^^ cannot borrow as mutable + | + = note: the value which is causing this path not to be mutable is...: `*t` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.rs b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.rs new file mode 100644 index 00000000000..2c4d9d81385 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.rs @@ -0,0 +1,23 @@ +// Copyright 2018 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. + +// Check that reborrows are still illegal with Copy mutable references +#![feature(trivial_bounds)] +#![allow(unused)] + +fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { + *t //~ ERROR +} + +fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { + {*t} //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.stderr b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.stderr new file mode 100644 index 00000000000..bea2bb66857 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-copy-reborrow.stderr @@ -0,0 +1,19 @@ +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:16:5 + | +LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { + | --------------- use `&'a mut &'a mut i32` here to make mutable +LL | *t //~ ERROR + | ^^ assignment into an immutable reference + +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:20:6 + | +LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { + | --------------- use `&'a mut &'a mut i32` here to make mutable +LL | {*t} //~ ERROR + | ^^ assignment into an immutable reference + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0389`. diff --git a/src/test/ui/trivial-bounds-inconsistent-copy.rs b/src/test/ui/trivial-bounds-inconsistent-copy.rs new file mode 100644 index 00000000000..375885a02c7 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-copy.rs @@ -0,0 +1,43 @@ +// Copyright 2018 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. + +// run-pass +// Check tautalogically false `Copy` bounds +#![feature(trivial_bounds)] +#![allow(unused)] + +fn copy_string(t: String) -> String where String: Copy { + is_copy(&t); + let x = t; + drop(t); + t +} + +fn copy_out_string(t: &String) -> String where String: Copy { + *t +} + +fn copy_string_with_param(x: String) where String: Copy { + let y = x; + let z = x; +} + +// Check that no reborrowing occurs +fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy { + is_copy(t); + let x = *t; + drop(x); + x +} + +fn is_copy(t: &T) {} + + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent-copy.stderr b/src/test/ui/trivial-bounds-inconsistent-copy.stderr new file mode 100644 index 00000000000..ae639005756 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-copy.stderr @@ -0,0 +1,41 @@ +warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-copy.rs:16:1 + | +LL | / fn copy_string(t: String) -> String where String: Copy { +LL | | is_copy(&t); +LL | | let x = t; +LL | | drop(t); +LL | | t +LL | | } + | |_^ + | + = note: #[warn(trivial_bounds)] on by default + +warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-copy.rs:23:1 + | +LL | / fn copy_out_string(t: &String) -> String where String: Copy { +LL | | *t +LL | | } + | |_^ + +warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-copy.rs:27:1 + | +LL | / fn copy_string_with_param(x: String) where String: Copy { +LL | | let y = x; +LL | | let z = x; +LL | | } + | |_^ + +warning: Trait bound for<'b> &'b mut i32: std::marker::Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-copy.rs:33:1 + | +LL | / fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy { +LL | | is_copy(t); +LL | | let x = *t; +LL | | drop(x); +LL | | x +LL | | } + | |_^ + diff --git a/src/test/ui/trivial-bounds-inconsistent-sized.rs b/src/test/ui/trivial-bounds-inconsistent-sized.rs new file mode 100644 index 00000000000..14ba11c44de --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-sized.rs @@ -0,0 +1,34 @@ +// Copyright 2018 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. + +// run-pass +// Check tautalogically false `Sized` bounds +#![feature(trivial_bounds)] +#![allow(unused)] + +trait A {} + +impl A for i32 {} + +struct T { + x: X, +} + +struct S(str, str) where str: Sized; + +fn unsized_local() where for<'a> T: Sized { + let x: T = *(Box::new(T { x: 1 }) as Box>); +} + +fn return_str() -> str where str: Sized { + *"Sized".to_string().into_boxed_str() +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent-sized.stderr b/src/test/ui/trivial-bounds-inconsistent-sized.stderr new file mode 100644 index 00000000000..ee2ff7d7861 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-sized.stderr @@ -0,0 +1,24 @@ +warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-sized.rs:24:1 + | +LL | struct S(str, str) where str: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(trivial_bounds)] on by default + +warning: Trait bound for<'a> T: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-sized.rs:26:1 + | +LL | / fn unsized_local() where for<'a> T: Sized { +LL | | let x: T = *(Box::new(T { x: 1 }) as Box>); +LL | | } + | |_^ + +warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-sized.rs:30:1 + | +LL | / fn return_str() -> str where str: Sized { +LL | | *"Sized".to_string().into_boxed_str() +LL | | } + | |_^ + diff --git a/src/test/ui/trivial-bounds-inconsistent-well-formed.rs b/src/test/ui/trivial-bounds-inconsistent-well-formed.rs new file mode 100644 index 00000000000..5fcdbfc437a --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-well-formed.rs @@ -0,0 +1,22 @@ +// Copyright 2018 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. + +// run-pass +// Test that inconsistent bounds are used in well-formedness checks +#![feature(trivial_bounds)] + +use std::fmt::Debug; + +pub fn foo() where Vec: Debug, str: Copy { + let x = vec![*"1"]; + println!("{:?}", x); +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent-well-formed.stderr b/src/test/ui/trivial-bounds-inconsistent-well-formed.stderr new file mode 100644 index 00000000000..b51ecd49900 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent-well-formed.stderr @@ -0,0 +1,20 @@ +warning: Trait bound std::vec::Vec: std::fmt::Debug does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:1 + | +LL | / pub fn foo() where Vec: Debug, str: Copy { +LL | | let x = vec![*"1"]; +LL | | println!("{:?}", x); +LL | | } + | |_^ + | + = note: #[warn(trivial_bounds)] on by default + +warning: Trait bound str: std::marker::Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:1 + | +LL | / pub fn foo() where Vec: Debug, str: Copy { +LL | | let x = vec![*"1"]; +LL | | println!("{:?}", x); +LL | | } + | |_^ + diff --git a/src/test/ui/trivial-bounds-inconsistent.rs b/src/test/ui/trivial-bounds-inconsistent.rs new file mode 100644 index 00000000000..2c8b873b8c9 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent.rs @@ -0,0 +1,81 @@ +// Copyright 2018 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. + +// run-pass + +// Check that tautalogically false bounds are accepted, and are used +// in type inference. +#![feature(trivial_bounds)] +#![allow(unused)] + +pub trait Foo { + fn test(&self); +} + +fn generic_function(x: X) {} + +enum E where i32: Foo { V } + +struct S where i32: Foo; + +trait T where i32: Foo {} + +union U where i32: Foo { f: i32 } + +type Y where i32: Foo = (); + +impl Foo for () where i32: Foo { + fn test(&self) { + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); + } +} + +fn f() where i32: Foo { + let s = S; + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); +} + +fn g() where &'static str: Foo { + "Foo".test(); + Foo::test(&"Foo"); + generic_function("Foo"); +} + +trait A {} + +impl A for i32 {} + +struct Dst { + x: X, +} + +struct TwoStrs(str, str) where str: Sized; + +fn unsized_local() where for<'a> Dst: Sized { + let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); +} + +fn return_str() -> str where str: Sized { + *"Sized".to_string().into_boxed_str() +} + +fn use_op(s: String) -> String where String: ::std::ops::Neg { + -s +} + +fn use_for() where i32: Iterator { + for _ in 2i32 {} +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-inconsistent.stderr b/src/test/ui/trivial-bounds-inconsistent.stderr new file mode 100644 index 00000000000..ee3c7518294 --- /dev/null +++ b/src/test/ui/trivial-bounds-inconsistent.stderr @@ -0,0 +1,112 @@ +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:24:1 + | +LL | enum E where i32: Foo { V } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(trivial_bounds)] on by default + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:26:1 + | +LL | struct S where i32: Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:28:1 + | +LL | trait T where i32: Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:30:1 + | +LL | union U where i32: Foo { f: i32 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: where clauses are not enforced in type aliases + --> $DIR/trivial-bounds-inconsistent.rs:32:14 + | +LL | type Y where i32: Foo = (); + | ^^^^^^^^ + | + = note: #[warn(type_alias_bounds)] on by default + = help: the clause will not be checked when the type alias is used, and should be removed + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:32:1 + | +LL | type Y where i32: Foo = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:34:1 + | +LL | / impl Foo for () where i32: Foo { +LL | | fn test(&self) { +LL | | 3i32.test(); +LL | | Foo::test(&4i32); +LL | | generic_function(5i32); +LL | | } +LL | | } + | |_^ + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:42:1 + | +LL | / fn f() where i32: Foo { +LL | | let s = S; +LL | | 3i32.test(); +LL | | Foo::test(&4i32); +LL | | generic_function(5i32); +LL | | } + | |_^ + +warning: Trait bound &'static str: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:49:1 + | +LL | / fn g() where &'static str: Foo { +LL | | "Foo".test(); +LL | | Foo::test(&"Foo"); +LL | | generic_function("Foo"); +LL | | } + | |_^ + +warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:63:1 + | +LL | struct TwoStrs(str, str) where str: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Trait bound for<'a> Dst: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:65:1 + | +LL | / fn unsized_local() where for<'a> Dst: Sized { +LL | | let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); +LL | | } + | |_^ + +warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:69:1 + | +LL | / fn return_str() -> str where str: Sized { +LL | | *"Sized".to_string().into_boxed_str() +LL | | } + | |_^ + +warning: Trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:73:1 + | +LL | / fn use_op(s: String) -> String where String: ::std::ops::Neg { +LL | | -s +LL | | } + | |_^ + +warning: Trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:77:1 + | +LL | / fn use_for() where i32: Iterator { +LL | | for _ in 2i32 {} +LL | | } + | |_^ + diff --git a/src/test/ui/trivial-bounds-leak-copy.rs b/src/test/ui/trivial-bounds-leak-copy.rs new file mode 100644 index 00000000000..9850ec2bd1f --- /dev/null +++ b/src/test/ui/trivial-bounds-leak-copy.rs @@ -0,0 +1,22 @@ +// Copyright 2018 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. + +// Check that false Copy bounds don't leak +#![feature(trivial_bounds)] + +fn copy_out_string(t: &String) -> String where String: Copy { + *t +} + +fn move_out_string(t: &String) -> String { + *t //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/trivial-bounds-leak-copy.stderr b/src/test/ui/trivial-bounds-leak-copy.stderr new file mode 100644 index 00000000000..3c3fcbf9b80 --- /dev/null +++ b/src/test/ui/trivial-bounds-leak-copy.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/trivial-bounds-leak-copy.rs:19:5 + | +LL | *t //~ ERROR + | ^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/trivial-bounds-leak.rs b/src/test/ui/trivial-bounds-leak.rs new file mode 100644 index 00000000000..98cb5b2b503 --- /dev/null +++ b/src/test/ui/trivial-bounds-leak.rs @@ -0,0 +1,42 @@ +// Copyright 2018 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. + +// Check that false bounds don't leak +#![feature(trivial_bounds)] + +pub trait Foo { + fn test(&self); +} + +fn return_str() -> str where str: Sized { + *"Sized".to_string().into_boxed_str() +} + +fn cant_return_str() -> str { //~ ERROR + *"Sized".to_string().into_boxed_str() +} + +fn my_function() where i32: Foo +{ + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); +} + +fn foo() { + 3i32.test(); //~ ERROR + Foo::test(&4i32); //~ ERROR + generic_function(5i32); //~ ERROR +} + +fn generic_function(t: T) {} + +fn main() {} + diff --git a/src/test/ui/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds-leak.stderr new file mode 100644 index 00000000000..df91ba0dd2a --- /dev/null +++ b/src/test/ui/trivial-bounds-leak.stderr @@ -0,0 +1,47 @@ +error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied + --> $DIR/trivial-bounds-leak.rs:22:25 + | +LL | fn cant_return_str() -> str { //~ ERROR + | ^^^ `str` does not have a constant size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: the return type of a function must have a statically known size + +error[E0599]: no method named `test` found for type `i32` in the current scope + --> $DIR/trivial-bounds-leak.rs:34:10 + | +LL | 3i32.test(); //~ ERROR + | ^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `test`, perhaps you need to implement it: + candidate #1: `Foo` + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/trivial-bounds-leak.rs:35:5 + | +LL | Foo::test(&4i32); //~ ERROR + | ^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | +note: required by `Foo::test` + --> $DIR/trivial-bounds-leak.rs:15:5 + | +LL | fn test(&self); + | ^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/trivial-bounds-leak.rs:36:5 + | +LL | generic_function(5i32); //~ ERROR + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | +note: required by `generic_function` + --> $DIR/trivial-bounds-leak.rs:39:1 + | +LL | fn generic_function(t: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. -- 2.44.0