Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c6554733
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,发现更多精彩内容 >>
提交
c6554733
编写于
8月 18, 2018
作者:
D
Donato Sciarra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mv CodeMap SourceMap
上级
3ac79c71
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
133 addition
and
133 deletion
+133
-133
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+2
-2
src/librustc/hir/map/definitions.rs
src/librustc/hir/map/definitions.rs
+1
-1
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+5
-5
src/librustc/ich/caching_codemap_view.rs
src/librustc/ich/caching_codemap_view.rs
+3
-3
src/librustc/ich/hcx.rs
src/librustc/ich/hcx.rs
+4
-4
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+4
-4
src/librustc/ty/query/on_disk_cache.rs
src/librustc/ty/query/on_disk_cache.rs
+4
-4
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+2
-2
src/librustc_driver/test.rs
src/librustc_driver/test.rs
+2
-2
src/librustc_errors/emitter.rs
src/librustc_errors/emitter.rs
+4
-4
src/librustc_errors/lib.rs
src/librustc_errors/lib.rs
+5
-5
src/librustc_metadata/decoder.rs
src/librustc_metadata/decoder.rs
+2
-2
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+2
-2
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/demand.rs
+1
-1
src/librustdoc/core.rs
src/librustdoc/core.rs
+4
-4
src/librustdoc/html/highlight.rs
src/librustdoc/html/highlight.rs
+3
-3
src/librustdoc/test.rs
src/librustdoc/test.rs
+6
-6
src/libsyntax/codemap.rs
src/libsyntax/codemap.rs
+29
-29
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+2
-2
src/libsyntax/json.rs
src/libsyntax/json.rs
+6
-6
src/libsyntax/parse/lexer/comments.rs
src/libsyntax/parse/lexer/comments.rs
+2
-2
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/lexer/mod.rs
+18
-18
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+5
-5
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+2
-2
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+5
-5
src/libsyntax/test.rs
src/libsyntax/test.rs
+1
-1
src/libsyntax/test_snippet.rs
src/libsyntax/test_snippet.rs
+2
-2
src/libsyntax_pos/lib.rs
src/libsyntax_pos/lib.rs
+7
-7
未找到文件。
src/librustc/hir/map/collector.rs
浏览文件 @
c6554733
...
...
@@ -18,7 +18,7 @@
use
session
::
CrateDisambiguator
;
use
std
::
iter
::
repeat
;
use
syntax
::
ast
::{
NodeId
,
CRATE_NODE_ID
};
use
syntax
::
codemap
::
Cod
eMap
;
use
syntax
::
codemap
::
Sourc
eMap
;
use
syntax_pos
::
Span
;
use
ich
::
StableHashingContext
;
...
...
@@ -122,7 +122,7 @@ pub(super) fn root(krate: &'hir Crate,
pub
(
super
)
fn
finalize_and_compute_crate_hash
(
mut
self
,
crate_disambiguator
:
CrateDisambiguator
,
cstore
:
&
dyn
CrateStore
,
codemap
:
&
Cod
eMap
,
codemap
:
&
Sourc
eMap
,
commandline_args_hash
:
u64
)
->
(
Vec
<
MapEntry
<
'hir
>>
,
Svh
)
{
self
...
...
src/librustc/hir/map/definitions.rs
浏览文件 @
c6554733
...
...
@@ -739,7 +739,7 @@ fn name(&self) -> Symbol {
LangItems
,
LangItemsMissing
,
NativeLibraries
,
Cod
eMap
,
Sourc
eMap
,
Impls
,
ExportedSymbols
});
src/librustc/hir/print.rs
浏览文件 @
c6554733
...
...
@@ -12,7 +12,7 @@
use
rustc_target
::
spec
::
abi
::
Abi
;
use
syntax
::
ast
;
use
syntax
::
codemap
::{
Cod
eMap
,
Spanned
};
use
syntax
::
codemap
::{
Sourc
eMap
,
Spanned
};
use
syntax
::
parse
::
ParseSess
;
use
syntax
::
parse
::
lexer
::
comments
;
use
syntax
::
print
::
pp
::{
self
,
Breaks
};
...
...
@@ -85,7 +85,7 @@ fn nested(&self, state: &mut State, nested: Nested) -> io::Result<()> {
pub
struct
State
<
'a
>
{
pub
s
:
pp
::
Printer
<
'a
>
,
cm
:
Option
<&
'a
Cod
eMap
>
,
cm
:
Option
<&
'a
Sourc
eMap
>
,
comments
:
Option
<
Vec
<
comments
::
Comment
>>
,
literals
:
Peekable
<
vec
::
IntoIter
<
comments
::
Literal
>>
,
cur_cmnt
:
usize
,
...
...
@@ -129,7 +129,7 @@ fn bump_lit(&mut self) -> Option<comments::Literal> {
/// Requires you to pass an input filename and reader so that
/// it can scan the input text for comments and literals to
/// copy forward.
pub
fn
print_crate
<
'a
>
(
cm
:
&
'a
Cod
eMap
,
pub
fn
print_crate
<
'a
>
(
cm
:
&
'a
Sourc
eMap
,
sess
:
&
ParseSess
,
krate
:
&
hir
::
Crate
,
filename
:
FileName
,
...
...
@@ -149,7 +149,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
}
impl
<
'a
>
State
<
'a
>
{
pub
fn
new_from_input
(
cm
:
&
'a
Cod
eMap
,
pub
fn
new_from_input
(
cm
:
&
'a
Sourc
eMap
,
sess
:
&
ParseSess
,
filename
:
FileName
,
input
:
&
mut
dyn
Read
,
...
...
@@ -173,7 +173,7 @@ pub fn new_from_input(cm: &'a CodeMap,
})
}
pub
fn
new
(
cm
:
&
'a
Cod
eMap
,
pub
fn
new
(
cm
:
&
'a
Sourc
eMap
,
out
:
Box
<
dyn
Write
+
'a
>
,
ann
:
&
'a
dyn
PpAnn
,
comments
:
Option
<
Vec
<
comments
::
Comment
>>
,
...
...
src/librustc/ich/caching_codemap_view.rs
浏览文件 @
c6554733
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
rustc_data_structures
::
sync
::
Lrc
;
use
syntax
::
codemap
::
Cod
eMap
;
use
syntax
::
codemap
::
Sourc
eMap
;
use
syntax_pos
::{
BytePos
,
FileMap
};
#[derive(Clone)]
...
...
@@ -24,13 +24,13 @@ struct CacheEntry {
#[derive(Clone)]
pub
struct
CachingCodemapView
<
'cm
>
{
codemap
:
&
'cm
Cod
eMap
,
codemap
:
&
'cm
Sourc
eMap
,
line_cache
:
[
CacheEntry
;
3
],
time_stamp
:
usize
,
}
impl
<
'cm
>
CachingCodemapView
<
'cm
>
{
pub
fn
new
(
codemap
:
&
'cm
Cod
eMap
)
->
CachingCodemapView
<
'cm
>
{
pub
fn
new
(
codemap
:
&
'cm
Sourc
eMap
)
->
CachingCodemapView
<
'cm
>
{
let
files
=
codemap
.files
();
let
first_file
=
files
[
0
]
.clone
();
let
entry
=
CacheEntry
{
...
...
src/librustc/ich/hcx.rs
浏览文件 @
c6554733
...
...
@@ -25,7 +25,7 @@
use
syntax
::
ast
;
use
syntax
::
codemap
::
Cod
eMap
;
use
syntax
::
codemap
::
Sourc
eMap
;
use
syntax
::
ext
::
hygiene
::
SyntaxContext
;
use
syntax
::
symbol
::
Symbol
;
use
syntax_pos
::{
Span
,
DUMMY_SP
};
...
...
@@ -58,7 +58,7 @@ pub struct StableHashingContext<'a> {
// Very often, we are hashing something that does not need the
// CachingCodemapView, so we initialize it lazily.
raw_codemap
:
&
'a
Cod
eMap
,
raw_codemap
:
&
'a
Sourc
eMap
,
caching_codemap
:
Option
<
CachingCodemapView
<
'a
>>
,
pub
(
super
)
alloc_id_recursion_tracker
:
FxHashSet
<
AllocId
>
,
...
...
@@ -308,9 +308,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
// Hash a span in a stable way. We can't directly hash the span's BytePos
// fields (that would be similar to hashing pointers, since those are just
// offsets into the
Cod
eMap). Instead, we hash the (file name, line, column)
// offsets into the
Sourc
eMap). Instead, we hash the (file name, line, column)
// triple, which stays the same even if the containing FileMap has moved
// within the
Cod
eMap.
// within the
Sourc
eMap.
// Also note that we are hashing byte offsets for the column, not unicode
// codepoint offsets. For the purpose of the hash that's sufficient.
// Also, hashing filenames is expensive so we avoid doing it twice when the
...
...
src/librustc/session/mod.rs
浏览文件 @
c6554733
...
...
@@ -484,7 +484,7 @@ pub fn diag_span_suggestion_once<'a, 'b>(
);
}
pub
fn
codemap
<
'a
>
(
&
'a
self
)
->
&
'a
codemap
::
Cod
eMap
{
pub
fn
codemap
<
'a
>
(
&
'a
self
)
->
&
'a
codemap
::
Sourc
eMap
{
self
.parse_sess
.codemap
()
}
pub
fn
verbose
(
&
self
)
->
bool
{
...
...
@@ -984,7 +984,7 @@ pub fn build_session(
sopts
,
local_crate_source_file
,
registry
,
Lrc
::
new
(
codemap
::
Cod
eMap
::
new
(
file_path_mapping
)),
Lrc
::
new
(
codemap
::
Sourc
eMap
::
new
(
file_path_mapping
)),
None
,
)
}
...
...
@@ -993,7 +993,7 @@ pub fn build_session_with_codemap(
sopts
:
config
::
Options
,
local_crate_source_file
:
Option
<
PathBuf
>
,
registry
:
errors
::
registry
::
Registry
,
codemap
:
Lrc
<
codemap
::
Cod
eMap
>
,
codemap
:
Lrc
<
codemap
::
Sourc
eMap
>
,
emitter_dest
:
Option
<
Box
<
dyn
Write
+
Send
>>
,
)
->
Session
{
// FIXME: This is not general enough to make the warning lint completely override
...
...
@@ -1070,7 +1070,7 @@ pub fn build_session_(
sopts
:
config
::
Options
,
local_crate_source_file
:
Option
<
PathBuf
>
,
span_diagnostic
:
errors
::
Handler
,
codemap
:
Lrc
<
codemap
::
Cod
eMap
>
,
codemap
:
Lrc
<
codemap
::
Sourc
eMap
>
,
)
->
Session
{
let
host_triple
=
TargetTriple
::
from_triple
(
config
::
host_triple
());
let
host
=
match
Target
::
search
(
&
host_triple
)
{
...
...
src/librustc/ty/query/on_disk_cache.rs
浏览文件 @
c6554733
...
...
@@ -26,7 +26,7 @@
use
session
::{
CrateDisambiguator
,
Session
};
use
std
::
mem
;
use
syntax
::
ast
::
NodeId
;
use
syntax
::
codemap
::{
Cod
eMap
,
StableFilemapId
};
use
syntax
::
codemap
::{
Sourc
eMap
,
StableFilemapId
};
use
syntax_pos
::{
BytePos
,
Span
,
DUMMY_SP
,
FileMap
};
use
syntax_pos
::
hygiene
::{
Mark
,
SyntaxContext
,
ExpnInfo
};
use
ty
;
...
...
@@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> {
prev_cnums
:
Vec
<
(
u32
,
String
,
CrateDisambiguator
)
>
,
cnum_map
:
Once
<
IndexVec
<
CrateNum
,
Option
<
CrateNum
>>>
,
codemap
:
&
'sess
Cod
eMap
,
codemap
:
&
'sess
Sourc
eMap
,
file_index_to_stable_id
:
FxHashMap
<
FileMapIndex
,
StableFilemapId
>
,
// These two fields caches that are populated lazily during decoding.
...
...
@@ -149,7 +149,7 @@ pub fn new(sess: &'sess Session, data: Vec<u8>, start_pos: usize) -> OnDiskCache
}
}
pub
fn
new_empty
(
codemap
:
&
'sess
Cod
eMap
)
->
OnDiskCache
<
'sess
>
{
pub
fn
new_empty
(
codemap
:
&
'sess
Sourc
eMap
)
->
OnDiskCache
<
'sess
>
{
OnDiskCache
{
serialized_data
:
Vec
::
new
(),
file_index_to_stable_id
:
FxHashMap
(),
...
...
@@ -475,7 +475,7 @@ fn compute_cnum_map(tcx: TyCtxt,
struct
CacheDecoder
<
'a
,
'tcx
:
'a
,
'x
>
{
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
opaque
:
opaque
::
Decoder
<
'x
>
,
codemap
:
&
'x
Cod
eMap
,
codemap
:
&
'x
Sourc
eMap
,
cnum_map
:
&
'x
IndexVec
<
CrateNum
,
Option
<
CrateNum
>>
,
synthetic_expansion_infos
:
&
'x
Lock
<
FxHashMap
<
AbsoluteBytePos
,
SyntaxContext
>>
,
file_index_to_file
:
&
'x
Lock
<
FxHashMap
<
FileMapIndex
,
Lrc
<
FileMap
>>>
,
...
...
src/librustc_driver/lib.rs
浏览文件 @
c6554733
...
...
@@ -107,7 +107,7 @@
use
std
::
thread
;
use
syntax
::
ast
;
use
syntax
::
codemap
::{
Cod
eMap
,
FileLoader
,
RealFileLoader
};
use
syntax
::
codemap
::{
Sourc
eMap
,
FileLoader
,
RealFileLoader
};
use
syntax
::
feature_gate
::{
GatedCfg
,
UnstableFeatures
};
use
syntax
::
parse
::{
self
,
PResult
};
use
syntax_pos
::{
DUMMY_SP
,
MultiSpan
,
FileName
};
...
...
@@ -522,7 +522,7 @@ fn run_compiler_with_pool<'a>(
};
let
loader
=
file_loader
.unwrap_or
(
box
RealFileLoader
);
let
codemap
=
Lrc
::
new
(
Cod
eMap
::
with_file_loader
(
loader
,
sopts
.file_path_mapping
()));
let
codemap
=
Lrc
::
new
(
Sourc
eMap
::
with_file_loader
(
loader
,
sopts
.file_path_mapping
()));
let
mut
sess
=
session
::
build_session_with_codemap
(
sopts
,
input_file_path
.clone
(),
descriptions
,
codemap
,
emitter_dest
,
);
...
...
src/librustc_driver/test.rs
浏览文件 @
c6554733
...
...
@@ -32,7 +32,7 @@
use
syntax
;
use
syntax
::
ast
;
use
rustc_target
::
spec
::
abi
::
Abi
;
use
syntax
::
codemap
::{
Cod
eMap
,
FilePathMapping
,
FileName
};
use
syntax
::
codemap
::{
Sourc
eMap
,
FilePathMapping
,
FileName
};
use
errors
;
use
errors
::
emitter
::
Emitter
;
use
errors
::{
Level
,
DiagnosticBuilder
};
...
...
@@ -121,7 +121,7 @@ fn test_env_with_pool<F>(
let
sess
=
session
::
build_session_
(
options
,
None
,
diagnostic_handler
,
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
())));
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
())));
let
cstore
=
CStore
::
new
(::
get_codegen_backend
(
&
sess
)
.metadata_loader
());
rustc_lint
::
register_builtins
(
&
mut
sess
.lint_store
.borrow_mut
(),
Some
(
&
sess
));
let
input
=
config
::
Input
::
Str
{
...
...
src/librustc_errors/emitter.rs
浏览文件 @
c6554733
...
...
@@ -12,7 +12,7 @@
use
syntax_pos
::{
FileMap
,
Span
,
MultiSpan
};
use
{
Level
,
CodeSuggestion
,
DiagnosticBuilder
,
SubDiagnostic
,
Cod
eMapperDyn
,
DiagnosticId
};
use
{
Level
,
CodeSuggestion
,
DiagnosticBuilder
,
SubDiagnostic
,
Sourc
eMapperDyn
,
DiagnosticId
};
use
snippet
::{
Annotation
,
AnnotationType
,
Line
,
MultilineAnnotation
,
StyledString
,
Style
};
use
styled_buffer
::
StyledBuffer
;
...
...
@@ -120,7 +120,7 @@ fn to_color_choice(&self) -> ColorChoice {
pub
struct
EmitterWriter
{
dst
:
Destination
,
cm
:
Option
<
Lrc
<
Cod
eMapperDyn
>>
,
cm
:
Option
<
Lrc
<
Sourc
eMapperDyn
>>
,
short_message
:
bool
,
teach
:
bool
,
ui_testing
:
bool
,
...
...
@@ -134,7 +134,7 @@ struct FileWithAnnotatedLines {
impl
EmitterWriter
{
pub
fn
stderr
(
color_config
:
ColorConfig
,
code_map
:
Option
<
Lrc
<
Cod
eMapperDyn
>>
,
code_map
:
Option
<
Lrc
<
Sourc
eMapperDyn
>>
,
short_message
:
bool
,
teach
:
bool
)
->
EmitterWriter
{
...
...
@@ -149,7 +149,7 @@ pub fn stderr(color_config: ColorConfig,
}
pub
fn
new
(
dst
:
Box
<
dyn
Write
+
Send
>
,
code_map
:
Option
<
Lrc
<
Cod
eMapperDyn
>>
,
code_map
:
Option
<
Lrc
<
Sourc
eMapperDyn
>>
,
short_message
:
bool
,
teach
:
bool
)
->
EmitterWriter
{
...
...
src/librustc_errors/lib.rs
浏览文件 @
c6554733
...
...
@@ -111,9 +111,9 @@ pub struct SubstitutionPart {
pub
snippet
:
String
,
}
pub
type
CodeMapperDyn
=
dyn
Cod
eMapper
+
sync
::
Send
+
sync
::
Sync
;
pub
type
SourceMapperDyn
=
dyn
Sourc
eMapper
+
sync
::
Send
+
sync
::
Sync
;
pub
trait
Cod
eMapper
{
pub
trait
Sourc
eMapper
{
fn
lookup_char_pos
(
&
self
,
pos
:
BytePos
)
->
Loc
;
fn
span_to_lines
(
&
self
,
sp
:
Span
)
->
FileLinesResult
;
fn
span_to_string
(
&
self
,
sp
:
Span
)
->
String
;
...
...
@@ -126,7 +126,7 @@ pub trait CodeMapper {
impl
CodeSuggestion
{
/// Returns the assembled code suggestions and whether they should be shown with an underline.
pub
fn
splice_lines
(
&
self
,
cm
:
&
Cod
eMapperDyn
)
pub
fn
splice_lines
(
&
self
,
cm
:
&
Sourc
eMapperDyn
)
->
Vec
<
(
String
,
Vec
<
SubstitutionPart
>
)
>
{
use
syntax_pos
::{
CharPos
,
Loc
,
Pos
};
...
...
@@ -321,7 +321,7 @@ impl Handler {
pub
fn
with_tty_emitter
(
color_config
:
ColorConfig
,
can_emit_warnings
:
bool
,
treat_err_as_bug
:
bool
,
cm
:
Option
<
Lrc
<
Cod
eMapperDyn
>>
)
cm
:
Option
<
Lrc
<
Sourc
eMapperDyn
>>
)
->
Handler
{
Handler
::
with_tty_emitter_and_flags
(
color_config
,
...
...
@@ -334,7 +334,7 @@ pub fn with_tty_emitter(color_config: ColorConfig,
}
pub
fn
with_tty_emitter_and_flags
(
color_config
:
ColorConfig
,
cm
:
Option
<
Lrc
<
Cod
eMapperDyn
>>
,
cm
:
Option
<
Lrc
<
Sourc
eMapperDyn
>>
,
flags
:
HandlerFlags
)
->
Handler
{
let
emitter
=
Box
::
new
(
EmitterWriter
::
stderr
(
color_config
,
cm
,
false
,
false
));
...
...
src/librustc_metadata/decoder.rs
浏览文件 @
c6554733
...
...
@@ -1117,7 +1117,7 @@ pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
/// multibyte characters. This information is enough to generate valid debuginfo
/// for items inlined from other crates.
pub
fn
imported_filemaps
(
&
'a
self
,
local_codemap
:
&
codemap
::
Cod
eMap
)
local_codemap
:
&
codemap
::
Sourc
eMap
)
->
ReadGuard
<
'a
,
Vec
<
cstore
::
ImportedFileMap
>>
{
{
let
filemaps
=
self
.codemap_import_info
.borrow
();
...
...
@@ -1154,7 +1154,7 @@ pub fn imported_filemaps(&'a self,
// Translate line-start positions and multibyte character
// position into frame of reference local to file.
// `
Cod
eMap::new_imported_filemap()` will then translate those
// `
Sourc
eMap::new_imported_filemap()` will then translate those
// coordinates to their new global frame of reference when the
// offset of the FileMap is known.
for
pos
in
&
mut
lines
{
...
...
src/librustc_resolve/lib.rs
浏览文件 @
c6554733
...
...
@@ -49,7 +49,7 @@
use
rustc_metadata
::
creader
::
CrateLoader
;
use
rustc_metadata
::
cstore
::
CStore
;
use
syntax
::
codemap
::
Cod
eMap
;
use
syntax
::
codemap
::
Sourc
eMap
;
use
syntax
::
ext
::
hygiene
::{
Mark
,
Transparency
,
SyntaxContext
};
use
syntax
::
ast
::{
self
,
Name
,
NodeId
,
Ident
,
FloatTy
,
IntTy
,
UintTy
};
use
syntax
::
ext
::
base
::
SyntaxExtension
;
...
...
@@ -415,7 +415,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
/// Attention: The method used is very fragile since it essentially duplicates the work of the
/// parser. If you need to use this function or something similar, please consider updating the
/// codemap functions and this function to something more robust.
fn
reduce_impl_span_to_impl_keyword
(
cm
:
&
Cod
eMap
,
impl_span
:
Span
)
->
Span
{
fn
reduce_impl_span_to_impl_keyword
(
cm
:
&
Sourc
eMap
,
impl_span
:
Span
)
->
Span
{
let
impl_span
=
cm
.span_until_char
(
impl_span
,
'<'
);
let
impl_span
=
cm
.span_until_whitespace
(
impl_span
);
impl_span
...
...
src/librustc_typeck/check/demand.rs
浏览文件 @
c6554733
...
...
@@ -21,7 +21,7 @@
use
rustc
::
hir
::{
Item
,
ItemKind
,
print
};
use
rustc
::
ty
::{
self
,
Ty
,
AssociatedItem
};
use
rustc
::
ty
::
adjustment
::
AllowTwoPhase
;
use
errors
::{
DiagnosticBuilder
,
Cod
eMapper
};
use
errors
::{
DiagnosticBuilder
,
Sourc
eMapper
};
use
super
::
method
::
probe
;
...
...
src/librustdoc/core.rs
浏览文件 @
c6554733
...
...
@@ -258,9 +258,9 @@ fn is_doc_reachable(&self, did: DefId) -> bool {
/// Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
///
/// If the given `error_format` is `ErrorOutputType::Json` and no `
Cod
eMap` is given, a new one
/// If the given `error_format` is `ErrorOutputType::Json` and no `
Sourc
eMap` is given, a new one
/// will be created for the handler.
pub
fn
new_handler
(
error_format
:
ErrorOutputType
,
codemap
:
Option
<
Lrc
<
codemap
::
Cod
eMap
>>
)
pub
fn
new_handler
(
error_format
:
ErrorOutputType
,
codemap
:
Option
<
Lrc
<
codemap
::
Sourc
eMap
>>
)
->
errors
::
Handler
{
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
...
...
@@ -277,7 +277,7 @@ pub fn new_handler(error_format: ErrorOutputType, codemap: Option<Lrc<codemap::C
),
ErrorOutputType
::
Json
(
pretty
)
=>
{
let
codemap
=
codemap
.unwrap_or_else
(
||
Lrc
::
new
(
codemap
::
Cod
eMap
::
new
(
sessopts
.file_path_mapping
())));
||
Lrc
::
new
(
codemap
::
Sourc
eMap
::
new
(
sessopts
.file_path_mapping
())));
Box
::
new
(
JsonEmitter
::
stderr
(
None
,
...
...
@@ -387,7 +387,7 @@ pub fn run_core(search_paths: SearchPaths,
..
Options
::
default
()
};
driver
::
spawn_thread_pool
(
sessopts
,
move
|
sessopts
|
{
let
codemap
=
Lrc
::
new
(
codemap
::
Cod
eMap
::
new
(
sessopts
.file_path_mapping
()));
let
codemap
=
Lrc
::
new
(
codemap
::
Sourc
eMap
::
new
(
sessopts
.file_path_mapping
()));
let
diagnostic_handler
=
new_handler
(
error_format
,
Some
(
codemap
.clone
()));
let
mut
sess
=
session
::
build_session_
(
...
...
src/librustdoc/html/highlight.rs
浏览文件 @
c6554733
...
...
@@ -21,7 +21,7 @@
use
std
::
io
;
use
std
::
io
::
prelude
::
*
;
use
syntax
::
codemap
::{
Cod
eMap
,
FilePathMapping
};
use
syntax
::
codemap
::{
Sourc
eMap
,
FilePathMapping
};
use
syntax
::
parse
::
lexer
::{
self
,
TokenAndSpan
};
use
syntax
::
parse
::
token
;
use
syntax
::
parse
;
...
...
@@ -60,7 +60,7 @@ pub fn render_with_highlighting(src: &str, class: Option<&str>,
/// each span of text in sequence.
struct
Classifier
<
'a
>
{
lexer
:
lexer
::
StringReader
<
'a
>
,
codemap
:
&
'a
Cod
eMap
,
codemap
:
&
'a
Sourc
eMap
,
// State of the classifier.
in_attribute
:
bool
,
...
...
@@ -145,7 +145,7 @@ fn exit_span(&mut self) -> io::Result<()> {
}
impl
<
'a
>
Classifier
<
'a
>
{
fn
new
(
lexer
:
lexer
::
StringReader
<
'a
>
,
codemap
:
&
'a
Cod
eMap
)
->
Classifier
<
'a
>
{
fn
new
(
lexer
:
lexer
::
StringReader
<
'a
>
,
codemap
:
&
'a
Sourc
eMap
)
->
Classifier
<
'a
>
{
Classifier
{
lexer
,
codemap
,
...
...
src/librustdoc/test.rs
浏览文件 @
c6554733
...
...
@@ -33,7 +33,7 @@
use
rustc_metadata
::
cstore
::
CStore
;
use
rustc_resolve
::
MakeGlobMap
;
use
syntax
::
ast
;
use
syntax
::
codemap
::
Cod
eMap
;
use
syntax
::
codemap
::
Sourc
eMap
;
use
syntax
::
edition
::
Edition
;
use
syntax
::
feature_gate
::
UnstableFeatures
;
use
syntax
::
with_globals
;
...
...
@@ -86,7 +86,7 @@ pub fn run(input_path: &Path,
..
config
::
Options
::
default
()
};
driver
::
spawn_thread_pool
(
sessopts
,
|
sessopts
|
{
let
codemap
=
Lrc
::
new
(
Cod
eMap
::
new
(
sessopts
.file_path_mapping
()));
let
codemap
=
Lrc
::
new
(
Sourc
eMap
::
new
(
sessopts
.file_path_mapping
()));
let
handler
=
errors
::
Handler
::
with_tty_emitter
(
ColorConfig
::
Auto
,
true
,
false
,
...
...
@@ -205,7 +205,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
// never wrap the test in `fn main() { ... }`
let
(
test
,
line_offset
)
=
make_test
(
test
,
Some
(
cratename
),
as_test_harness
,
opts
);
// FIXME(#44940): if doctests ever support path remapping, then this filename
// needs to be the result of
Cod
eMap::span_to_unmapped_path
// needs to be the result of
Sourc
eMap::span_to_unmapped_path
let
input
=
config
::
Input
::
Str
{
name
:
filename
.to_owned
(),
input
:
test
.to_owned
(),
...
...
@@ -262,7 +262,7 @@ fn drop(&mut self) {
let
_
bomb
=
Bomb
(
data
.clone
(),
old
.unwrap_or
(
box
io
::
stdout
()));
let
(
libdir
,
outdir
,
compile_result
)
=
driver
::
spawn_thread_pool
(
sessopts
,
|
sessopts
|
{
let
codemap
=
Lrc
::
new
(
Cod
eMap
::
new_doctest
(
let
codemap
=
Lrc
::
new
(
Sourc
eMap
::
new_doctest
(
sessopts
.file_path_mapping
(),
filename
.clone
(),
line
as
isize
-
line_offset
as
isize
));
let
emitter
=
errors
::
emitter
::
EmitterWriter
::
new
(
box
Sink
(
data
.clone
()),
...
...
@@ -500,7 +500,7 @@ pub struct Collector {
opts
:
TestOptions
,
maybe_sysroot
:
Option
<
PathBuf
>
,
position
:
Span
,
codemap
:
Option
<
Lrc
<
Cod
eMap
>>
,
codemap
:
Option
<
Lrc
<
Sourc
eMap
>>
,
filename
:
Option
<
PathBuf
>
,
linker
:
Option
<
PathBuf
>
,
edition
:
Edition
,
...
...
@@ -509,7 +509,7 @@ pub struct Collector {
impl
Collector
{
pub
fn
new
(
cratename
:
String
,
cfgs
:
Vec
<
String
>
,
libs
:
SearchPaths
,
cg
:
CodegenOptions
,
externs
:
Externs
,
use_headers
:
bool
,
opts
:
TestOptions
,
maybe_sysroot
:
Option
<
PathBuf
>
,
codemap
:
Option
<
Lrc
<
Cod
eMap
>>
,
maybe_sysroot
:
Option
<
PathBuf
>
,
codemap
:
Option
<
Lrc
<
Sourc
eMap
>>
,
filename
:
Option
<
PathBuf
>
,
linker
:
Option
<
PathBuf
>
,
edition
:
Edition
)
->
Collector
{
Collector
{
tests
:
Vec
::
new
(),
...
...
src/libsyntax/codemap.rs
浏览文件 @
c6554733
...
...
@@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! The
Cod
eMap tracks all the source code used within a single crate, mapping
//! The
Sourc
eMap tracks all the source code used within a single crate, mapping
//! from integer byte positions to the original source code location. Each bit
//! of source parsed during crate parsing (typically files, in-memory strings,
//! or various bits of macro expansion) cover a continuous range of bytes in the
//!
Cod
eMap and are represented by FileMaps. Byte positions are stored in
//!
Sourc
eMap and are represented by FileMaps. Byte positions are stored in
//! `spans` and used pervasively in the compiler. They are absolute positions
//! within the
Cod
eMap, which upon request can be converted to line and column
//! within the
Sourc
eMap, which upon request can be converted to line and column
//! information, source code snippets, etc.
...
...
@@ -32,7 +32,7 @@
use
std
::
env
;
use
std
::
fs
;
use
std
::
io
::{
self
,
Read
};
use
errors
::
Cod
eMapper
;
use
errors
::
Sourc
eMapper
;
/// Return the span itself if it doesn't come from a macro expansion,
/// otherwise return the call site span up to the `enclosing_sp` by
...
...
@@ -121,29 +121,29 @@ pub fn new(filemap: &FileMap) -> StableFilemapId {
}
// _____________________________________________________________________________
//
Cod
eMap
//
Sourc
eMap
//
pub
(
super
)
struct
Cod
eMapFiles
{
pub
(
super
)
struct
Sourc
eMapFiles
{
pub
(
super
)
file_maps
:
Vec
<
Lrc
<
FileMap
>>
,
stable_id_to_filemap
:
FxHashMap
<
StableFilemapId
,
Lrc
<
FileMap
>>
}
pub
struct
Cod
eMap
{
pub
(
super
)
files
:
Lock
<
Cod
eMapFiles
>
,
pub
struct
Sourc
eMap
{
pub
(
super
)
files
:
Lock
<
Sourc
eMapFiles
>
,
file_loader
:
Box
<
dyn
FileLoader
+
Sync
+
Send
>
,
// This is used to apply the file path remapping as specified via
// --remap-path-prefix to all FileMaps allocated within this
Cod
eMap.
// --remap-path-prefix to all FileMaps allocated within this
Sourc
eMap.
path_mapping
:
FilePathMapping
,
/// In case we are in a doctest, replace all file names with the PathBuf,
/// and add the given offsets to the line info
doctest_offset
:
Option
<
(
FileName
,
isize
)
>
,
}
impl
Cod
eMap
{
pub
fn
new
(
path_mapping
:
FilePathMapping
)
->
Cod
eMap
{
Cod
eMap
{
files
:
Lock
::
new
(
Cod
eMapFiles
{
impl
Sourc
eMap
{
pub
fn
new
(
path_mapping
:
FilePathMapping
)
->
Sourc
eMap
{
Sourc
eMap
{
files
:
Lock
::
new
(
Sourc
eMapFiles
{
file_maps
:
Vec
::
new
(),
stable_id_to_filemap
:
FxHashMap
(),
}),
...
...
@@ -154,19 +154,19 @@ pub fn new(path_mapping: FilePathMapping) -> CodeMap {
}
pub
fn
new_doctest
(
path_mapping
:
FilePathMapping
,
file
:
FileName
,
line
:
isize
)
->
Cod
eMap
{
Cod
eMap
{
file
:
FileName
,
line
:
isize
)
->
Sourc
eMap
{
Sourc
eMap
{
doctest_offset
:
Some
((
file
,
line
)),
..
Cod
eMap
::
new
(
path_mapping
)
..
Sourc
eMap
::
new
(
path_mapping
)
}
}
pub
fn
with_file_loader
(
file_loader
:
Box
<
dyn
FileLoader
+
Sync
+
Send
>
,
path_mapping
:
FilePathMapping
)
->
Cod
eMap
{
Cod
eMap
{
files
:
Lock
::
new
(
Cod
eMapFiles
{
->
Sourc
eMap
{
Sourc
eMap
{
files
:
Lock
::
new
(
Sourc
eMapFiles
{
file_maps
:
Vec
::
new
(),
stable_id_to_filemap
:
FxHashMap
(),
}),
...
...
@@ -463,7 +463,7 @@ pub fn span_to_filename(&self, sp: Span) -> FileName {
pub
fn
span_to_unmapped_path
(
&
self
,
sp
:
Span
)
->
FileName
{
self
.lookup_char_pos
(
sp
.lo
())
.file.unmapped_path
.clone
()
.expect
(
"
Cod
eMap::span_to_unmapped_path called for imported FileMap?"
)
.expect
(
"
Sourc
eMap::span_to_unmapped_path called for imported FileMap?"
)
}
pub
fn
is_multiline
(
&
self
,
sp
:
Span
)
->
bool
{
...
...
@@ -941,7 +941,7 @@ pub fn generate_local_type_param_snippet(&self, span: Span) -> Option<(Span, Str
}
}
impl
CodeMapper
for
Cod
eMap
{
impl
SourceMapper
for
Sourc
eMap
{
fn
lookup_char_pos
(
&
self
,
pos
:
BytePos
)
->
Loc
{
self
.lookup_char_pos
(
pos
)
}
...
...
@@ -1023,8 +1023,8 @@ mod tests {
use
super
::
*
;
use
rustc_data_structures
::
sync
::
Lrc
;
fn
init_code_map
()
->
Cod
eMap
{
let
cm
=
Cod
eMap
::
new
(
FilePathMapping
::
empty
());
fn
init_code_map
()
->
Sourc
eMap
{
let
cm
=
Sourc
eMap
::
new
(
FilePathMapping
::
empty
());
cm
.new_filemap
(
PathBuf
::
from
(
"blork.rs"
)
.into
(),
"first line.
\n
second line"
.to_string
());
cm
.new_filemap
(
PathBuf
::
from
(
"empty.rs"
)
.into
(),
...
...
@@ -1080,8 +1080,8 @@ fn t5() {
assert_eq!
(
loc2
.col
,
CharPos
(
0
));
}
fn
init_code_map_mbc
()
->
Cod
eMap
{
let
cm
=
Cod
eMap
::
new
(
FilePathMapping
::
empty
());
fn
init_code_map_mbc
()
->
Sourc
eMap
{
let
cm
=
Sourc
eMap
::
new
(
FilePathMapping
::
empty
());
// € is a three byte utf8 char.
cm
.new_filemap
(
PathBuf
::
from
(
"blork.rs"
)
.into
(),
"fir€st €€€€ line.
\n
second line"
.to_string
());
...
...
@@ -1135,7 +1135,7 @@ fn span_from_selection(input: &str, selection: &str) -> Span {
/// lines in the middle of a file.
#[test]
fn
span_to_snippet_and_lines_spanning_multiple_lines
()
{
let
cm
=
Cod
eMap
::
new
(
FilePathMapping
::
empty
());
let
cm
=
Sourc
eMap
::
new
(
FilePathMapping
::
empty
());
let
inputtext
=
"aaaaa
\n
bbbbBB
\n
CCC
\n
DDDDDddddd
\n
eee
\n
"
;
let
selection
=
"
\n
~~
\n
~~~
\n
~~~~~
\n
\n
"
;
cm
.new_filemap
(
Path
::
new
(
"blork.rs"
)
.to_owned
()
.into
(),
inputtext
.to_string
());
...
...
@@ -1177,7 +1177,7 @@ fn t9() {
/// Test failing to merge two spans on different lines
#[test]
fn
span_merging_fail
()
{
let
cm
=
Cod
eMap
::
new
(
FilePathMapping
::
empty
());
let
cm
=
Sourc
eMap
::
new
(
FilePathMapping
::
empty
());
let
inputtext
=
"bbbb BB
\n
cc CCC
\n
"
;
let
selection1
=
" ~~
\n
\n
"
;
let
selection2
=
"
\n
~~~
\n
"
;
...
...
@@ -1190,7 +1190,7 @@ fn span_merging_fail() {
/// Returns the span corresponding to the `n`th occurrence of
/// `substring` in `source_text`.
trait
Cod
eMapExtension
{
trait
Sourc
eMapExtension
{
fn
span_substr
(
&
self
,
file
:
&
Lrc
<
FileMap
>
,
source_text
:
&
str
,
...
...
@@ -1199,7 +1199,7 @@ fn span_substr(&self,
->
Span
;
}
impl
CodeMapExtension
for
Cod
eMap
{
impl
SourceMapExtension
for
Sourc
eMap
{
fn
span_substr
(
&
self
,
file
:
&
Lrc
<
FileMap
>
,
source_text
:
&
str
,
...
...
src/libsyntax/ext/base.rs
浏览文件 @
c6554733
...
...
@@ -12,7 +12,7 @@
use
ast
::{
self
,
Attribute
,
Name
,
PatKind
,
MetaItem
};
use
attr
::
HasAttrs
;
use
codemap
::{
self
,
Cod
eMap
,
Spanned
,
respan
};
use
codemap
::{
self
,
Sourc
eMap
,
Spanned
,
respan
};
use
syntax_pos
::{
Span
,
MultiSpan
,
DUMMY_SP
};
use
edition
::
Edition
;
use
errors
::{
DiagnosticBuilder
,
DiagnosticId
};
...
...
@@ -836,7 +836,7 @@ pub fn monotonic_expander<'b>(&'b mut self) -> expand::MacroExpander<'b, 'a> {
pub
fn
new_parser_from_tts
(
&
self
,
tts
:
&
[
tokenstream
::
TokenTree
])
->
parser
::
Parser
<
'a
>
{
parse
::
stream_to_parser
(
self
.parse_sess
,
tts
.iter
()
.cloned
()
.collect
())
}
pub
fn
codemap
(
&
self
)
->
&
'a
Cod
eMap
{
self
.parse_sess
.codemap
()
}
pub
fn
codemap
(
&
self
)
->
&
'a
Sourc
eMap
{
self
.parse_sess
.codemap
()
}
pub
fn
parse_sess
(
&
self
)
->
&
'a
parse
::
ParseSess
{
self
.parse_sess
}
pub
fn
cfg
(
&
self
)
->
&
ast
::
CrateConfig
{
&
self
.parse_sess.config
}
pub
fn
call_site
(
&
self
)
->
Span
{
...
...
src/libsyntax/json.rs
浏览文件 @
c6554733
...
...
@@ -19,10 +19,10 @@
// FIXME spec the JSON output properly.
use
codemap
::{
Cod
eMap
,
FilePathMapping
};
use
codemap
::{
Sourc
eMap
,
FilePathMapping
};
use
syntax_pos
::{
self
,
MacroBacktrace
,
Span
,
SpanLabel
,
MultiSpan
};
use
errors
::
registry
::
Registry
;
use
errors
::{
DiagnosticBuilder
,
SubDiagnostic
,
CodeSuggestion
,
Cod
eMapper
};
use
errors
::{
DiagnosticBuilder
,
SubDiagnostic
,
CodeSuggestion
,
Sourc
eMapper
};
use
errors
::{
DiagnosticId
,
Applicability
};
use
errors
::
emitter
::{
Emitter
,
EmitterWriter
};
...
...
@@ -36,14 +36,14 @@
pub
struct
JsonEmitter
{
dst
:
Box
<
dyn
Write
+
Send
>
,
registry
:
Option
<
Registry
>
,
cm
:
Lrc
<
dyn
Cod
eMapper
+
sync
::
Send
+
sync
::
Sync
>
,
cm
:
Lrc
<
dyn
Sourc
eMapper
+
sync
::
Send
+
sync
::
Sync
>
,
pretty
:
bool
,
ui_testing
:
bool
,
}
impl
JsonEmitter
{
pub
fn
stderr
(
registry
:
Option
<
Registry
>
,
code_map
:
Lrc
<
Cod
eMap
>
,
code_map
:
Lrc
<
Sourc
eMap
>
,
pretty
:
bool
)
->
JsonEmitter
{
JsonEmitter
{
dst
:
Box
::
new
(
io
::
stderr
()),
...
...
@@ -56,13 +56,13 @@ pub fn stderr(registry: Option<Registry>,
pub
fn
basic
(
pretty
:
bool
)
->
JsonEmitter
{
let
file_path_mapping
=
FilePathMapping
::
empty
();
JsonEmitter
::
stderr
(
None
,
Lrc
::
new
(
Cod
eMap
::
new
(
file_path_mapping
)),
JsonEmitter
::
stderr
(
None
,
Lrc
::
new
(
Sourc
eMap
::
new
(
file_path_mapping
)),
pretty
)
}
pub
fn
new
(
dst
:
Box
<
dyn
Write
+
Send
>
,
registry
:
Option
<
Registry
>
,
code_map
:
Lrc
<
Cod
eMap
>
,
code_map
:
Lrc
<
Sourc
eMap
>
,
pretty
:
bool
)
->
JsonEmitter
{
JsonEmitter
{
dst
,
...
...
src/libsyntax/parse/lexer/comments.rs
浏览文件 @
c6554733
...
...
@@ -11,7 +11,7 @@
pub
use
self
::
CommentStyle
::
*
;
use
ast
;
use
codemap
::
Cod
eMap
;
use
codemap
::
Sourc
eMap
;
use
syntax_pos
::{
BytePos
,
CharPos
,
Pos
,
FileName
};
use
parse
::
lexer
::{
is_block_doc_comment
,
is_pattern_whitespace
};
use
parse
::
lexer
::{
self
,
ParseSess
,
StringReader
,
TokenAndSpan
};
...
...
@@ -371,7 +371,7 @@ pub fn gather_comments_and_literals(sess: &ParseSess, path: FileName, srdr: &mut
{
let
mut
src
=
String
::
new
();
srdr
.read_to_string
(
&
mut
src
)
.unwrap
();
let
cm
=
Cod
eMap
::
new
(
sess
.codemap
()
.path_mapping
()
.clone
());
let
cm
=
Sourc
eMap
::
new
(
sess
.codemap
()
.path_mapping
()
.clone
());
let
filemap
=
cm
.new_filemap
(
path
,
src
);
let
mut
rdr
=
lexer
::
StringReader
::
new_raw
(
sess
,
filemap
,
None
);
...
...
src/libsyntax/parse/lexer/mod.rs
浏览文件 @
c6554733
...
...
@@ -10,7 +10,7 @@
use
ast
::{
self
,
Ident
};
use
syntax_pos
::{
self
,
BytePos
,
CharPos
,
Pos
,
Span
,
NO_EXPANSION
};
use
codemap
::{
Cod
eMap
,
FilePathMapping
};
use
codemap
::{
Sourc
eMap
,
FilePathMapping
};
use
errors
::{
Applicability
,
FatalError
,
DiagnosticBuilder
};
use
parse
::{
token
,
ParseSess
};
use
str
::
char_at
;
...
...
@@ -622,7 +622,7 @@ fn scan_comment(&mut self) -> Option<TokenAndSpan> {
// I guess this is the only way to figure out if
// we're at the beginning of the file...
let
cmap
=
Cod
eMap
::
new
(
FilePathMapping
::
empty
());
let
cmap
=
Sourc
eMap
::
new
(
FilePathMapping
::
empty
());
cmap
.files
.borrow_mut
()
.file_maps
.push
(
self
.filemap
.clone
());
let
loc
=
cmap
.lookup_char_pos_adj
(
self
.pos
);
debug!
(
"Skipping a shebang"
);
...
...
@@ -1827,7 +1827,7 @@ mod tests {
use
ast
::{
Ident
,
CrateConfig
};
use
symbol
::
Symbol
;
use
syntax_pos
::{
BytePos
,
Span
,
NO_EXPANSION
};
use
codemap
::
Cod
eMap
;
use
codemap
::
Sourc
eMap
;
use
errors
;
use
feature_gate
::
UnstableFeatures
;
use
parse
::
token
;
...
...
@@ -1837,7 +1837,7 @@ mod tests {
use
diagnostics
::
plugin
::
ErrorMap
;
use
rustc_data_structures
::
sync
::
Lock
;
use
with_globals
;
fn
mk_sess
(
cm
:
Lrc
<
Cod
eMap
>
)
->
ParseSess
{
fn
mk_sess
(
cm
:
Lrc
<
Sourc
eMap
>
)
->
ParseSess
{
let
emitter
=
errors
::
emitter
::
EmitterWriter
::
new
(
Box
::
new
(
io
::
sink
()),
Some
(
cm
.clone
()),
false
,
...
...
@@ -1857,7 +1857,7 @@ fn mk_sess(cm: Lrc<CodeMap>) -> ParseSess {
}
// open a string reader for the given string
fn
setup
<
'a
>
(
cm
:
&
Cod
eMap
,
fn
setup
<
'a
>
(
cm
:
&
Sourc
eMap
,
sess
:
&
'a
ParseSess
,
teststr
:
String
)
->
StringReader
<
'a
>
{
...
...
@@ -1868,7 +1868,7 @@ fn setup<'a>(cm: &CodeMap,
#[test]
fn
t1
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
let
mut
string_reader
=
setup
(
&
cm
,
&
sh
,
...
...
@@ -1916,7 +1916,7 @@ fn mk_ident(id: &str) -> token::Token {
#[test]
fn
doublecolonparsing
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
check_tokenization
(
setup
(
&
cm
,
&
sh
,
"a b"
.to_string
()),
vec!
[
mk_ident
(
"a"
),
token
::
Whitespace
,
mk_ident
(
"b"
)]);
...
...
@@ -1926,7 +1926,7 @@ fn doublecolonparsing() {
#[test]
fn
dcparsing_2
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
check_tokenization
(
setup
(
&
cm
,
&
sh
,
"a::b"
.to_string
()),
vec!
[
mk_ident
(
"a"
),
token
::
ModSep
,
mk_ident
(
"b"
)]);
...
...
@@ -1936,7 +1936,7 @@ fn dcparsing_2() {
#[test]
fn
dcparsing_3
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
check_tokenization
(
setup
(
&
cm
,
&
sh
,
"a ::b"
.to_string
()),
vec!
[
mk_ident
(
"a"
),
token
::
Whitespace
,
token
::
ModSep
,
mk_ident
(
"b"
)]);
...
...
@@ -1946,7 +1946,7 @@ fn dcparsing_3() {
#[test]
fn
dcparsing_4
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
check_tokenization
(
setup
(
&
cm
,
&
sh
,
"a:: b"
.to_string
()),
vec!
[
mk_ident
(
"a"
),
token
::
ModSep
,
token
::
Whitespace
,
mk_ident
(
"b"
)]);
...
...
@@ -1956,7 +1956,7 @@ fn dcparsing_4() {
#[test]
fn
character_a
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
assert_eq!
(
setup
(
&
cm
,
&
sh
,
"'a'"
.to_string
())
.next_token
()
.tok
,
token
::
Literal
(
token
::
Char
(
Symbol
::
intern
(
"a"
)),
None
));
...
...
@@ -1966,7 +1966,7 @@ fn character_a() {
#[test]
fn
character_space
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
assert_eq!
(
setup
(
&
cm
,
&
sh
,
"' '"
.to_string
())
.next_token
()
.tok
,
token
::
Literal
(
token
::
Char
(
Symbol
::
intern
(
" "
)),
None
));
...
...
@@ -1976,7 +1976,7 @@ fn character_space() {
#[test]
fn
character_escaped
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
assert_eq!
(
setup
(
&
cm
,
&
sh
,
"'
\\
n'"
.to_string
())
.next_token
()
.tok
,
token
::
Literal
(
token
::
Char
(
Symbol
::
intern
(
"
\\
n"
)),
None
));
...
...
@@ -1986,7 +1986,7 @@ fn character_escaped() {
#[test]
fn
lifetime_name
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
assert_eq!
(
setup
(
&
cm
,
&
sh
,
"'abc"
.to_string
())
.next_token
()
.tok
,
token
::
Lifetime
(
Ident
::
from_str
(
"'abc"
)));
...
...
@@ -1996,7 +1996,7 @@ fn lifetime_name() {
#[test]
fn
raw_string
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
assert_eq!
(
setup
(
&
cm
,
&
sh
,
"r###
\"\"
#a
\\
b
\x00
c
\"\"
###"
.to_string
())
.next_token
()
...
...
@@ -2008,7 +2008,7 @@ fn raw_string() {
#[test]
fn
literal_suffixes
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
macro_rules!
test
{
(
$input
:
expr
,
$tok_type
:
ident
,
$tok_contents
:
expr
)
=>
{{
...
...
@@ -2054,7 +2054,7 @@ fn line_doc_comments() {
#[test]
fn
nested_block_comments
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
let
mut
lexer
=
setup
(
&
cm
,
&
sh
,
"/* /* */ */'a'"
.to_string
());
match
lexer
.next_token
()
.tok
{
...
...
@@ -2069,7 +2069,7 @@ fn nested_block_comments() {
#[test]
fn
crlf_comments
()
{
with_globals
(||
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
let
sh
=
mk_sess
(
cm
.clone
());
let
mut
lexer
=
setup
(
&
cm
,
&
sh
,
"// test
\r\n
/// test
\r\n
"
.to_string
());
let
comment
=
lexer
.next_token
();
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
c6554733
...
...
@@ -13,7 +13,7 @@
use
rustc_data_structures
::
sync
::{
Lrc
,
Lock
};
use
ast
::{
self
,
CrateConfig
,
NodeId
};
use
early_buffered_lints
::{
BufferedEarlyLint
,
BufferedEarlyLintId
};
use
codemap
::{
Cod
eMap
,
FilePathMapping
};
use
codemap
::{
Sourc
eMap
,
FilePathMapping
};
use
syntax_pos
::{
Span
,
FileMap
,
FileName
,
MultiSpan
};
use
errors
::{
Handler
,
ColorConfig
,
DiagnosticBuilder
};
use
feature_gate
::
UnstableFeatures
;
...
...
@@ -57,13 +57,13 @@ pub struct ParseSess {
pub
non_modrs_mods
:
Lock
<
Vec
<
(
ast
::
Ident
,
Span
)
>>
,
/// Used to determine and report recursive mod inclusions
included_mod_stack
:
Lock
<
Vec
<
PathBuf
>>
,
code_map
:
Lrc
<
Cod
eMap
>
,
code_map
:
Lrc
<
Sourc
eMap
>
,
pub
buffered_lints
:
Lock
<
Vec
<
BufferedEarlyLint
>>
,
}
impl
ParseSess
{
pub
fn
new
(
file_path_mapping
:
FilePathMapping
)
->
Self
{
let
cm
=
Lrc
::
new
(
Cod
eMap
::
new
(
file_path_mapping
));
let
cm
=
Lrc
::
new
(
Sourc
eMap
::
new
(
file_path_mapping
));
let
handler
=
Handler
::
with_tty_emitter
(
ColorConfig
::
Auto
,
true
,
false
,
...
...
@@ -71,7 +71,7 @@ pub fn new(file_path_mapping: FilePathMapping) -> Self {
ParseSess
::
with_span_handler
(
handler
,
cm
)
}
pub
fn
with_span_handler
(
handler
:
Handler
,
code_map
:
Lrc
<
Cod
eMap
>
)
->
ParseSess
{
pub
fn
with_span_handler
(
handler
:
Handler
,
code_map
:
Lrc
<
Sourc
eMap
>
)
->
ParseSess
{
ParseSess
{
span_diagnostic
:
handler
,
unstable_features
:
UnstableFeatures
::
from_environment
(),
...
...
@@ -86,7 +86,7 @@ pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess
}
}
pub
fn
codemap
(
&
self
)
->
&
Cod
eMap
{
pub
fn
codemap
(
&
self
)
->
&
Sourc
eMap
{
&
self
.code_map
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
c6554733
...
...
@@ -42,7 +42,7 @@
use
ast
::{
BinOpKind
,
UnOp
};
use
ast
::{
RangeEnd
,
RangeSyntax
};
use
{
ast
,
attr
};
use
codemap
::{
self
,
Cod
eMap
,
Spanned
,
respan
};
use
codemap
::{
self
,
Sourc
eMap
,
Spanned
,
respan
};
use
syntax_pos
::{
self
,
Span
,
MultiSpan
,
BytePos
,
FileName
,
edition
::
Edition
};
use
errors
::{
self
,
Applicability
,
DiagnosticBuilder
,
DiagnosticId
};
use
parse
::{
self
,
SeqSep
,
classify
,
token
};
...
...
@@ -6322,7 +6322,7 @@ pub fn default_submod_path(
id
:
ast
::
Ident
,
relative
:
Option
<
ast
::
Ident
>
,
dir_path
:
&
Path
,
codemap
:
&
Cod
eMap
)
->
ModulePath
codemap
:
&
Sourc
eMap
)
->
ModulePath
{
// If we're in a foo.rs file instead of a mod.rs file,
// we need to look for submodules in
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
c6554733
...
...
@@ -16,7 +16,7 @@
use
ast
::{
Attribute
,
MacDelimiter
,
GenericArg
};
use
util
::
parser
::{
self
,
AssocOp
,
Fixity
};
use
attr
;
use
codemap
::{
self
,
Cod
eMap
,
Spanned
};
use
codemap
::{
self
,
Sourc
eMap
,
Spanned
};
use
syntax_pos
::{
self
,
BytePos
};
use
syntax_pos
::
hygiene
::{
Mark
,
SyntaxContext
};
use
parse
::
token
::{
self
,
BinOpToken
,
Token
};
...
...
@@ -57,7 +57,7 @@ impl PpAnn for NoAnn {}
pub
struct
State
<
'a
>
{
pub
s
:
pp
::
Printer
<
'a
>
,
cm
:
Option
<&
'a
Cod
eMap
>
,
cm
:
Option
<&
'a
Sourc
eMap
>
,
comments
:
Option
<
Vec
<
comments
::
Comment
>
>
,
literals
:
Peekable
<
vec
::
IntoIter
<
comments
::
Literal
>>
,
cur_cmnt
:
usize
,
...
...
@@ -84,7 +84,7 @@ fn rust_printer<'a>(writer: Box<dyn Write+'a>, ann: &'a dyn PpAnn) -> State<'a>
/// Requires you to pass an input filename and reader so that
/// it can scan the input text for comments and literals to
/// copy forward.
pub
fn
print_crate
<
'a
>
(
cm
:
&
'a
Cod
eMap
,
pub
fn
print_crate
<
'a
>
(
cm
:
&
'a
Sourc
eMap
,
sess
:
&
ParseSess
,
krate
:
&
ast
::
Crate
,
filename
:
FileName
,
...
...
@@ -118,7 +118,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
}
impl
<
'a
>
State
<
'a
>
{
pub
fn
new_from_input
(
cm
:
&
'a
Cod
eMap
,
pub
fn
new_from_input
(
cm
:
&
'a
Sourc
eMap
,
sess
:
&
ParseSess
,
filename
:
FileName
,
input
:
&
mut
dyn
Read
,
...
...
@@ -138,7 +138,7 @@ pub fn new_from_input(cm: &'a CodeMap,
if
is_expanded
{
None
}
else
{
Some
(
lits
)
})
}
pub
fn
new
(
cm
:
&
'a
Cod
eMap
,
pub
fn
new
(
cm
:
&
'a
Sourc
eMap
,
out
:
Box
<
dyn
Write
+
'a
>
,
ann
:
&
'a
dyn
PpAnn
,
comments
:
Option
<
Vec
<
comments
::
Comment
>>
,
...
...
src/libsyntax/test.rs
浏览文件 @
c6554733
...
...
@@ -22,7 +22,7 @@
use
attr
::{
self
,
HasAttrs
};
use
syntax_pos
::{
self
,
DUMMY_SP
,
NO_EXPANSION
,
Span
,
FileMap
,
BytePos
};
use
codemap
::{
self
,
Cod
eMap
,
ExpnInfo
,
MacroAttribute
,
dummy_spanned
};
use
codemap
::{
self
,
Sourc
eMap
,
ExpnInfo
,
MacroAttribute
,
dummy_spanned
};
use
errors
;
use
config
;
use
entry
::{
self
,
EntryPointType
};
...
...
src/libsyntax/test_snippet.rs
浏览文件 @
c6554733
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
codemap
::{
Cod
eMap
,
FilePathMapping
};
use
codemap
::{
Sourc
eMap
,
FilePathMapping
};
use
errors
::
Handler
;
use
errors
::
emitter
::
EmitterWriter
;
use
std
::
io
;
...
...
@@ -50,7 +50,7 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &
with_globals
(||
{
let
output
=
Arc
::
new
(
Mutex
::
new
(
Vec
::
new
()));
let
code_map
=
Lrc
::
new
(
Cod
eMap
::
new
(
FilePathMapping
::
empty
()));
let
code_map
=
Lrc
::
new
(
Sourc
eMap
::
new
(
FilePathMapping
::
empty
()));
code_map
.new_filemap
(
Path
::
new
(
"test.rs"
)
.to_owned
()
.into
(),
file_text
.to_owned
());
let
primary_span
=
make_span
(
&
file_text
,
&
span_labels
[
0
]
.start
,
&
span_labels
[
0
]
.end
);
...
...
src/libsyntax_pos/lib.rs
浏览文件 @
c6554733
...
...
@@ -163,7 +163,7 @@ pub fn is_macros(&self) -> bool {
/// Spans represent a region of code, used for error reporting. Positions in spans
/// are *absolute* positions from the beginning of the codemap, not positions
/// relative to FileMaps. Methods on the
Cod
eMap can be used to relate spans back
/// relative to FileMaps. Methods on the
Sourc
eMap can be used to relate spans back
/// to the original source.
/// You must be careful if the span crosses more than one file - you will not be
/// able to use many of the functions on spans in codemap and you cannot assume
...
...
@@ -678,7 +678,7 @@ fn from(spans: Vec<Span>) -> MultiSpan {
/// Identifies an offset of a multi-byte character in a FileMap
#[derive(Copy,
Clone,
RustcEncodable,
RustcDecodable,
Eq,
PartialEq,
Debug)]
pub
struct
MultiByteChar
{
/// The absolute offset of the character in the
Cod
eMap
/// The absolute offset of the character in the
Sourc
eMap
pub
pos
:
BytePos
,
/// The number of bytes, >=2
pub
bytes
:
u8
,
...
...
@@ -705,7 +705,7 @@ fn new(pos: BytePos, width: usize) -> Self {
}
}
/// Returns the absolute offset of the character in the
Cod
eMap
/// Returns the absolute offset of the character in the
Sourc
eMap
pub
fn
pos
(
&
self
)
->
BytePos
{
match
*
self
{
NonNarrowChar
::
ZeroWidth
(
p
)
|
...
...
@@ -777,7 +777,7 @@ pub fn get_source(&self) -> Option<&str> {
}
}
/// A single source in the
Cod
eMap.
/// A single source in the
Sourc
eMap.
#[derive(Clone)]
pub
struct
FileMap
{
/// The name of the file that the source came from, source that doesn't
...
...
@@ -798,9 +798,9 @@ pub struct FileMap {
/// The external source code (used for external crates, which will have a `None`
/// value as `self.src`.
pub
external_src
:
Lock
<
ExternalSource
>
,
/// The start position of this source in the
Cod
eMap
/// The start position of this source in the
Sourc
eMap
pub
start_pos
:
BytePos
,
/// The end position of this source in the
Cod
eMap
/// The end position of this source in the
Sourc
eMap
pub
end_pos
:
BytePos
,
/// Locations of lines beginnings in the source code
pub
lines
:
Vec
<
BytePos
>
,
...
...
@@ -1141,7 +1141,7 @@ pub trait Pos {
pub
struct
BytePos
(
pub
u32
);
/// A character offset. Because of multibyte utf8 characters, a byte offset
/// is not equivalent to a character offset. The
Cod
eMap will convert BytePos
/// is not equivalent to a character offset. The
Sourc
eMap will convert BytePos
/// values to CharPos values as necessary.
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Debug)]
pub
struct
CharPos
(
pub
usize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录