Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fa2c2463
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,发现更多精彩内容 >>
提交
fa2c2463
编写于
9月 20, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stabilize crate_in_paths, extern_absolute_paths and extern_prelude on all editions.
上级
c97b60ff
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
61 addition
and
181 deletion
+61
-181
src/doc/unstable-book/src/language-features/crate-in-paths.md
...doc/unstable-book/src/language-features/crate-in-paths.md
+0
-49
src/doc/unstable-book/src/language-features/extern-absolute-paths.md
...table-book/src/language-features/extern-absolute-paths.md
+0
-43
src/librustc/lib.rs
src/librustc/lib.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-20
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+0
-8
src/librustc_traits/lib.rs
src/librustc_traits/lib.rs
+2
-2
src/librustdoc/core.rs
src/librustdoc/core.rs
+1
-3
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+7
-14
src/test/run-make-fulldeps/extern-prelude/Makefile
src/test/run-make-fulldeps/extern-prelude/Makefile
+0
-1
src/test/run-make-fulldeps/extern-prelude/feature-gate.rs
src/test/run-make-fulldeps/extern-prelude/feature-gate.rs
+0
-13
src/test/ui/feature-gates/feature-gate-crate_in_paths.rs
src/test/ui/feature-gates/feature-gate-crate_in_paths.rs
+0
-15
src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr
src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr
+0
-11
src/test/ui/hygiene/dollar-crate-modern.stderr
src/test/ui/hygiene/dollar-crate-modern.stderr
+8
-0
src/test/ui/macros/macro-path-prelude-pass.stderr
src/test/ui/macros/macro-path-prelude-pass.stderr
+8
-0
src/test/ui/run-pass/extern/extern-prelude-core.stderr
src/test/ui/run-pass/extern/extern-prelude-core.stderr
+8
-0
src/test/ui/run-pass/extern/extern-prelude-std.stderr
src/test/ui/run-pass/extern/extern-prelude-std.stderr
+8
-0
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr
...pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr
+8
-0
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr
...c-2126-crate-paths/crate-path-visibility-ambiguity.stderr
+8
-0
src/tools/cargo
src/tools/cargo
+1
-1
未找到文件。
src/doc/unstable-book/src/language-features/crate-in-paths.md
已删除
100644 → 0
浏览文件 @
c97b60ff
# `crate_in_paths`
The tracking issue for this feature is: [#44660]
[
#44660
]:
https://github.com/rust-lang/rust/issues/44660
------------------------
The
`crate_in_paths`
feature allows to explicitly refer to the crate root in absolute paths
using keyword
`crate`
.
This feature is required in
`feature(extern_absolute_paths)`
mode to refer to any absolute path
in the local crate (absolute paths refer to extern crates by default in that mode), but can be
used without
`feature(extern_absolute_paths)`
as well.
```
rust
#![feature(crate_in_paths)]
// Imports, `::` is added implicitly
use
crate
::
m
::
f
;
use
crate
as
root
;
mod
m
{
pub
fn
f
()
->
u8
{
1
}
pub
fn
g
()
->
u8
{
2
}
pub
fn
h
()
->
u8
{
3
}
// OK, visibilities implicitly add starting `::` as well, like imports
pub
(
in
crate
::
m
)
struct
S
;
}
mod
n
{
use
crate
::
m
::
f
;
use
crate
as
root
;
pub
fn
check
()
{
assert_eq!
(
f
(),
1
);
assert_eq!
(
crate
::
m
::
g
(),
2
);
assert_eq!
(
root
::
m
::
h
(),
3
);
}
}
fn
main
()
{
assert_eq!
(
f
(),
1
);
assert_eq!
(
crate
::
m
::
g
(),
2
);
assert_eq!
(
root
::
m
::
h
(),
3
);
n
::
check
();
}
```
src/doc/unstable-book/src/language-features/extern-absolute-paths.md
已删除
100644 → 0
浏览文件 @
c97b60ff
# `extern_absolute_paths`
The tracking issue for this feature is: [#44660]
[
#44660
]:
https://github.com/rust-lang/rust/issues/44660
------------------------
The
`extern_absolute_paths`
feature enables mode allowing to refer to names from other crates
"inline", without introducing
`extern crate`
items, using absolute paths like
`::my_crate::a::b`
.
`::my_crate::a::b`
will resolve to path
`a::b`
in crate
`my_crate`
.
`feature(crate_in_paths)`
can be used in
`feature(extern_absolute_paths)`
mode for referring
to absolute paths in the local crate (
`crate::a::b`
).
`feature(extern_in_paths)`
provides the same effect by using keyword
`extern`
to refer to
paths from other crates (
`extern::my_crate::a::b`
).
```
rust,ignore
#![feature(extern_absolute_paths)]
// Suppose we have a dependency crate `xcrate` available through `Cargo.toml`, or `--extern`
// options, or standard Rust distribution, or some other means.
use
xcrate
::
Z
;
fn
f
()
{
use
xcrate
;
use
xcrate
as
ycrate
;
let
s
=
xcrate
::
S
;
assert_eq!
(
format!
(
"{:?}"
,
s
),
"S"
);
let
z
=
ycrate
::
Z
;
assert_eq!
(
format!
(
"{:?}"
,
z
),
"Z"
);
}
fn
main
()
{
let
s
=
::
xcrate
::
S
;
assert_eq!
(
format!
(
"{:?}"
,
s
),
"S"
);
let
z
=
Z
;
assert_eq!
(
format!
(
"{:?}"
,
z
),
"Z"
);
}
```
src/librustc/lib.rs
浏览文件 @
fa2c2463
...
...
@@ -73,7 +73,7 @@
#![cfg_attr(not(stage0),
feature(impl_header_lifetime_elision))]
#![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)]
#![
feature(crate_in_paths
)]
#![
cfg_attr(stage0,
feature(crate_in_paths)
)]
#![feature(crate_visibility_modifier)]
#![recursion_limit=
"512"
]
...
...
src/librustc_resolve/lib.rs
浏览文件 @
fa2c2463
...
...
@@ -65,7 +65,6 @@
use
syntax
::
ast
::{
Item
,
ItemKind
,
ImplItem
,
ImplItemKind
};
use
syntax
::
ast
::{
Label
,
Local
,
Mutability
,
Pat
,
PatKind
,
Path
};
use
syntax
::
ast
::{
QSelf
,
TraitItemKind
,
TraitRef
,
Ty
,
TyKind
};
use
syntax
::
feature_gate
::{
feature_err
,
GateIssue
};
use
syntax
::
ptr
::
P
;
use
syntax_pos
::{
Span
,
DUMMY_SP
,
MultiSpan
};
...
...
@@ -1466,9 +1465,6 @@ pub struct Resolver<'a, 'b: 'a> {
current_type_ascription
:
Vec
<
Span
>
,
injected_crate
:
Option
<
Module
<
'a
>>
,
/// Only supposed to be used by rustdoc, otherwise should be false.
pub
ignore_extern_prelude_feature
:
bool
,
}
/// Nothing really interesting here, it just provides memory for the rest of the crate.
...
...
@@ -1766,7 +1762,6 @@ pub fn new(session: &'a Session,
unused_macros
:
FxHashSet
(),
current_type_ascription
:
Vec
::
new
(),
injected_crate
:
None
,
ignore_extern_prelude_feature
:
false
,
}
}
...
...
@@ -1969,13 +1964,6 @@ fn resolve_ident_in_lexical_scope(&mut self,
if
!
module
.no_implicit_prelude
{
// `record_used` means that we don't try to load crates during speculative resolution
if
record_used
&&
ns
==
TypeNS
&&
self
.extern_prelude
.contains
(
&
ident
.name
)
{
if
!
self
.session
.features_untracked
()
.extern_prelude
&&
!
self
.ignore_extern_prelude_feature
{
feature_err
(
&
self
.session.parse_sess
,
"extern_prelude"
,
ident
.span
,
GateIssue
::
Language
,
"access to extern crates through prelude is experimental"
)
.emit
();
}
let
crate_id
=
self
.crate_loader
.process_path_extern
(
ident
.name
,
ident
.span
);
let
crate_root
=
self
.get_module
(
DefId
{
krate
:
crate_id
,
index
:
CRATE_DEF_INDEX
});
self
.populate_module_if_necessary
(
&
crate_root
);
...
...
@@ -3576,7 +3564,6 @@ fn resolve_path_with_parent_scope(
}
if
name
==
keywords
::
Extern
.name
()
||
name
==
keywords
::
CrateRoot
.name
()
&&
self
.session
.features_untracked
()
.extern_absolute_paths
&&
self
.session
.rust_2018
()
{
module
=
Some
(
ModuleOrUniformRoot
::
UniformRoot
(
name
));
continue
;
...
...
@@ -3715,12 +3702,6 @@ fn lint_if_path_starts_with_module(
return
}
// In the 2015 edition there's no use in emitting lints unless the
// crate's already enabled the feature that we're going to suggest
if
!
self
.session
.features_untracked
()
.crate_in_paths
{
return
}
let
(
diag_id
,
diag_span
)
=
match
crate_lint
{
CrateLint
::
No
=>
return
,
CrateLint
::
SimplePath
(
id
)
=>
(
id
,
path_span
),
...
...
@@ -4417,7 +4398,7 @@ fn lookup_import_candidates<FilterFn>(&mut self,
)
);
if
self
.session
.
features_untracked
()
.extern_prelude
{
if
self
.session
.
rust_2018
()
{
let
extern_prelude_names
=
self
.extern_prelude
.clone
();
for
&
name
in
extern_prelude_names
.iter
()
{
let
ident
=
Ident
::
with_empty_ctxt
(
name
);
...
...
src/librustc_resolve/macros.rs
浏览文件 @
fa2c2463
...
...
@@ -682,14 +682,6 @@ enum WhereToResolve<'a> {
}
WhereToResolve
::
ExternPrelude
=>
{
if
use_prelude
&&
self
.extern_prelude
.contains
(
&
ident
.name
)
{
if
!
self
.session
.features_untracked
()
.extern_prelude
&&
!
self
.ignore_extern_prelude_feature
{
feature_err
(
&
self
.session.parse_sess
,
"extern_prelude"
,
ident
.span
,
GateIssue
::
Language
,
"access to extern crates through prelude is experimental"
)
.emit
();
}
let
crate_id
=
self
.crate_loader
.process_path_extern
(
ident
.name
,
ident
.span
);
let
crate_root
=
...
...
src/librustc_traits/lib.rs
浏览文件 @
fa2c2463
...
...
@@ -11,9 +11,9 @@
//! New recursive solver modeled on Chalk's recursive solver. Most of
//! the guts are broken up into modules; see the comments in those modules.
#![
feature(crate_in_paths
)]
#![
cfg_attr(stage0,
feature(crate_in_paths)
)]
#![feature(crate_visibility_modifier)]
#![
feature(extern_prelude
)]
#![
cfg_attr(stage0,
feature(extern_prelude)
)]
#![feature(in_band_lifetimes)]
#![cfg_attr(not(stage0),
feature(nll))]
...
...
src/librustdoc/core.rs
浏览文件 @
fa2c2463
...
...
@@ -455,12 +455,10 @@ pub fn run_core(search_paths: SearchPaths,
|
_
|
Ok
(()));
let
driver
::
InnerExpansionResult
{
mut
hir_forest
,
mut
resolver
,
resolver
,
..
}
=
abort_on_err
(
result
,
&
sess
);
resolver
.ignore_extern_prelude_feature
=
true
;
// We need to hold on to the complete resolver, so we clone everything
// for the analysis passes to use. Suboptimal, but necessary in the
// current architecture.
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
fa2c2463
...
...
@@ -394,18 +394,12 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
// Allows trait methods with arbitrary self types
(
active
,
arbitrary_self_types
,
"1.23.0"
,
Some
(
44874
),
None
),
// `crate` in paths
(
active
,
crate_in_paths
,
"1.23.0"
,
Some
(
45477
),
Some
(
Edition
::
Edition2018
)),
// In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`)
(
active
,
in_band_lifetimes
,
"1.23.0"
,
Some
(
44524
),
None
),
// Generic associated types (RFC 1598)
(
active
,
generic_associated_types
,
"1.23.0"
,
Some
(
44265
),
None
),
// Resolve absolute paths as paths from other crates
(
active
,
extern_absolute_paths
,
"1.24.0"
,
Some
(
44660
),
Some
(
Edition
::
Edition2018
)),
// `extern` in paths
(
active
,
extern_in_paths
,
"1.23.0"
,
Some
(
44660
),
None
),
...
...
@@ -455,9 +449,6 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
// #[doc(alias = "...")]
(
active
,
doc_alias
,
"1.27.0"
,
Some
(
50146
),
None
),
// Access to crate names passed via `--extern` through prelude
(
active
,
extern_prelude
,
"1.27.0"
,
Some
(
44660
),
Some
(
Edition
::
Edition2018
)),
// Scoped lints
(
active
,
tool_lints
,
"1.28.0"
,
Some
(
44690
),
None
),
...
...
@@ -683,7 +674,12 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
(
accepted
,
panic_handler
,
"1.30.0"
,
Some
(
44489
),
None
),
// Used to preserve symbols (see llvm.used)
(
accepted
,
used
,
"1.30.0"
,
Some
(
40289
),
None
),
// `crate` in paths
(
accepted
,
crate_in_paths
,
"1.30.0"
,
Some
(
45477
),
None
),
// Resolve absolute paths as paths from other crates
(
accepted
,
extern_absolute_paths
,
"1.30.0"
,
Some
(
44660
),
None
),
// Access to crate names passed via `--extern` through prelude
(
accepted
,
extern_prelude
,
"1.30.0"
,
Some
(
44660
),
None
),
);
// If you change this, please modify src/doc/unstable-book as well. You must
...
...
@@ -1892,10 +1888,7 @@ fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
// cannot be kept in identifiers, so it's kept in paths instead and we take it from
// there while keeping location info from the ident span.
let
span
=
segment
.ident.span
.with_ctxt
(
path
.span
.ctxt
());
if
segment
.ident.name
==
keywords
::
Crate
.name
()
{
gate_feature_post!
(
&
self
,
crate_in_paths
,
span
,
"`crate` in paths is experimental"
);
}
else
if
segment
.ident.name
==
keywords
::
Extern
.name
()
{
if
segment
.ident.name
==
keywords
::
Extern
.name
()
{
gate_feature_post!
(
&
self
,
extern_in_paths
,
span
,
"`extern` in paths is experimental"
);
}
...
...
src/test/run-make-fulldeps/extern-prelude/Makefile
浏览文件 @
fa2c2463
...
...
@@ -7,6 +7,5 @@ all:
$(RUSTC)
basic.rs
--extern
ep_lib
=
$(TMPDIR)
/libep_lib.rlib
$(RUSTC)
shadow-mod.rs
--extern
ep_lib
=
$(TMPDIR)
/libep_lib.rlib
$(RUSTC)
shadow-prelude.rs
--extern
Vec
=
$(TMPDIR)
/libep_vec.rlib
$(RUSTC)
feature-gate.rs
--extern
ep_lib
=
$(TMPDIR)
/libep_lib.rlib 2>&1 |
$(CGREP)
"access to extern crates through prelude is experimental"
$(RUSTC)
relative-only.rs
--extern
ep_lib
=
$(TMPDIR)
/libep_lib.rlib 2>&1 |
$(CGREP)
"unresolved import"
$(RUSTC)
relative-only.rs
--extern
ep_lib
=
$(TMPDIR)
/libep_lib.rlib 2>&1 |
$(CGREP)
"failed to resolve"
src/test/run-make-fulldeps/extern-prelude/feature-gate.rs
已删除
100644 → 0
浏览文件 @
c97b60ff
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
main
()
{
let
s
=
ep_lib
::
S
;
// Feature error
}
src/test/ui/feature-gates/feature-gate-crate_in_paths.rs
已删除
100644 → 0
浏览文件 @
c97b60ff
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct
S
;
fn
main
()
{
let
_
=
crate
::
S
;
//~ ERROR `crate` in paths is experimental
}
src/test/ui/feature-gates/feature-gate-crate_in_paths.stderr
已删除
100644 → 0
浏览文件 @
c97b60ff
error[E0658]: `crate` in paths is experimental (see issue #45477)
--> $DIR/feature-gate-crate_in_paths.rs:14:13
|
LL | let _ = crate::S; //~ ERROR `crate` in paths is experimental
| ^^^^^
|
= help: add #![feature(crate_in_paths)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
src/test/ui/hygiene/dollar-crate-modern.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/dollar-crate-modern.rs:16:24
|
LL | #![feature(decl_macro, crate_in_paths)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
src/test/ui/macros/macro-path-prelude-pass.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/macro-path-prelude-pass.rs:13:12
|
LL | #![feature(extern_prelude)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
src/test/ui/run-pass/extern/extern-prelude-core.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/extern-prelude-core.rs:12:12
|
LL | #![feature(extern_prelude, lang_items, start, alloc)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
src/test/ui/run-pass/extern/extern-prelude-std.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/extern-prelude-std.rs:12:12
|
LL | #![feature(extern_prelude)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/crate-path-absolute.rs:12:12
|
LL | #![feature(crate_in_paths)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr
0 → 100644
浏览文件 @
fa2c2463
warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/crate-path-visibility-ambiguity.rs:12:12
|
LL | #![feature(crate_in_paths)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
cargo
@
de314a8b
比较
b1e1d388
...
de314a8b
Subproject commit
b1e1d388ea09ecc27515345b180dd02263b087df
Subproject commit
de314a8b2d45bce4958fc23939c5e4286e31621c
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录