Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f4efc5de
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,发现更多精彩内容 >>
提交
f4efc5de
编写于
11月 23, 2019
作者:
M
Matthew Jasper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for raw_ref_op
上级
064bed0f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
373 addition
and
11 deletion
+373
-11
src/test/ui-fulldeps/pprust-expr-roundtrip.rs
src/test/ui-fulldeps/pprust-expr-roundtrip.rs
+4
-1
src/test/ui/raw-ref-op/feature-raw-ref-op.rs
src/test/ui/raw-ref-op/feature-raw-ref-op.rs
+21
-0
src/test/ui/raw-ref-op/feature-raw-ref-op.stderr
src/test/ui/raw-ref-op/feature-raw-ref-op.stderr
+57
-0
src/test/ui/raw-ref-op/raw-ref-op.rs
src/test/ui/raw-ref-op/raw-ref-op.rs
+13
-0
src/test/ui/raw-ref-op/raw-ref-op.stderr
src/test/ui/raw-ref-op/raw-ref-op.stderr
+18
-0
src/test/ui/raw-ref-op/raw-ref-temp-deref.rs
src/test/ui/raw-ref-op/raw-ref-temp-deref.rs
+15
-10
src/test/ui/raw-ref-op/raw-ref-temp-deref.stderr
src/test/ui/raw-ref-op/raw-ref-temp-deref.stderr
+74
-0
src/test/ui/raw-ref-op/raw-ref-temp.rs
src/test/ui/raw-ref-op/raw-ref-temp.rs
+29
-0
src/test/ui/raw-ref-op/raw-ref-temp.stderr
src/test/ui/raw-ref-op/raw-ref-temp.stderr
+99
-0
src/test/ui/raw-ref-op/unusual_locations.rs
src/test/ui/raw-ref-op/unusual_locations.rs
+25
-0
src/test/ui/raw-ref-op/unusual_locations.stderr
src/test/ui/raw-ref-op/unusual_locations.stderr
+18
-0
未找到文件。
src/test/ui-fulldeps/pprust-expr-roundtrip.rs
浏览文件 @
f4efc5de
...
...
@@ -139,7 +139,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
Some
(
make_x
()),
Some
(
e
),
RangeLimits
::
HalfOpen
)));
},
15
=>
{
iter_exprs
(
depth
-
1
,
&
mut
|
e
|
g
(
ExprKind
::
AddrOf
(
Mutability
::
Immutable
,
e
)));
iter_exprs
(
depth
-
1
,
&
mut
|
e
|
g
(
ExprKind
::
AddrOf
(
BorrowKind
::
Ref
,
Mutability
::
Immutable
,
e
)),
);
},
16
=>
{
g
(
ExprKind
::
Ret
(
None
));
...
...
src/test/ui/raw-ref-op/feature-raw-ref-op.rs
0 → 100644
浏览文件 @
f4efc5de
// gate-test-raw_ref_op
macro_rules!
is_expr
{
(
$e:expr
)
=>
{}
}
is_expr!
(
&
raw
const
a
);
//~ ERROR raw address of syntax is experimental
is_expr!
(
&
raw
mut
a
);
//~ ERROR raw address of syntax is experimental
#[cfg(FALSE)]
fn
cfgd_out
()
{
let
mut
a
=
0
;
&
raw
const
a
;
//~ ERROR raw address of syntax is experimental
&
raw
mut
a
;
//~ ERROR raw address of syntax is experimental
}
fn
main
()
{
let
mut
y
=
123
;
let
x
=
&
raw
const
y
;
//~ ERROR raw address of syntax is experimental
let
x
=
&
raw
mut
y
;
//~ ERROR raw address of syntax is experimental
}
src/test/ui/raw-ref-op/feature-raw-ref-op.stderr
0 → 100644
浏览文件 @
f4efc5de
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:13:5
|
LL | &raw const a;
| ^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:14:5
|
LL | &raw mut a;
| ^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:19:13
|
LL | let x = &raw const y;
| ^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:20:13
|
LL | let x = &raw mut y;
| ^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:7:10
|
LL | is_expr!(&raw const a);
| ^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error[E0658]: raw address of syntax is experimental
--> $DIR/feature-raw-ref-op.rs:8:10
|
LL | is_expr!(&raw mut a);
| ^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
= help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0658`.
src/test/ui/raw-ref-op/raw-ref-op.rs
0 → 100644
浏览文件 @
f4efc5de
// FIXME(#64490): make this run-pass
#![feature(raw_ref_op)]
fn
main
()
{
let
mut
x
=
123
;
let
c_p
=
&
raw
const
x
;
//~ ERROR not yet implemented
let
m_p
=
&
raw
mut
x
;
//~ ERROR not yet implemented
let
i_r
=
&
x
;
assert
!
(
c_p
==
i_r
);
assert
!
(
c_p
==
m_p
);
unsafe
{
assert
!
(
*
c_p
==
*
i_r
);
}
}
src/test/ui/raw-ref-op/raw-ref-op.stderr
0 → 100644
浏览文件 @
f4efc5de
error: raw borrows are not yet implemented
--> $DIR/raw-ref-op.rs:7:15
|
LL | let c_p = &raw const x;
| ^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-op.rs:8:15
|
LL | let m_p = &raw mut x;
| ^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: aborting due to 2 previous errors
src/test/ui/raw-ref-op/raw-ref-temp-deref.rs
浏览文件 @
f4efc5de
// Ensure that we don't allow taking the address of temporary values
#![feature(raw_ref_op)]
// FIXME(#64490) This should be check-pass
// Check that taking the address of a place that contains a dereference is
// allowed.
#![feature(raw_ref_op,
type_ascription)]
const
PAIR
:
(
i32
,
i64
)
=
(
1
,
2
);
const
PAIR_REF
:
&
(
i32
,
i64
)
=
&
(
1
,
2
);
const
ARRAY
:
[
i32
;
2
]
=
[
1
,
2
];
const
ARRAY_REF
:
&
[
i32
;
2
]
=
&
[
3
,
4
];
const
SLICE_REF
:
&
[
i32
]
=
&
[
5
,
6
];
fn
main
()
{
// These are all OK, we're not taking the address of the temporary
let
deref_ref
=
&
raw
const
*
PAIR_REF
;
//~ ERROR not yet implemented
let
field_deref_ref
=
&
raw
const
PAIR_REF
.0
;
//~ ERROR not yet implemented
let
deref_ref
=
&
raw
const
*
ARRAY_REF
;
//~ ERROR not yet implemented
let
field_deref_ref
=
&
raw
const
ARRAY_REF
[
0
];
//~ ERROR not yet implemented
let
deref_ref
=
&
raw
const
*
SLICE_REF
;
//~ ERROR not yet implemented
let
field_deref_ref
=
&
raw
const
SLICE_REF
[
1
];
//~ ERROR not yet implemented
let
deref_ref
=
&
raw
const
*
PAIR_REF
;
//~ ERROR not yet implemented
let
field_deref_ref
=
&
raw
const
PAIR_REF
.0
;
//~ ERROR not yet implemented
let
deref_ref
=
&
raw
const
*
ARRAY_REF
;
//~ ERROR not yet implemented
let
index_deref_ref
=
&
raw
const
ARRAY_REF
[
0
];
//~ ERROR not yet implemented
let
deref_ref
=
&
raw
const
*
SLICE_REF
;
//~ ERROR not yet implemented
let
index_deref_ref
=
&
raw
const
SLICE_REF
[
1
];
//~ ERROR not yet implemented
let
x
=
0
;
let
ascribe_ref
=
&
raw
const
(
x
:
i32
);
//~ ERROR not yet implemented
let
ascribe_deref
=
&
raw
const
(
*
ARRAY_REF
:
[
i32
;
2
]);
//~ ERROR not yet implemented
let
ascribe_index_deref
=
&
raw
const
(
ARRAY_REF
[
0
]:
i32
);
//~ ERROR not yet implemented
}
src/test/ui/raw-ref-op/raw-ref-temp-deref.stderr
0 → 100644
浏览文件 @
f4efc5de
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:13:21
|
LL | let deref_ref = &raw const *PAIR_REF;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:14:27
|
LL | let field_deref_ref = &raw const PAIR_REF.0;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:15:21
|
LL | let deref_ref = &raw const *ARRAY_REF;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:16:27
|
LL | let index_deref_ref = &raw const ARRAY_REF[0];
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:17:21
|
LL | let deref_ref = &raw const *SLICE_REF;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:18:27
|
LL | let index_deref_ref = &raw const SLICE_REF[1];
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:21:23
|
LL | let ascribe_ref = &raw const (x: i32);
| ^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:22:25
|
LL | let ascribe_deref = &raw const (*ARRAY_REF: [i32; 2]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/raw-ref-temp-deref.rs:23:31
|
LL | let ascribe_index_deref = &raw const (ARRAY_REF[0]: i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: aborting due to 9 previous errors
src/test/ui/raw-ref-op/raw-ref-temp.rs
0 → 100644
浏览文件 @
f4efc5de
// Ensure that we don't allow taking the address of temporary values
#![feature(raw_ref_op,
type_ascription)]
const
PAIR
:
(
i32
,
i64
)
=
(
1
,
2
);
const
ARRAY
:
[
i32
;
2
]
=
[
1
,
2
];
fn
main
()
{
let
ref_expr
=
&
raw
const
2
;
//~ ERROR cannot take address
let
mut_ref_expr
=
&
raw
mut
3
;
//~ ERROR cannot take address
let
ref_const
=
&
raw
const
4
;
//~ ERROR cannot take address
let
mut_ref_const
=
&
raw
mut
5
;
//~ ERROR cannot take address
let
field_ref_expr
=
&
raw
const
(
1
,
2
)
.0
;
//~ ERROR cannot take address
let
mut_field_ref_expr
=
&
raw
mut
(
1
,
2
)
.0
;
//~ ERROR cannot take address
let
field_ref
=
&
raw
const
PAIR
.0
;
//~ ERROR cannot take address
let
mut_field_ref
=
&
raw
mut
PAIR
.0
;
//~ ERROR cannot take address
let
index_ref_expr
=
&
raw
const
[
1
,
2
][
0
];
//~ ERROR cannot take address
let
mut_index_ref_expr
=
&
raw
mut
[
1
,
2
][
0
];
//~ ERROR cannot take address
let
index_ref
=
&
raw
const
ARRAY
[
0
];
//~ ERROR cannot take address
let
mut_index_ref
=
&
raw
mut
ARRAY
[
1
];
//~ ERROR cannot take address
let
ref_ascribe
=
&
raw
const
(
2
:
i32
);
//~ ERROR cannot take address
let
mut_ref_ascribe
=
&
raw
mut
(
3
:
i32
);
//~ ERROR cannot take address
let
ascribe_field_ref
=
&
raw
const
(
PAIR
.0
:
i32
);
//~ ERROR cannot take address
let
ascribe_index_ref
=
&
raw
mut
(
ARRAY
[
0
]:
i32
);
//~ ERROR cannot take address
}
src/test/ui/raw-ref-op/raw-ref-temp.stderr
0 → 100644
浏览文件 @
f4efc5de
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:9:31
|
LL | let ref_expr = &raw const 2;
| ^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:10:33
|
LL | let mut_ref_expr = &raw mut 3;
| ^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:11:32
|
LL | let ref_const = &raw const 4;
| ^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:12:34
|
LL | let mut_ref_const = &raw mut 5;
| ^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:14:37
|
LL | let field_ref_expr = &raw const (1, 2).0;
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:15:39
|
LL | let mut_field_ref_expr = &raw mut (1, 2).0;
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:16:32
|
LL | let field_ref = &raw const PAIR.0;
| ^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:17:34
|
LL | let mut_field_ref = &raw mut PAIR.0;
| ^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:19:37
|
LL | let index_ref_expr = &raw const [1, 2][0];
| ^^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:20:39
|
LL | let mut_index_ref_expr = &raw mut [1, 2][0];
| ^^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:21:32
|
LL | let index_ref = &raw const ARRAY[0];
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:22:34
|
LL | let mut_index_ref = &raw mut ARRAY[1];
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:24:34
|
LL | let ref_ascribe = &raw const (2: i32);
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:25:36
|
LL | let mut_ref_ascribe = &raw mut (3: i32);
| ^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:27:40
|
LL | let ascribe_field_ref = &raw const (PAIR.0: i32);
| ^^^^^^^^^^^^^ temporary value
error[E0745]: cannot take address of a temporary
--> $DIR/raw-ref-temp.rs:28:38
|
LL | let ascribe_index_ref = &raw mut (ARRAY[0]: i32);
| ^^^^^^^^^^^^^^^ temporary value
error: aborting due to 16 previous errors
For more information about this error, try `rustc --explain E0745`.
src/test/ui/raw-ref-op/unusual_locations.rs
0 → 100644
浏览文件 @
f4efc5de
// FIXME(#64490): make this check-pass
#![feature(raw_ref_op)]
const
USES_PTR
:
()
=
{
let
u
=
();
&
raw
const
u
;
};
//~ ERROR not yet implemented
static
ALSO_USES_PTR
:
()
=
{
let
u
=
();
&
raw
const
u
;
};
//~ ERROR not yet implemented
fn
main
()
{
#[cfg(FALSE)]
{
let
x
:
[
i32
;
{
let
u
=
2
;
let
x
=
&
raw
const
u
;
4
}]
=
[
2
;
{
let
v
=
3
;
let
y
=
&
raw
const
v
;
4
}];
let
mut
one
=
1
;
let
two
=
2
;
if
&
raw
const
one
==
&
raw
mut
one
{
match
&
raw
const
two
{
_
=>
{}
}
}
let
three
=
3
;
let
mut
four
=
4
;
println!
(
"{:p}"
,
&
raw
const
three
);
unsafe
{
&
raw
mut
four
;
}
}
}
src/test/ui/raw-ref-op/unusual_locations.stderr
0 → 100644
浏览文件 @
f4efc5de
error: raw borrows are not yet implemented
--> $DIR/unusual_locations.rs:5:36
|
LL | const USES_PTR: () = { let u = (); &raw const u; };
| ^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: raw borrows are not yet implemented
--> $DIR/unusual_locations.rs:6:42
|
LL | static ALSO_USES_PTR: () = { let u = (); &raw const u; };
| ^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/64490
error: aborting due to 2 previous errors
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录