X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fui%2Fmin_max.rs;h=f7ed72a11cf684b64f8d584cbaa990ae4aa0fa39;hb=87e740921abd4132152f090545fa4c9ed9fa0d6d;hp=32e3863ad40750afa1478bcbd4c1cd44d8c10b38;hpb=e9c025ea70f9297836d62e0f0c959b9359a8035a;p=rust.git diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index 32e3863ad40..f7ed72a11cf 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -1,23 +1,22 @@ -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution. -// -// 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. +#![warn(clippy::all)] +use std::cmp::max as my_max; +use std::cmp::min as my_min; +use std::cmp::{max, min}; -#![feature(tool_lints)] +const LARGE: usize = 3; +struct NotOrd(u64); -#![warn(clippy::all)] - -use std::cmp::{min, max}; -use std::cmp::min as my_min; -use std::cmp::max as my_max; +impl NotOrd { + fn min(self, x: u64) -> NotOrd { + NotOrd(x) + } -const LARGE : usize = 3; + fn max(self, x: u64) -> NotOrd { + NotOrd(x) + } +} fn main() { let x; @@ -43,4 +42,24 @@ fn main() { max(min(s, "Apple"), "Zoo"); max("Apple", min(s, "Zoo")); // ok + + let f = 3f32; + x.min(1).max(3); + x.max(3).min(1); + f.max(3f32).min(1f32); + + x.max(1).min(3); // ok + x.min(3).max(1); // ok + f.min(3f32).max(1f32); // ok + + max(x.min(1), 3); + min(x.max(1), 3); // ok + + s.max("Zoo").min("Apple"); + s.min("Apple").max("Zoo"); + + s.min("Zoo").max("Apple"); // ok + + let not_ord = NotOrd(1); + not_ord.min(1).max(3); // ok }