PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/compile-fail/rfc1214-warn-and-error.rs

https://github.com/paulstansifer/rust
Rust | 37 lines | 13 code | 9 blank | 15 comment | 0 complexity | 8d0b6adc45a7927bf449ded60c6779e7 MD5 | raw file
Possible License(s): 0BSD, Apache-2.0, MIT, AGPL-1.0
  1. // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. // Test that an RFC1214 warning from an earlier function (`foo`) does
  11. // not suppress an error for the same problem (`WantEq<NotEq>`,
  12. // `NotEq: !Eq`) in a later function (`bar)`. Earlier versions of the
  13. // warning mechanism had an issue due to caching.
  14. #![allow(dead_code)]
  15. #![allow(unused_variables)]
  16. struct WantEq<T:Eq> { t: T }
  17. struct NotEq;
  18. trait Trait<T> { }
  19. fn foo() {
  20. let x: Box<Trait<WantEq<NotEq>>> = loop { };
  21. //~^ WARN E0277
  22. }
  23. fn bar() {
  24. wf::<WantEq<NotEq>>();
  25. //~^ ERROR E0277
  26. }
  27. fn wf<T>() { }
  28. fn main() { }