Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
78a7d1c6
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78a7d1c6
编写于
8月 30, 2021
作者:
M
Mara Bos
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add and update tests.
上级
e2abf068
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
20 deletion
+96
-20
src/test/ui/rust-2021/future-prelude-collision-generic-trait.fixed
...ui/rust-2021/future-prelude-collision-generic-trait.fixed
+30
-0
src/test/ui/rust-2021/future-prelude-collision-generic-trait.rs
...st/ui/rust-2021/future-prelude-collision-generic-trait.rs
+30
-0
src/test/ui/rust-2021/future-prelude-collision-generic-trait.stderr
...i/rust-2021/future-prelude-collision-generic-trait.stderr
+16
-0
src/test/ui/rust-2021/future-prelude-collision-generic.fixed
src/test/ui/rust-2021/future-prelude-collision-generic.fixed
+8
-8
src/test/ui/rust-2021/future-prelude-collision-generic.rs
src/test/ui/rust-2021/future-prelude-collision-generic.rs
+7
-7
src/test/ui/rust-2021/future-prelude-collision-generic.stderr
...test/ui/rust-2021/future-prelude-collision-generic.stderr
+5
-5
未找到文件。
src/test/ui/rust-2021/future-prelude-collision-generic-trait.fixed
0 → 100644
浏览文件 @
78a7d1c6
// See https://github.com/rust-lang/rust/issues/88470
// run-rustfix
// edition:2018
// check-pass
#![warn(rust_2021_prelude_collisions)]
#![allow(dead_code)]
#![allow(unused_imports)]
pub trait PyTryFrom<'v, T>: Sized {
fn try_from<V>(value: V) -> Result<&'v Self, T>;
}
pub trait PyTryInto<T>: Sized {
fn try_into(&self) -> Result<&T, i32>;
}
struct Foo;
impl<U> PyTryInto<U> for Foo
where
U: for<'v> PyTryFrom<'v, i32>,
{
fn try_into(&self) -> Result<&U, i32> {
<U as PyTryFrom<'_, _>>::try_from(self)
//~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
}
fn main() {}
src/test/ui/rust-2021/future-prelude-collision-generic-trait.rs
0 → 100644
浏览文件 @
78a7d1c6
// See https://github.com/rust-lang/rust/issues/88470
// run-rustfix
// edition:2018
// check-pass
#![warn(rust_2021_prelude_collisions)]
#![allow(dead_code)]
#![allow(unused_imports)]
pub
trait
PyTryFrom
<
'v
,
T
>
:
Sized
{
fn
try_from
<
V
>
(
value
:
V
)
->
Result
<&
'v
Self
,
T
>
;
}
pub
trait
PyTryInto
<
T
>
:
Sized
{
fn
try_into
(
&
self
)
->
Result
<&
T
,
i32
>
;
}
struct
Foo
;
impl
<
U
>
PyTryInto
<
U
>
for
Foo
where
U
:
for
<
'v
>
PyTryFrom
<
'v
,
i32
>
,
{
fn
try_into
(
&
self
)
->
Result
<&
U
,
i32
>
{
U
::
try_from
(
self
)
//~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
}
fn
main
()
{}
src/test/ui/rust-2021/future-prelude-collision-generic-trait.stderr
0 → 100644
浏览文件 @
78a7d1c6
warning: trait-associated function `try_from` will become ambiguous in Rust 2021
--> $DIR/future-prelude-collision-generic-trait.rs:24:9
|
LL | U::try_from(self)
| ^^^^^^^^^^^ help: disambiguate the associated function: `<U as PyTryFrom<'_, _>>::try_from`
|
note: the lint level is defined here
--> $DIR/future-prelude-collision-generic-trait.rs:5:9
|
LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
warning: 1 warning emitted
src/test/ui/rust-2021/future-prelude-collision-generic.fixed
浏览文件 @
78a7d1c6
...
...
@@ -6,32 +6,32 @@
#![allow(dead_code)]
#![allow(unused_imports)]
struct Generic<
T, U>(T,
U);
struct Generic<
'a, U>(&'a
U);
trait MyFromIter {
fn from_iter(_: i32) -> Self;
}
impl MyFromIter for Generic<
i32
, i32> {
fn from_iter(
x
: i32) -> Self {
Self(x, x
)
impl MyFromIter for Generic<
'static
, i32> {
fn from_iter(
_
: i32) -> Self {
todo!(
)
}
}
impl std::iter::FromIterator<i32> for Generic<
i32
, i32> {
impl std::iter::FromIterator<i32> for Generic<
'static
, i32> {
fn from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self {
todo!()
}
}
fn main() {
<Generic<_, _> as MyFromIter>::from_iter(1);
<Generic<
'
_, _> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
<Generic::<
i32
, i32> as MyFromIter>::from_iter(1);
<Generic::<
'static
, i32> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
<Generic::<_, _> as MyFromIter>::from_iter(1);
<Generic::<
'
_, _> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
src/test/ui/rust-2021/future-prelude-collision-generic.rs
浏览文件 @
78a7d1c6
...
...
@@ -6,19 +6,19 @@
#![allow(dead_code)]
#![allow(unused_imports)]
struct
Generic
<
T
,
U
>
(
T
,
U
);
struct
Generic
<
'a
,
U
>
(
&
'a
U
);
trait
MyFromIter
{
fn
from_iter
(
_
:
i32
)
->
Self
;
}
impl
MyFromIter
for
Generic
<
i32
,
i32
>
{
fn
from_iter
(
x
:
i32
)
->
Self
{
Self
(
x
,
x
)
impl
MyFromIter
for
Generic
<
'static
,
i32
>
{
fn
from_iter
(
_
:
i32
)
->
Self
{
todo!
(
)
}
}
impl
std
::
iter
::
FromIterator
<
i32
>
for
Generic
<
i32
,
i32
>
{
impl
std
::
iter
::
FromIterator
<
i32
>
for
Generic
<
'static
,
i32
>
{
fn
from_iter
<
T
:
IntoIterator
<
Item
=
i32
>>
(
_
:
T
)
->
Self
{
todo!
()
}
...
...
@@ -28,10 +28,10 @@ fn main() {
Generic
::
from_iter
(
1
);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
Generic
::
<
i32
,
i32
>
::
from_iter
(
1
);
Generic
::
<
'static
,
i32
>
::
from_iter
(
1
);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
Generic
::
<
_
,
_
>
::
from_iter
(
1
);
Generic
::
<
'
_
,
_
>
::
from_iter
(
1
);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
src/test/ui/rust-2021/future-prelude-collision-generic.stderr
浏览文件 @
78a7d1c6
...
...
@@ -2,7 +2,7 @@ warning: trait-associated function `from_iter` will become ambiguous in Rust 202
--> $DIR/future-prelude-collision-generic.rs:28:5
|
LL | Generic::from_iter(1);
| ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic<_, _> as MyFromIter>::from_iter`
| ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic<
'
_, _> as MyFromIter>::from_iter`
|
note: the lint level is defined here
--> $DIR/future-prelude-collision-generic.rs:5:9
...
...
@@ -15,8 +15,8 @@ LL | #![warn(rust_2021_prelude_collisions)]
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
--> $DIR/future-prelude-collision-generic.rs:31:5
|
LL | Generic::<
i32
, i32>::from_iter(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the associated function: `<Generic::<i32
, i32> as MyFromIter>::from_iter`
LL | Generic::<
'static
, i32>::from_iter(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^ help: disambiguate the associated function: `<Generic::<'static
, i32> as MyFromIter>::from_iter`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
...
...
@@ -24,8 +24,8 @@ LL | Generic::<i32, i32>::from_iter(1);
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
--> $DIR/future-prelude-collision-generic.rs:34:5
|
LL | Generic::<_, _>::from_iter(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the associated function: `<Generic::<
_, _> as MyFromIter>::from_iter`
LL | Generic::<
'
_, _>::from_iter(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
^ help: disambiguate the associated function: `<Generic::<'
_, _> as MyFromIter>::from_iter`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录