Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
329b8ca8
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,发现更多精彩内容 >>
提交
329b8ca8
编写于
12月 10, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: always rely on '_ to be not printed by ty::Region itself.
上级
387cacf7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
69 addition
and
79 deletion
+69
-79
src/librustc/traits/specialize/mod.rs
src/librustc/traits/specialize/mod.rs
+1
-1
src/librustc/ty/structural_impls.rs
src/librustc/ty/structural_impls.rs
+1
-0
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+58
-69
src/test/ui/issues/issue-17905-2.stderr
src/test/ui/issues/issue-17905-2.stderr
+2
-2
src/test/ui/nll/closure-requirements/escape-argument-callee.stderr
...ui/nll/closure-requirements/escape-argument-callee.stderr
+1
-1
src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr
...equirements/propagate-approximated-fail-no-postdom.stderr
+2
-2
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr
...nts/propagate-fail-to-approximate-longer-no-bounds.stderr
+2
-2
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr
.../propagate-fail-to-approximate-longer-wrong-bounds.stderr
+2
-2
未找到文件。
src/librustc/traits/specialize/mod.rs
浏览文件 @
329b8ca8
...
...
@@ -411,7 +411,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<
w
.push
(
'<'
);
w
.push_str
(
&
substs
.iter
()
.map
(|
k
|
k
.to_string
())
.filter
(|
k
|
&
k
[
..
]
!=
"'_"
)
.filter
(|
k
|
!
k
.is_empty
()
)
.collect
::
<
Vec
<
_
>>
()
.join
(
", "
));
w
.push
(
'>'
);
}
...
...
src/librustc/ty/structural_impls.rs
浏览文件 @
329b8ca8
...
...
@@ -55,6 +55,7 @@
crate
::
ty
::
IntVarValue
,
crate
::
ty
::
ParamConst
,
crate
::
ty
::
ParamTy
,
crate
::
ty
::
RegionVid
,
crate
::
ty
::
UniverseIndex
,
crate
::
ty
::
Variance
,
::
syntax_pos
::
Span
,
...
...
src/librustc/util/ppaux.rs
浏览文件 @
329b8ca8
...
...
@@ -120,17 +120,6 @@ pub fn highlighting_region_vid<R>(
Self
::
highlighting_region
(
&
ty
::
ReVar
(
vid
),
number
,
op
)
}
/// Returns `true` if any placeholders are highlighted, and `false` otherwise.
fn
any_region_vids_highlighted
(
&
self
)
->
bool
{
Self
::
get
()
.highlight_regions
.iter
()
.any
(|
h
|
match
h
{
Some
((
ty
::
ReVar
(
_
),
_
))
=>
true
,
_
=>
false
,
})
}
/// Returns `Some(n)` with the number to use for the given region, if any.
fn
region_highlighted
(
&
self
,
region
:
ty
::
Region
<
'_
>
)
->
Option
<
usize
>
{
Self
::
get
()
...
...
@@ -163,17 +152,6 @@ pub fn highlighting_bound_region<R>(
)
}
/// Returns `true` if any placeholders are highlighted, and `false` otherwise.
pub
fn
any_placeholders_highlighted
(
&
self
)
->
bool
{
Self
::
get
()
.highlight_regions
.iter
()
.any
(|
h
|
match
h
{
Some
((
ty
::
RePlaceholder
(
_
),
_
))
=>
true
,
_
=>
false
,
})
}
/// Returns `Some(N)` if the placeholder `p` is highlighted to print as "`'N`".
pub
fn
placeholder_highlight
(
&
self
,
p
:
ty
::
PlaceholderRegion
)
->
Option
<
usize
>
{
self
.region_highlighted
(
&
ty
::
RePlaceholder
(
p
))
...
...
@@ -421,7 +399,7 @@ fn parameterized<F: fmt::Write>(
if
self
.is_verbose
{
write!
(
f
,
"{:?}"
,
region
)
?
;
}
else
{
let
s
=
region
.
to_string
(
);
let
s
=
region
.
print_display_to_string
(
self
);
if
s
.is_empty
()
{
// This happens when the value of the region
// parameter is not easily serialized. This may be
...
...
@@ -720,19 +698,20 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
return
self
.print_debug
(
f
,
cx
);
}
if
let
Some
((
region
,
counter
))
=
RegionHighlightMode
::
get
()
.highlight_bound_region
{
if
*
self
==
region
{
return
match
*
self
{
BrNamed
(
_
,
name
)
=>
write!
(
f
,
"{}"
,
name
),
BrAnon
(
_
)
|
BrFresh
(
_
)
|
BrEnv
=>
write!
(
f
,
"'{}"
,
counter
)
};
if
let
BrNamed
(
_
,
name
)
=
*
self
{
if
name
!=
""
&&
name
!=
"'_"
{
return
write!
(
f
,
"{}"
,
name
);
}
}
match
*
self
{
BrNamed
(
_
,
name
)
=>
write!
(
f
,
"{}"
,
name
),
BrAnon
(
_
)
|
BrFresh
(
_
)
|
BrEnv
=>
Ok
(())
let
highlight
=
RegionHighlightMode
::
get
();
if
let
Some
((
region
,
counter
))
=
highlight
.highlight_bound_region
{
if
*
self
==
region
{
return
write!
(
f
,
"'{}"
,
counter
);
}
}
Ok
(())
}
debug
{
return
match
*
self
{
...
...
@@ -757,12 +736,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let
highlight
=
RegionHighlightMode
::
get
();
if
let
Some
(
counter
)
=
highlight
.placeholder_highlight
(
*
self
)
{
write!
(
f
,
"'{}"
,
counter
)
}
else
if
highlight
.any_placeholders_highlighted
()
{
write!
(
f
,
"'_"
)
}
else
{
write!
(
f
,
"{}"
,
self
.name
)
return
write!
(
f
,
"'{}"
,
counter
);
}
write!
(
f
,
"{}"
,
self
.name
)
}
}
}
...
...
@@ -785,7 +762,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// `explain_region()` or `note_and_explain_region()`.
match
*
self
{
ty
::
ReEarlyBound
(
ref
data
)
=>
{
write!
(
f
,
"{}"
,
data
.name
)
if
data
.name
!=
"'_"
{
write!
(
f
,
"{}"
,
data
.name
)
}
else
{
Ok
(())
}
}
ty
::
ReLateBound
(
_
,
br
)
|
ty
::
ReFree
(
ty
::
FreeRegion
{
bound_region
:
br
,
..
})
=>
{
...
...
@@ -812,14 +793,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
),
}
}
ty
::
ReVar
(
region_vid
)
if
cx
.identify_regions
=>
{
write!
(
f
,
"{:?}"
,
region_vid
)
}
ty
::
ReVar
(
region_vid
)
=>
{
if
RegionHighlightMode
::
get
()
.any_region_vids_highlighted
()
{
write!
(
f
,
"{:?}"
,
region_vid
)
}
else
if
cx
.identify_regions
{
write!
(
f
,
"'{}rv"
,
region_vid
.index
())
}
else
{
Ok
(())
}
write!
(
f
,
"{}"
,
region_vid
)
}
ty
::
ReScope
(
_
)
|
ty
::
ReErased
=>
Ok
(()),
...
...
@@ -938,15 +916,30 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl
fmt
::
Debug
for
ty
::
RegionVid
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
if
let
Some
(
counter
)
=
RegionHighlightMode
::
get
()
.region_highlighted
(
&
ty
::
ReVar
(
*
self
))
{
return
write!
(
f
,
"'{:?}"
,
counter
);
}
else
if
RegionHighlightMode
::
get
()
.any_region_vids_highlighted
()
{
return
write!
(
f
,
"'_"
);
define_print!
{
()
ty
::
RegionVid
,
(
self
,
f
,
cx
)
{
display
{
if
cx
.is_verbose
{
return
self
.print_debug
(
f
,
cx
);
}
let
highlight
=
RegionHighlightMode
::
get
();
if
let
Some
(
counter
)
=
highlight
.region_highlighted
(
&
ty
::
ReVar
(
*
self
))
{
return
write!
(
f
,
"'{:?}"
,
counter
);
}
Ok
(())
}
debug
{
// HACK(eddyb) this is duplicated from `display` printing,
// to keep NLL borrowck working even with `-Zverbose`.
let
highlight
=
RegionHighlightMode
::
get
();
if
let
Some
(
counter
)
=
highlight
.region_highlighted
(
&
ty
::
ReVar
(
*
self
))
{
return
write!
(
f
,
"'{:?}"
,
counter
);
}
write!
(
f
,
"'_#{}r"
,
self
.index
())
write!
(
f
,
"'_#{}r"
,
self
.index
())
}
}
}
...
...
@@ -954,16 +947,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
()
ty
::
InferTy
,
(
self
,
f
,
cx
)
{
display
{
if
cx
.is_verbose
{
print!
(
f
,
cx
,
print_debug
(
self
))
}
else
{
match
*
self
{
ty
::
TyVar
(
_
)
=>
write!
(
f
,
"_"
),
ty
::
IntVar
(
_
)
=>
write!
(
f
,
"{}"
,
"{integer}"
),
ty
::
FloatVar
(
_
)
=>
write!
(
f
,
"{}"
,
"{float}"
),
ty
::
FreshTy
(
v
)
=>
write!
(
f
,
"FreshTy({})"
,
v
),
ty
::
FreshIntTy
(
v
)
=>
write!
(
f
,
"FreshIntTy({})"
,
v
),
ty
::
FreshFloatTy
(
v
)
=>
write!
(
f
,
"FreshFloatTy({})"
,
v
)
}
return
self
.print_debug
(
f
,
cx
);
}
match
*
self
{
ty
::
TyVar
(
_
)
=>
write!
(
f
,
"_"
),
ty
::
IntVar
(
_
)
=>
write!
(
f
,
"{}"
,
"{integer}"
),
ty
::
FloatVar
(
_
)
=>
write!
(
f
,
"{}"
,
"{float}"
),
ty
::
FreshTy
(
v
)
=>
write!
(
f
,
"FreshTy({})"
,
v
),
ty
::
FreshIntTy
(
v
)
=>
write!
(
f
,
"FreshIntTy({})"
,
v
),
ty
::
FreshFloatTy
(
v
)
=>
write!
(
f
,
"FreshFloatTy({})"
,
v
)
}
}
debug
{
...
...
@@ -1061,12 +1053,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
Ref
(
r
,
ty
,
mutbl
)
=>
{
write!
(
f
,
"&"
)
?
;
let
s
=
r
.print_to_string
(
cx
);
if
s
!=
"'_"
{
write!
(
f
,
"{}"
,
s
)
?
;
if
!
s
.is_empty
()
{
write!
(
f
,
" "
)
?
;
}
let
s
=
r
.print_display_to_string
(
cx
);
if
!
s
.is_empty
()
{
write!
(
f
,
"{} "
,
s
)
?
;
}
ty
::
TypeAndMut
{
ty
,
mutbl
}
.print
(
f
,
cx
)
}
...
...
@@ -1112,7 +1101,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
Adt
(
def
,
substs
)
=>
cx
.parameterized
(
f
,
def
.did
,
substs
,
iter
::
empty
()),
Dynamic
(
data
,
r
)
=>
{
let
r
=
r
.print_to_string
(
cx
);
let
r
=
r
.print_
display_
to_string
(
cx
);
if
!
r
.is_empty
()
{
write!
(
f
,
"("
)
?
;
}
...
...
src/test/ui/issues/issue-17905-2.stderr
浏览文件 @
329b8ca8
...
...
@@ -4,7 +4,7 @@ error[E0308]: mismatched method receiver
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Pair<&
'_
str, _>`
= note: expected type `Pair<&str, _>`
found type `Pair<&str, _>`
note: the anonymous lifetime #2 defined on the method body at 8:5...
--> $DIR/issue-17905-2.rs:8:5
...
...
@@ -27,7 +27,7 @@ error[E0308]: mismatched method receiver
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Pair<&
'_
str, _>`
= note: expected type `Pair<&str, _>`
found type `Pair<&str, _>`
note: the lifetime '_ as defined on the impl at 5:5...
--> $DIR/issue-17905-2.rs:5:5
...
...
src/test/ui/nll/closure-requirements/escape-argument-callee.stderr
浏览文件 @
329b8ca8
...
...
@@ -16,7 +16,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
| - - ^^^^^^ assignment requires that `'1` must outlive `'2`
| | |
| | has type `&'1 i32`
| has type `&mut &'2 i32`
| has type `&
'_#2r
mut &'2 i32`
note: No external requirements
--> $DIR/escape-argument-callee.rs:20:1
...
...
src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr
浏览文件 @
329b8ca8
...
...
@@ -20,9 +20,9 @@ error: lifetime may not live long enough
--> $DIR/propagate-approximated-fail-no-postdom.rs:46:13
|
LL | |_outlives1, _outlives2, _outlives3, x, y| {
| ---------- ---------- has type `std::cell::Cell<&'2 &u32>`
| ---------- ---------- has type `std::cell::Cell<&'2 &
'_#3r
u32>`
| |
| has type `std::cell::Cell<&&'1 u32>`
| has type `std::cell::Cell<&
'_#1r
&'1 u32>`
...
LL | demand_y(x, y, p)
| ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
...
...
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr
浏览文件 @
329b8ca8
...
...
@@ -20,9 +20,9 @@ error: lifetime may not live long enough
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:37:9
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| --------- - has type `&std::cell::Cell<&'1 u32>`
| --------- - has type `&
'_#7r
std::cell::Cell<&'1 u32>`
| |
| has type `&
std::cell::Cell<&'2 &
u32>`
| has type `&
'_#5r std::cell::Cell<&'2 &'_#1r
u32>`
LL | // Only works if 'x: 'y:
LL | demand_y(x, y, x.get())
| ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
...
...
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr
浏览文件 @
329b8ca8
...
...
@@ -20,9 +20,9 @@ error: lifetime may not live long enough
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:41:9
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| ---------- ---------- has type `&
std::cell::Cell<&'2 &
u32>`
| ---------- ---------- has type `&
'_#8r std::cell::Cell<&'2 &'_#2r
u32>`
| |
| has type `&
std::cell::Cell<&'1 &
u32>`
| has type `&
'_#6r std::cell::Cell<&'1 &'_#1r
u32>`
LL | // Only works if 'x: 'y:
LL | demand_y(x, y, x.get())
| ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录