diff options
| author | kennytm <kennytm@gmail.com> | 2018-02-26 21:34:06 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-03-24 06:58:01 +0800 |
| commit | abf4d8babfebcdad66599c50bf5b6ae3e5bcbeb5 (patch) | |
| tree | dd6d8262326e6ced02103facdcb7680858022a0b /src/test | |
| parent | 1731bf8049258e63257f6dde48b375acafaeb4ef (diff) | |
| download | rust-abf4d8babfebcdad66599c50bf5b6ae3e5bcbeb5.tar.gz rust-abf4d8babfebcdad66599c50bf5b6ae3e5bcbeb5.zip | |
When picking a candidate, consider the unstable ones last.
If there is potential ambiguity after stabilizing those candidates, a warning will be emitted.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/auxiliary/inference_unstable_iterator.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/auxiliary/inference_unstable_itertools.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable_featured.rs | 27 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable_featured.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable_forced.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/inference_unstable_forced.stderr | 11 |
8 files changed, 154 insertions, 0 deletions
diff --git a/src/test/ui/auxiliary/inference_unstable_iterator.rs b/src/test/ui/auxiliary/inference_unstable_iterator.rs new file mode 100644 index 00000000000..b73346e6332 --- /dev/null +++ b/src/test/ui/auxiliary/inference_unstable_iterator.rs @@ -0,0 +1,24 @@ +// 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 <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. + +#![feature(staged_api)] + +#![stable(feature = "ipu_iterator", since = "1.0.0")] + +#[stable(feature = "ipu_iterator", since = "1.0.0")] +pub trait IpuIterator { + #[unstable(feature = "ipu_flatten", issue = "99999")] + fn ipu_flatten(&self) -> u32 { + 0 + } +} + +#[stable(feature = "ipu_iterator", since = "1.0.0")] +impl IpuIterator for char {} diff --git a/src/test/ui/auxiliary/inference_unstable_itertools.rs b/src/test/ui/auxiliary/inference_unstable_itertools.rs new file mode 100644 index 00000000000..2ad264ee3d8 --- /dev/null +++ b/src/test/ui/auxiliary/inference_unstable_itertools.rs @@ -0,0 +1,17 @@ +// 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 <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. + +pub trait IpuItertools { + fn ipu_flatten(&self) -> u32 { + 1 + } +} + +impl IpuItertools for char {} diff --git a/src/test/ui/inference_unstable.rs b/src/test/ui/inference_unstable.rs new file mode 100644 index 00000000000..525fda33955 --- /dev/null +++ b/src/test/ui/inference_unstable.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 <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. + +// Ensures #[unstable] functions without opting in the corresponding #![feature] +// will not break inference. + +// aux-build:inference_unstable_iterator.rs +// aux-build:inference_unstable_itertools.rs +// run-pass + +extern crate inference_unstable_iterator; +extern crate inference_unstable_itertools; + +#[allow(unused_imports)] +use inference_unstable_iterator::IpuIterator; +use inference_unstable_itertools::IpuItertools; + +fn main() { + assert_eq!('x'.ipu_flatten(), 1); + //~^ WARN a method with this name will be added to the standard library in the future + //~^^ WARN it will become a hard error in a future release +} diff --git a/src/test/ui/inference_unstable.stderr b/src/test/ui/inference_unstable.stderr new file mode 100644 index 00000000000..a5cf4d6dff3 --- /dev/null +++ b/src/test/ui/inference_unstable.stderr @@ -0,0 +1,12 @@ +warning: a method with this name will be added to the standard library in the future + --> $DIR/inference_unstable.rs:26:20 + | +LL | assert_eq!('x'.ipu_flatten(), 1); + | ^^^^^^^^^^^ + | + = note: #[warn(unstable_name_collision)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see pr #48552 <https://github.com/rust-lang/rust/pull/48552> + = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method + = note: add #![feature(ipu_flatten)] to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten` + diff --git a/src/test/ui/inference_unstable_featured.rs b/src/test/ui/inference_unstable_featured.rs new file mode 100644 index 00000000000..f5c49bedc71 --- /dev/null +++ b/src/test/ui/inference_unstable_featured.rs @@ -0,0 +1,27 @@ +// 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 <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. + +// There should be E0034 "multiple applicable items in scope" if we opt-in for +// the feature. + +// aux-build:inference_unstable_iterator.rs +// aux-build:inference_unstable_itertools.rs + +#![feature(ipu_flatten)] + +extern crate inference_unstable_iterator; +extern crate inference_unstable_itertools; + +use inference_unstable_iterator::IpuIterator; +use inference_unstable_itertools::IpuItertools; + +fn main() { + assert_eq!('x'.ipu_flatten(), 0); //~ ERROR E0034 +} diff --git a/src/test/ui/inference_unstable_featured.stderr b/src/test/ui/inference_unstable_featured.stderr new file mode 100644 index 00000000000..cb5f3623291 --- /dev/null +++ b/src/test/ui/inference_unstable_featured.stderr @@ -0,0 +1,12 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/inference_unstable_featured.rs:26:20 + | +LL | assert_eq!('x'.ipu_flatten(), 0); //~ ERROR E0034 + | ^^^^^^^^^^^ multiple `ipu_flatten` found + | + = note: candidate #1 is defined in an impl of the trait `inference_unstable_iterator::IpuIterator` for the type `char` + = note: candidate #2 is defined in an impl of the trait `inference_unstable_itertools::IpuItertools` for the type `char` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/src/test/ui/inference_unstable_forced.rs b/src/test/ui/inference_unstable_forced.rs new file mode 100644 index 00000000000..82ce4034ce2 --- /dev/null +++ b/src/test/ui/inference_unstable_forced.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 <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. + +// If the unstable API is the only possible solution, +// still emit E0658 "use of unstable library feature". + +// aux-build:inference_unstable_iterator.rs + +extern crate inference_unstable_iterator; + +use inference_unstable_iterator::IpuIterator; + +fn main() { + assert_eq!('x'.ipu_flatten(), 0); //~ ERROR E0658 +} diff --git a/src/test/ui/inference_unstable_forced.stderr b/src/test/ui/inference_unstable_forced.stderr new file mode 100644 index 00000000000..00eb81cd9a2 --- /dev/null +++ b/src/test/ui/inference_unstable_forced.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'ipu_flatten' (see issue #99999) + --> $DIR/inference_unstable_forced.rs:21:20 + | +LL | assert_eq!('x'.ipu_flatten(), 0); //~ ERROR E0658 + | ^^^^^^^^^^^ + | + = help: add #![feature(ipu_flatten)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. |
