When picking a candidate, consider the unstable ones last.
If there is potential ambiguity after stabilizing those candidates, a warning will be emitted.
This commit is contained in:
parent
1731bf8049
commit
abf4d8babf
12 changed files with 316 additions and 40 deletions
24
src/test/ui/auxiliary/inference_unstable_iterator.rs
Normal file
24
src/test/ui/auxiliary/inference_unstable_iterator.rs
Normal file
|
|
@ -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 {}
|
||||
17
src/test/ui/auxiliary/inference_unstable_itertools.rs
Normal file
17
src/test/ui/auxiliary/inference_unstable_itertools.rs
Normal file
|
|
@ -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 {}
|
||||
29
src/test/ui/inference_unstable.rs
Normal file
29
src/test/ui/inference_unstable.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
12
src/test/ui/inference_unstable.stderr
Normal file
12
src/test/ui/inference_unstable.stderr
Normal file
|
|
@ -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`
|
||||
|
||||
27
src/test/ui/inference_unstable_featured.rs
Normal file
27
src/test/ui/inference_unstable_featured.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
12
src/test/ui/inference_unstable_featured.stderr
Normal file
12
src/test/ui/inference_unstable_featured.stderr
Normal file
|
|
@ -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`.
|
||||
22
src/test/ui/inference_unstable_forced.rs
Normal file
22
src/test/ui/inference_unstable_forced.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
11
src/test/ui/inference_unstable_forced.stderr
Normal file
11
src/test/ui/inference_unstable_forced.stderr
Normal file
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue