Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cce055da
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,发现更多精彩内容 >>
未验证
提交
cce055da
编写于
1月 04, 2020
作者:
D
Dylan DPC
提交者:
GitHub
1月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #67137 - anp:tracked-panic-internals, r=eddyb
libstd uses `core::panic::Location` where possible. cc
@EddyB
上级
cd8377d3
27b25eb8
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
90 addition
and
94 deletion
+90
-94
src/libcore/macros/mod.rs
src/libcore/macros/mod.rs
+3
-9
src/libcore/panicking.rs
src/libcore/panicking.rs
+3
-2
src/librustc_expand/build.rs
src/librustc_expand/build.rs
+2
-8
src/librustc_mir/const_eval/machine.rs
src/librustc_mir/const_eval/machine.rs
+2
-1
src/librustc_mir/interpret/intrinsics.rs
src/librustc_mir/interpret/intrinsics.rs
+8
-34
src/librustc_mir/interpret/intrinsics/caller_location.rs
src/librustc_mir/interpret/intrinsics/caller_location.rs
+9
-3
src/librustc_mir/interpret/machine.rs
src/librustc_mir/interpret/machine.rs
+1
-0
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/interpret/terminator.rs
+1
-1
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/const_prop.rs
+1
-0
src/libstd/lib.rs
src/libstd/lib.rs
+1
-0
src/libstd/macros.rs
src/libstd/macros.rs
+16
-2
src/libstd/panicking.rs
src/libstd/panicking.rs
+17
-26
src/test/mir-opt/retain-never-const.rs
src/test/mir-opt/retain-never-const.rs
+1
-0
src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
...n/issue-64655-allow-unwind-when-calling-panic-directly.rs
+2
-4
src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
...est/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
+3
-3
src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
...est/ui/rfc-2091-track-caller/diverging-caller-location.rs
+19
-0
src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
+1
-1
未找到文件。
src/libcore/macros/mod.rs
浏览文件 @
cce055da
#[doc(include
=
"panic.md"
)]
#[macro_export]
#[allow_internal_unstable(core_panic,
// FIXME(anp, eddyb) `core_intrinsics` is used here to allow calling
// the `caller_location` intrinsic, but once `#[track_caller]` is implemented,
// `panicking::{panic, panic_fmt}` can use that instead of a `Location` argument.
core_intrinsics,
const_caller_location,
)]
#[allow_internal_unstable(core_panic,
track_caller)]
#[stable(feature
=
"core"
,
since
=
"1.6.0"
)]
macro_rules!
panic
{
()
=>
(
$crate
::
panic!
(
"explicit panic"
)
);
(
$msg:expr
)
=>
(
$crate
::
panicking
::
panic
(
$msg
,
$crate
::
intrinsics
::
caller_location
()
)
$crate
::
panicking
::
panic
(
$msg
)
);
(
$msg:expr
,)
=>
(
$crate
::
panic!
(
$msg
)
...
...
@@ -21,7 +15,7 @@
(
$fmt:expr
,
$
(
$arg:tt
)
+
)
=>
(
$crate
::
panicking
::
panic_fmt
(
$crate
::
format_args!
(
$fmt
,
$
(
$arg
)
+
),
$crate
::
intrinsics
::
caller_location
(),
$crate
::
panic
::
Location
::
caller
(),
)
);
}
...
...
src/libcore/panicking.rs
浏览文件 @
cce055da
...
...
@@ -36,8 +36,9 @@
// never inline unless panic_immediate_abort to avoid code
// bloat at the call sites as much as possible
#[cfg_attr(not(feature
=
"panic_immediate_abort"
),
inline(never))]
#[track_caller]
#[lang
=
"panic"
]
// needed by codegen for panic on overflow and other `Assert` MIR terminators
pub
fn
panic
(
expr
:
&
str
,
location
:
&
Location
<
'_
>
)
->
!
{
pub
fn
panic
(
expr
:
&
str
)
->
!
{
if
cfg!
(
feature
=
"panic_immediate_abort"
)
{
unsafe
{
super
::
intrinsics
::
abort
()
}
}
...
...
@@ -48,7 +49,7 @@ pub fn panic(expr: &str, location: &Location<'_>) -> ! {
// truncation and padding (even though none is used here). Using
// Arguments::new_v1 may allow the compiler to omit Formatter::pad from the
// output binary, saving up to a few kilobytes.
panic_fmt
(
fmt
::
Arguments
::
new_v1
(
&
[
expr
],
&
[]),
location
)
panic_fmt
(
fmt
::
Arguments
::
new_v1
(
&
[
expr
],
&
[]),
Location
::
caller
()
)
}
#[cold]
...
...
src/librustc_expand/build.rs
浏览文件 @
cce055da
...
...
@@ -6,7 +6,7 @@
use
syntax
::
attr
;
use
syntax
::
ptr
::
P
;
use
rustc_span
::
{
Pos
,
Span
}
;
use
rustc_span
::
Span
;
impl
<
'a
>
ExtCtxt
<
'a
>
{
pub
fn
path
(
&
self
,
span
:
Span
,
strs
:
Vec
<
ast
::
Ident
>
)
->
ast
::
Path
{
...
...
@@ -350,16 +350,10 @@ pub fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
}
pub
fn
expr_fail
(
&
self
,
span
:
Span
,
msg
:
Symbol
)
->
P
<
ast
::
Expr
>
{
let
loc
=
self
.source_map
()
.lookup_char_pos
(
span
.lo
());
let
expr_file
=
self
.expr_str
(
span
,
Symbol
::
intern
(
&
loc
.file.name
.to_string
()));
let
expr_line
=
self
.expr_u32
(
span
,
loc
.line
as
u32
);
let
expr_col
=
self
.expr_u32
(
span
,
loc
.col
.to_usize
()
as
u32
+
1
);
let
expr_loc_tuple
=
self
.expr_tuple
(
span
,
vec!
[
expr_file
,
expr_line
,
expr_col
]);
let
expr_loc_ptr
=
self
.expr_addr_of
(
span
,
expr_loc_tuple
);
self
.expr_call_global
(
span
,
[
sym
::
std
,
sym
::
rt
,
sym
::
begin_panic
]
.iter
()
.map
(|
s
|
Ident
::
new
(
*
s
,
span
))
.collect
(),
vec!
[
self
.expr_str
(
span
,
msg
)
,
expr_loc_ptr
],
vec!
[
self
.expr_str
(
span
,
msg
)],
)
}
...
...
src/librustc_mir/const_eval/machine.rs
浏览文件 @
cce055da
...
...
@@ -177,6 +177,7 @@ fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
fn
find_mir_or_eval_fn
(
ecx
:
&
mut
InterpCx
<
'mir
,
'tcx
,
Self
>
,
span
:
Span
,
instance
:
ty
::
Instance
<
'tcx
>
,
args
:
&
[
OpTy
<
'tcx
>
],
ret
:
Option
<
(
PlaceTy
<
'tcx
>
,
mir
::
BasicBlock
)
>
,
...
...
@@ -199,7 +200,7 @@ fn find_mir_or_eval_fn(
// Some functions we support even if they are non-const -- but avoid testing
// that for const fn! We certainly do *not* want to actually call the fn
// though, so be sure we return here.
return
if
ecx
.hook_panic_fn
(
instance
,
args
,
ret
)
?
{
return
if
ecx
.hook_panic_fn
(
span
,
instance
,
args
)
?
{
Ok
(
None
)
}
else
{
throw_unsup_format!
(
"calling non-const function `{}`"
,
instance
)
...
...
src/librustc_mir/interpret/intrinsics.rs
浏览文件 @
cce055da
...
...
@@ -366,47 +366,21 @@ pub fn emulate_intrinsic(
/// Returns `true` if an intercept happened.
pub
fn
hook_panic_fn
(
&
mut
self
,
span
:
Span
,
instance
:
ty
::
Instance
<
'tcx
>
,
args
:
&
[
OpTy
<
'tcx
,
M
::
PointerTag
>
],
_
ret
:
Option
<
(
PlaceTy
<
'tcx
,
M
::
PointerTag
>
,
mir
::
BasicBlock
)
>
,
)
->
InterpResult
<
'tcx
,
bool
>
{
let
def_id
=
instance
.def_id
();
if
Some
(
def_id
)
==
self
.tcx
.lang_items
()
.panic_fn
()
{
// &'static str, &core::panic::Location { &'static str, u32, u32 }
assert
!
(
args
.len
()
==
2
);
if
Some
(
def_id
)
==
self
.tcx
.lang_items
()
.panic_fn
()
||
Some
(
def_id
)
==
self
.tcx
.lang_items
()
.begin_panic_fn
()
{
// &'static str
assert
!
(
args
.len
()
==
1
);
let
msg_place
=
self
.deref_operand
(
args
[
0
])
?
;
let
msg
=
Symbol
::
intern
(
self
.read_str
(
msg_place
)
?
);
let
location
=
self
.deref_operand
(
args
[
1
])
?
;
let
(
file
,
line
,
col
)
=
(
self
.mplace_field
(
location
,
0
)
?
,
self
.mplace_field
(
location
,
1
)
?
,
self
.mplace_field
(
location
,
2
)
?
,
);
let
file_place
=
self
.deref_operand
(
file
.into
())
?
;
let
file
=
Symbol
::
intern
(
self
.read_str
(
file_place
)
?
);
let
line
=
self
.read_scalar
(
line
.into
())
?
.to_u32
()
?
;
let
col
=
self
.read_scalar
(
col
.into
())
?
.to_u32
()
?
;
throw_panic!
(
Panic
{
msg
,
file
,
line
,
col
})
}
else
if
Some
(
def_id
)
==
self
.tcx
.lang_items
()
.begin_panic_fn
()
{
assert
!
(
args
.len
()
==
2
);
// &'static str, &(&'static str, u32, u32)
let
msg
=
args
[
0
];
let
place
=
self
.deref_operand
(
args
[
1
])
?
;
let
(
file
,
line
,
col
)
=
(
self
.mplace_field
(
place
,
0
)
?
,
self
.mplace_field
(
place
,
1
)
?
,
self
.mplace_field
(
place
,
2
)
?
,
);
let
msg_place
=
self
.deref_operand
(
msg
.into
())
?
;
let
msg
=
Symbol
::
intern
(
self
.read_str
(
msg_place
)
?
);
let
file_place
=
self
.deref_operand
(
file
.into
())
?
;
let
file
=
Symbol
::
intern
(
self
.read_str
(
file_place
)
?
);
let
line
=
self
.read_scalar
(
line
.into
())
?
.to_u32
()
?
;
let
col
=
self
.read_scalar
(
col
.into
())
?
.to_u32
()
?
;
let
span
=
self
.find_closest_untracked_caller_location
()
.unwrap_or
(
span
);
let
(
file
,
line
,
col
)
=
self
.location_triple_for_span
(
span
);
throw_panic!
(
Panic
{
msg
,
file
,
line
,
col
})
}
else
{
return
Ok
(
false
);
...
...
src/librustc_mir/interpret/intrinsics/caller_location.rs
浏览文件 @
cce055da
...
...
@@ -9,8 +9,9 @@
};
impl
<
'mir
,
'tcx
,
M
:
Machine
<
'mir
,
'tcx
>>
InterpCx
<
'mir
,
'tcx
,
M
>
{
/// Walks up the callstack from the intrinsic's callsite, searching for the first frame which is
/// not `#[track_caller]`.
/// Walks up the callstack from the intrinsic's callsite, searching for the first callsite in a
/// frame which is not `#[track_caller]`. If the first frame found lacks `#[track_caller]`, then
/// `None` is returned and the callsite of the function invocation itself should be used.
crate
fn
find_closest_untracked_caller_location
(
&
self
)
->
Option
<
Span
>
{
let
mut
caller_span
=
None
;
for
next_caller
in
self
.stack
.iter
()
.rev
()
{
...
...
@@ -54,9 +55,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
pub
fn
alloc_caller_location_for_span
(
&
mut
self
,
span
:
Span
)
->
MPlaceTy
<
'tcx
,
M
::
PointerTag
>
{
let
(
file
,
line
,
column
)
=
self
.location_triple_for_span
(
span
);
self
.alloc_caller_location
(
file
,
line
,
column
)
}
pub
(
super
)
fn
location_triple_for_span
(
&
self
,
span
:
Span
)
->
(
Symbol
,
u32
,
u32
)
{
let
topmost
=
span
.ctxt
()
.outer_expn
()
.expansion_cause
()
.unwrap_or
(
span
);
let
caller
=
self
.tcx.sess
.source_map
()
.lookup_char_pos
(
topmost
.lo
());
self
.alloc_caller_location
(
(
Symbol
::
intern
(
&
caller
.file.name
.to_string
()),
caller
.line
as
u32
,
caller
.col_display
as
u32
+
1
,
...
...
src/librustc_mir/interpret/machine.rs
浏览文件 @
cce055da
...
...
@@ -139,6 +139,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
/// was used.
fn
find_mir_or_eval_fn
(
ecx
:
&
mut
InterpCx
<
'mir
,
'tcx
,
Self
>
,
span
:
Span
,
instance
:
ty
::
Instance
<
'tcx
>
,
args
:
&
[
OpTy
<
'tcx
,
Self
::
PointerTag
>
],
ret
:
Option
<
(
PlaceTy
<
'tcx
,
Self
::
PointerTag
>
,
mir
::
BasicBlock
)
>
,
...
...
src/librustc_mir/interpret/terminator.rs
浏览文件 @
cce055da
...
...
@@ -238,7 +238,7 @@ fn eval_fn_call(
|
ty
::
InstanceDef
::
CloneShim
(
..
)
|
ty
::
InstanceDef
::
Item
(
_
)
=>
{
// We need MIR for this fn
let
body
=
match
M
::
find_mir_or_eval_fn
(
self
,
instance
,
args
,
ret
,
unwind
)
?
{
let
body
=
match
M
::
find_mir_or_eval_fn
(
self
,
span
,
instance
,
args
,
ret
,
unwind
)
?
{
Some
(
body
)
=>
body
,
None
=>
return
Ok
(()),
};
...
...
src/librustc_mir/transform/const_prop.rs
浏览文件 @
cce055da
...
...
@@ -125,6 +125,7 @@ fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
fn
find_mir_or_eval_fn
(
_
ecx
:
&
mut
InterpCx
<
'mir
,
'tcx
,
Self
>
,
_
span
:
Span
,
_
instance
:
ty
::
Instance
<
'tcx
>
,
_
args
:
&
[
OpTy
<
'tcx
>
],
_
ret
:
Option
<
(
PlaceTy
<
'tcx
>
,
BasicBlock
)
>
,
...
...
src/libstd/lib.rs
浏览文件 @
cce055da
...
...
@@ -305,6 +305,7 @@
#![feature(thread_local)]
#![feature(toowned_clone_into)]
#![feature(trace_macros)]
#![feature(track_caller)]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(untagged_unions)]
...
...
src/libstd/macros.rs
浏览文件 @
cce055da
...
...
@@ -4,6 +4,7 @@
//! library. Each macro is available for use when linking against the standard
//! library.
#[cfg(bootstrap)]
#[doc(include
=
"../libcore/macros/panic.md"
)]
#[macro_export]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -19,8 +20,21 @@
$crate
::
panic!
(
$msg
)
});
(
$fmt:expr
,
$
(
$arg:tt
)
+
)
=>
({
$crate
::
rt
::
begin_panic_fmt
(
&
$crate
::
format_args!
(
$fmt
,
$
(
$arg
)
+
),
&
(
$crate
::
file!
(),
$crate
::
line!
(),
$crate
::
column!
()))
$crate
::
rt
::
begin_panic_fmt
(
&
$crate
::
format_args!
(
$fmt
,
$
(
$arg
)
+
))
});
}
#[cfg(not(bootstrap))]
#[doc(include
=
"../libcore/macros/panic.md"
)]
#[macro_export]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[allow_internal_unstable(libstd_sys_internals)]
macro_rules!
panic
{
()
=>
({
$crate
::
panic!
(
"explicit panic"
)
});
(
$msg:expr
)
=>
({
$crate
::
rt
::
begin_panic
(
$msg
)
});
(
$msg:expr
,)
=>
({
$crate
::
panic!
(
$msg
)
});
(
$fmt:expr
,
$
(
$arg:tt
)
+
)
=>
({
$crate
::
rt
::
begin_panic_fmt
(
&
$crate
::
format_args!
(
$fmt
,
$
(
$arg
)
+
))
});
}
...
...
src/libstd/panicking.rs
浏览文件 @
cce055da
...
...
@@ -313,17 +313,15 @@ pub fn panicking() -> bool {
#[cold]
// If panic_immediate_abort, inline the abort call,
// otherwise avoid inlining because of it is cold path.
#[cfg_attr(not(feature
=
"panic_immediate_abort"
),
track_caller)]
#[cfg_attr(not(feature
=
"panic_immediate_abort"
),
inline(never))]
#[cfg_attr(feature
=
"panic_immediate_abort"
,
inline)]
pub
fn
begin_panic_fmt
(
msg
:
&
fmt
::
Arguments
<
'_
>
,
file_line_col
:
&
(
&
'static
str
,
u32
,
u32
)
)
->
!
{
pub
fn
begin_panic_fmt
(
msg
:
&
fmt
::
Arguments
<
'_
>
)
->
!
{
if
cfg!
(
feature
=
"panic_immediate_abort"
)
{
unsafe
{
intrinsics
::
abort
()
}
}
// Just package everything into a `PanicInfo` and continue like libcore panics.
let
(
file
,
line
,
col
)
=
*
file_line_col
;
let
location
=
Location
::
internal_constructor
(
file
,
line
,
col
);
let
info
=
PanicInfo
::
internal_constructor
(
Some
(
msg
),
&
location
);
let
info
=
PanicInfo
::
internal_constructor
(
Some
(
msg
),
Location
::
caller
());
begin_panic_handler
(
&
info
)
}
...
...
@@ -356,6 +354,9 @@ fn fill(&mut self) -> &mut String {
unsafe
impl
<
'a
>
BoxMeUp
for
PanicPayload
<
'a
>
{
fn
take_box
(
&
mut
self
)
->
*
mut
(
dyn
Any
+
Send
)
{
// We do two allocations here, unfortunately. But (a) they're required with the current
// scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
// begin_panic below).
let
contents
=
mem
::
take
(
self
.fill
());
Box
::
into_raw
(
Box
::
new
(
contents
))
}
...
...
@@ -365,15 +366,9 @@ fn get(&mut self) -> &(dyn Any + Send) {
}
}
// We do two allocations here, unfortunately. But (a) they're
// required with the current scheme, and (b) we don't handle
// panic + OOM properly anyway (see comment in begin_panic
// below).
let
loc
=
info
.location
()
.unwrap
();
// The current implementation always returns Some
let
msg
=
info
.message
()
.unwrap
();
// The current implementation always returns Some
let
file_line_col
=
(
loc
.file
(),
loc
.line
(),
loc
.column
());
rust_panic_with_hook
(
&
mut
PanicPayload
::
new
(
msg
),
info
.message
(),
&
file_line_col
);
rust_panic_with_hook
(
&
mut
PanicPayload
::
new
(
msg
),
info
.message
(),
loc
);
}
/// This is the entry point of panicking for the non-format-string variants of
...
...
@@ -386,19 +381,13 @@ fn get(&mut self) -> &(dyn Any + Send) {
// bloat at the call sites as much as possible
#[cfg_attr(not(feature
=
"panic_immediate_abort"
),
inline(never))]
#[cold]
pub
fn
begin_panic
<
M
:
Any
+
Send
>
(
msg
:
M
,
file_line_col
:
&
(
&
'static
str
,
u32
,
u32
))
->
!
{
#[track_caller]
pub
fn
begin_panic
<
M
:
Any
+
Send
>
(
msg
:
M
,
#[cfg(bootstrap)]
_
:
&
(
&
str
,
u32
,
u32
))
->
!
{
if
cfg!
(
feature
=
"panic_immediate_abort"
)
{
unsafe
{
intrinsics
::
abort
()
}
}
// Note that this should be the only allocation performed in this code path.
// Currently this means that panic!() on OOM will invoke this code path,
// but then again we're not really ready for panic on OOM anyway. If
// we do start doing this, then we should propagate this allocation to
// be performed in the parent of this thread instead of the thread that's
// panicking.
rust_panic_with_hook
(
&
mut
PanicPayload
::
new
(
msg
),
None
,
file_line_col
);
rust_panic_with_hook
(
&
mut
PanicPayload
::
new
(
msg
),
None
,
Location
::
caller
());
struct
PanicPayload
<
A
>
{
inner
:
Option
<
A
>
,
...
...
@@ -412,6 +401,11 @@ fn new(inner: A) -> PanicPayload<A> {
unsafe
impl
<
A
:
Send
+
'static
>
BoxMeUp
for
PanicPayload
<
A
>
{
fn
take_box
(
&
mut
self
)
->
*
mut
(
dyn
Any
+
Send
)
{
// Note that this should be the only allocation performed in this code path. Currently
// this means that panic!() on OOM will invoke this code path, but then again we're not
// really ready for panic on OOM anyway. If we do start doing this, then we should
// propagate this allocation to be performed in the parent of this thread instead of the
// thread that's panicking.
let
data
=
match
self
.inner
.take
()
{
Some
(
a
)
=>
Box
::
new
(
a
)
as
Box
<
dyn
Any
+
Send
>
,
None
=>
process
::
abort
(),
...
...
@@ -436,10 +430,8 @@ fn get(&mut self) -> &(dyn Any + Send) {
fn
rust_panic_with_hook
(
payload
:
&
mut
dyn
BoxMeUp
,
message
:
Option
<&
fmt
::
Arguments
<
'_
>>
,
file_line_col
:
&
(
&
str
,
u32
,
u32
)
,
location
:
&
Location
<
'_
>
,
)
->
!
{
let
(
file
,
line
,
col
)
=
*
file_line_col
;
let
panics
=
update_panic_count
(
1
);
// If this is the third nested call (e.g., panics == 2, this is 0-indexed),
...
...
@@ -456,8 +448,7 @@ fn rust_panic_with_hook(
}
unsafe
{
let
location
=
Location
::
internal_constructor
(
file
,
line
,
col
);
let
mut
info
=
PanicInfo
::
internal_constructor
(
message
,
&
location
);
let
mut
info
=
PanicInfo
::
internal_constructor
(
message
,
location
);
HOOK_LOCK
.read
();
match
HOOK
{
// Some platforms (like wasm) know that printing to stderr won't ever actually
...
...
src/test/mir-opt/retain-never-const.rs
浏览文件 @
cce055da
...
...
@@ -6,6 +6,7 @@
#![feature(const_panic)]
#![feature(never_type)]
#![warn(const_err)]
struct
PrintName
<
T
>
(
T
);
...
...
src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
浏览文件 @
cce055da
...
...
@@ -22,7 +22,7 @@
//[thin]compile-flags: -C lto=thin
//[fat]compile-flags: -C lto=fat
#![feature(core_panic
,
panic_internals
)]
#![feature(core_panic)]
// (For some reason, reproducing the LTO issue requires pulling in std
// explicitly this way.)
...
...
@@ -50,9 +50,7 @@ fn drop(&mut self) {
}
let
_
guard
=
Droppable
;
let
s
=
"issue-64655-allow-unwind-when-calling-panic-directly.rs"
;
let
location
=
core
::
panic
::
Location
::
internal_constructor
(
s
,
17
,
4
);
core
::
panicking
::
panic
(
"???"
,
&
location
);
core
::
panicking
::
panic
(
"???"
);
});
let
wait
=
handle
.join
();
...
...
src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
浏览文件 @
cce055da
...
...
@@ -4,16 +4,16 @@
#[inline(never)]
#[track_caller]
fn
defeat_const_prop
()
->
&
'static
core
::
panic
::
Location
<
'static
>
{
fn
codegen_caller_loc
()
->
&
'static
core
::
panic
::
Location
<
'static
>
{
core
::
panic
::
Location
::
caller
()
}
macro_rules!
caller_location_from_macro
{
()
=>
(
defeat_const_prop
());
()
=>
(
codegen_caller_loc
());
}
fn
main
()
{
let
loc
=
defeat_const_prop
();
let
loc
=
codegen_caller_loc
();
assert_eq!
(
loc
.file
(),
file!
());
assert_eq!
(
loc
.line
(),
16
);
assert_eq!
(
loc
.column
(),
15
);
...
...
src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
0 → 100644
浏览文件 @
cce055da
// run-fail
//! This test ensures that `#[track_caller]` can be applied directly to diverging functions, as
//! the tracking issue says: https://github.com/rust-lang/rust/issues/47809#issue-292138490.
//! Because the annotated function must diverge and a panic keeps that faster than an infinite loop,
//! we don't inspect the location returned -- it would be difficult to distinguish between the
//! explicit panic and a failed assertion. That it compiles and runs is enough for this one.
#![feature(track_caller)]
#[track_caller]
fn
doesnt_return
()
->
!
{
let
_
location
=
core
::
panic
::
Location
::
caller
();
panic!
(
"huzzah"
);
}
fn
main
()
{
doesnt_return
();
}
src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
浏览文件 @
cce055da
// run-pass
#![feature(
const_fn,
track_caller)]
#![feature(track_caller)]
use
std
::
panic
::
Location
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录