Skip to content

Commit

Permalink
Add regression test for issue 90320
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Nov 15, 2021
1 parent 6a207f2 commit 6ad626f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/inference/auxiliary/inference_unstable_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(staged_api)]
#![feature(arbitrary_self_types)]

#![stable(feature = "ipu_iterator", since = "1.0.0")]

Expand All @@ -8,6 +9,22 @@ pub trait IpuIterator {
fn ipu_flatten(&self) -> u32 {
0
}

#[unstable(feature = "ipu_flatten", issue = "99999")]
fn ipu_by_value_vs_by_ref(self) -> u32 where Self: Sized {
0
}

#[unstable(feature = "ipu_flatten", issue = "99999")]
fn ipu_by_ref_vs_by_ref_mut(&self) -> u32 {
0
}

#[unstable(feature = "ipu_flatten", issue = "99999")]
fn ipu_by_mut_ptr_vs_by_const_ptr(self: *mut Self) -> u32 {
0
}

#[unstable(feature = "assoc_const_ipu_iter", issue = "99999")]
const C: i32;
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/inference/auxiliary/inference_unstable_itertools.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#![feature(arbitrary_self_types)]

pub trait IpuItertools {
fn ipu_flatten(&self) -> u32 {
1
}

fn ipu_by_value_vs_by_ref(&self) -> u32 {
1
}

fn ipu_by_ref_vs_by_ref_mut(&mut self) -> u32 {
1
}

fn ipu_by_mut_ptr_vs_by_const_ptr(self: *const Self) -> u32 {
1
}

const C: i32;
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/inference/inference_unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ use inference_unstable_itertools::IpuItertools;
fn main() {
assert_eq!('x'.ipu_flatten(), 1);
//~^ WARN an associated function with this name may be added to the standard library in the future
//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
assert_eq!('x'.ipu_by_value_vs_by_ref(), 1);
//~^ WARN an associated function with this name may be added to the standard library in the future
//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
assert_eq!('x'.ipu_by_ref_vs_by_ref_mut(), 1);
//~^ WARN an associated function with this name may be added to the standard library in the future
//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
assert_eq!((&mut 'x' as *mut char).ipu_by_mut_ptr_vs_by_const_ptr(), 1);
//~^ WARN an associated function with this name may be added to the standard library in the future
//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
assert_eq!(char::C, 1);
//~^ WARN an associated constant with this name may be added to the standard library in the future
Expand Down
37 changes: 35 additions & 2 deletions src/test/ui/inference/inference_unstable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,41 @@ LL | assert_eq!('x'.ipu_flatten(), 1);
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method
= help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten`

warning: an associated function with this name may be added to the standard library in the future
--> $DIR/inference_unstable.rs:19:20
|
LL | assert_eq!('x'.ipu_by_value_vs_by_ref(), 1);
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_value_vs_by_ref(...)` to keep using the current method
= help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_value_vs_by_ref`

warning: an associated function with this name may be added to the standard library in the future
--> $DIR/inference_unstable.rs:22:20
|
LL | assert_eq!('x'.ipu_by_ref_vs_by_ref_mut(), 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_ref_vs_by_ref_mut(...)` to keep using the current method
= help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_ref_vs_by_ref_mut`

warning: an associated function with this name may be added to the standard library in the future
--> $DIR/inference_unstable.rs:25:40
|
LL | assert_eq!((&mut 'x' as *mut char).ipu_by_mut_ptr_vs_by_const_ptr(), 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_mut_ptr_vs_by_const_ptr(...)` to keep using the current method
= help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_mut_ptr_vs_by_const_ptr`

warning: an associated constant with this name may be added to the standard library in the future
--> $DIR/inference_unstable.rs:19:16
--> $DIR/inference_unstable.rs:28:16
|
LL | assert_eq!(char::C, 1);
| ^^^^^^^ help: use the fully qualified path to the associated const: `<char as IpuItertools>::C`
Expand All @@ -20,5 +53,5 @@ LL | assert_eq!(char::C, 1);
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: add `#![feature(assoc_const_ipu_iter)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::C`

warning: 2 warnings emitted
warning: 5 warnings emitted

0 comments on commit 6ad626f

Please sign in to comment.