mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichton
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
This commit is contained in:
commit
d3ae56d755
44
mk/crates.mk
44
mk/crates.mk
@ -57,10 +57,10 @@ TARGET_CRATES := libc std term \
|
||||
panic_abort panic_unwind unwind
|
||||
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
|
||||
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
|
||||
rustc_data_structures rustc_platform_intrinsics \
|
||||
rustc_data_structures rustc_platform_intrinsics rustc_errors \
|
||||
rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
|
||||
rustc_const_eval rustc_const_math rustc_incremental
|
||||
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
|
||||
HOST_CRATES := syntax syntax_ext syntax_pos $(RUSTC_CRATES) rustdoc fmt_macros \
|
||||
flate arena graphviz rbml log serialize
|
||||
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
|
||||
|
||||
@ -98,43 +98,45 @@ DEPS_serialize := std log
|
||||
DEPS_term := std
|
||||
DEPS_test := std getopts term native:rust_test_helpers
|
||||
|
||||
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
|
||||
DEPS_syntax_ext := syntax fmt_macros
|
||||
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode rustc_errors syntax_pos
|
||||
DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros
|
||||
DEPS_syntax_pos := serialize
|
||||
|
||||
DEPS_rustc_const_math := std syntax log serialize
|
||||
DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
|
||||
rustc_back graphviz
|
||||
rustc_back graphviz syntax_pos
|
||||
|
||||
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml \
|
||||
log graphviz rustc_llvm rustc_back rustc_data_structures\
|
||||
rustc_const_math
|
||||
rustc_const_math syntax_pos rustc_errors
|
||||
DEPS_rustc_back := std syntax flate log libc
|
||||
DEPS_rustc_borrowck := rustc log graphviz syntax rustc_mir
|
||||
DEPS_rustc_borrowck := rustc log graphviz syntax syntax_pos rustc_errors rustc_mir
|
||||
DEPS_rustc_data_structures := std log serialize
|
||||
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
|
||||
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
|
||||
rustc_trans rustc_privacy rustc_lint rustc_plugin \
|
||||
rustc_metadata syntax_ext rustc_passes rustc_save_analysis rustc_const_eval \
|
||||
rustc_incremental
|
||||
DEPS_rustc_lint := rustc log syntax rustc_const_eval
|
||||
rustc_incremental syntax_pos rustc_errors
|
||||
DEPS_rustc_errors := log libc serialize syntax_pos
|
||||
DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
|
||||
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
|
||||
DEPS_rustc_metadata := rustc syntax rbml rustc_const_math
|
||||
DEPS_rustc_passes := syntax rustc core rustc_const_eval
|
||||
DEPS_rustc_mir := rustc syntax rustc_const_math rustc_const_eval rustc_bitflags
|
||||
DEPS_rustc_resolve := arena rustc log syntax
|
||||
DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rbml rustc_const_math
|
||||
DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors
|
||||
DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags
|
||||
DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors
|
||||
DEPS_rustc_platform_intrinsics := std
|
||||
DEPS_rustc_plugin := rustc rustc_metadata syntax
|
||||
DEPS_rustc_privacy := rustc log syntax
|
||||
DEPS_rustc_plugin := rustc rustc_metadata syntax syntax_pos rustc_errors
|
||||
DEPS_rustc_privacy := rustc log syntax syntax_pos
|
||||
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
|
||||
log syntax serialize rustc_llvm rustc_platform_intrinsics \
|
||||
rustc_const_math rustc_const_eval rustc_incremental
|
||||
DEPS_rustc_incremental := rbml rustc serialize rustc_data_structures
|
||||
DEPS_rustc_save_analysis := rustc log syntax serialize
|
||||
DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
|
||||
rustc_const_eval
|
||||
rustc_const_math rustc_const_eval rustc_incremental rustc_errors syntax_pos
|
||||
DEPS_rustc_incremental := rbml rustc syntax_pos serialize rustc_data_structures
|
||||
DEPS_rustc_save_analysis := rustc log syntax syntax_pos serialize
|
||||
DEPS_rustc_typeck := rustc syntax syntax_pos rustc_platform_intrinsics rustc_const_math \
|
||||
rustc_const_eval rustc_errors
|
||||
|
||||
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
|
||||
test rustc_lint rustc_const_eval
|
||||
test rustc_lint rustc_const_eval syntax_pos
|
||||
|
||||
|
||||
TOOL_DEPS_compiletest := test getopts log serialize
|
||||
|
@ -45,11 +45,11 @@ extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::TokenTree;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use syntax_pos::Span;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
|
@ -32,9 +32,9 @@ use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::ast::Name;
|
||||
use syntax::codemap;
|
||||
use syntax::codemap::Pos;
|
||||
use syntax::parse::token::{self, BinOpToken, DelimToken, Lit, Token};
|
||||
use syntax::parse::lexer::TokenAndSpan;
|
||||
use syntax_pos::Pos;
|
||||
|
||||
fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
|
||||
fn id() -> token::Token {
|
||||
@ -233,10 +233,10 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>, surrogate_
|
||||
lo -= surrogate_pairs_pos.binary_search(&(lo as usize)).unwrap_or_else(|x| x) as u32;
|
||||
hi -= surrogate_pairs_pos.binary_search(&(hi as usize)).unwrap_or_else(|x| x) as u32;
|
||||
|
||||
let sp = codemap::Span {
|
||||
lo: codemap::BytePos(lo),
|
||||
hi: codemap::BytePos(hi),
|
||||
expn_id: codemap::NO_EXPANSION
|
||||
let sp = syntax_pos::Span {
|
||||
lo: syntax_pos::BytePos(lo),
|
||||
hi: syntax_pos::BytePos(hi),
|
||||
expn_id: syntax_pos::NO_EXPANSION
|
||||
};
|
||||
|
||||
TokenAndSpan {
|
||||
|
@ -19,6 +19,8 @@ rustc_back = { path = "../librustc_back" }
|
||||
rustc_bitflags = { path = "../librustc_bitflags" }
|
||||
rustc_const_math = { path = "../librustc_const_math" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_llvm = { path = "../librustc_llvm" }
|
||||
serialize = { path = "../libserialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path "../libsyntax_pos" }
|
@ -16,7 +16,8 @@ use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, Attribute, Attribute_, MetaItem};
|
||||
use syntax::ast::MetaItemKind;
|
||||
use syntax::attr::ThinAttributesExt;
|
||||
use hir;
|
||||
use syntax::codemap::{respan, Span, Spanned};
|
||||
use syntax_pos::Span;
|
||||
use syntax::codemap::{respan, Spanned};
|
||||
use syntax::ptr::P;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::util::move_map::MoveMap;
|
||||
|
@ -28,7 +28,8 @@
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast::{NodeId, CRATE_NODE_ID, Name, Attribute};
|
||||
use syntax::attr::ThinAttributesExt;
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax_pos::Span;
|
||||
use hir::*;
|
||||
|
||||
use std::cmp;
|
||||
|
@ -52,10 +52,11 @@ use std::iter;
|
||||
use syntax::ast::*;
|
||||
use syntax::attr::{ThinAttributes, ThinAttributesExt};
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::{respan, Spanned, Span};
|
||||
use syntax::codemap::{respan, Spanned};
|
||||
use syntax::parse::token;
|
||||
use syntax::std_inject;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax_pos::Span;
|
||||
|
||||
pub struct LoweringContext<'a> {
|
||||
crate_root: Option<&'static str>,
|
||||
|
@ -29,7 +29,7 @@ use hir::{Block, FnDecl};
|
||||
use syntax::ast::{Attribute, Name, NodeId};
|
||||
use syntax::attr::ThinAttributesExt;
|
||||
use hir as ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::FnKind;
|
||||
|
||||
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
|
||||
|
@ -17,7 +17,7 @@ use hir::def_id::DefId;
|
||||
use middle::cstore::InlinedItem;
|
||||
use std::iter::repeat;
|
||||
use syntax::ast::{NodeId, CRATE_NODE_ID};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
/// A Visitor that walks over the HIR and collects Nodes into a HIR map
|
||||
pub struct NodeCollector<'ast> {
|
||||
|
@ -24,8 +24,9 @@ use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID, };
|
||||
use syntax::attr::ThinAttributesExt;
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax::visit;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir::*;
|
||||
use hir::fold::Folder;
|
||||
|
@ -36,7 +36,8 @@ use hir::def::Def;
|
||||
use hir::def_id::DefId;
|
||||
use util::nodemap::{NodeMap, FnvHashSet};
|
||||
|
||||
use syntax::codemap::{self, mk_sp, respan, Span, Spanned, ExpnId};
|
||||
use syntax_pos::{mk_sp, Span, ExpnId};
|
||||
use syntax::codemap::{self, respan, Spanned};
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
|
||||
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
|
||||
|
@ -14,7 +14,8 @@ use hir::{self, PatKind};
|
||||
use ty::TyCtxt;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{Span, Spanned, DUMMY_SP};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
use std::iter::{Enumerate, ExactSizeIterator};
|
||||
|
||||
|
@ -12,8 +12,7 @@ pub use self::AnnNode::*;
|
||||
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
|
||||
use syntax::errors;
|
||||
use syntax::codemap::{CodeMap, Spanned};
|
||||
use syntax::parse::token::{self, keywords, BinOpToken};
|
||||
use syntax::parse::lexer::comments;
|
||||
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
|
||||
@ -21,6 +20,8 @@ use syntax::print::pp::{Breaks, eof};
|
||||
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
|
||||
use syntax::print::pprust::{self as ast_pp, PrintState};
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{self, BytePos};
|
||||
use errors;
|
||||
|
||||
use hir;
|
||||
use hir::{Crate, PatKind, RegionTyParamBound, SelfKind, TraitTyParamBound, TraitBoundModifier};
|
||||
@ -368,11 +369,11 @@ impl<'a> State<'a> {
|
||||
self.end() // close the head-box
|
||||
}
|
||||
|
||||
pub fn bclose_(&mut self, span: codemap::Span, indented: usize) -> io::Result<()> {
|
||||
pub fn bclose_(&mut self, span: syntax_pos::Span, indented: usize) -> io::Result<()> {
|
||||
self.bclose_maybe_open(span, indented, true)
|
||||
}
|
||||
pub fn bclose_maybe_open(&mut self,
|
||||
span: codemap::Span,
|
||||
span: syntax_pos::Span,
|
||||
indented: usize,
|
||||
close_box: bool)
|
||||
-> io::Result<()> {
|
||||
@ -384,7 +385,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn bclose(&mut self, span: codemap::Span) -> io::Result<()> {
|
||||
pub fn bclose(&mut self, span: syntax_pos::Span) -> io::Result<()> {
|
||||
self.bclose_(span, indent_unit)
|
||||
}
|
||||
|
||||
@ -432,7 +433,7 @@ impl<'a> State<'a> {
|
||||
mut get_span: G)
|
||||
-> io::Result<()>
|
||||
where F: FnMut(&mut State, &T) -> io::Result<()>,
|
||||
G: FnMut(&T) -> codemap::Span
|
||||
G: FnMut(&T) -> syntax_pos::Span
|
||||
{
|
||||
self.rbox(0, b)?;
|
||||
let len = elts.len();
|
||||
@ -859,7 +860,7 @@ impl<'a> State<'a> {
|
||||
enum_definition: &hir::EnumDef,
|
||||
generics: &hir::Generics,
|
||||
name: ast::Name,
|
||||
span: codemap::Span,
|
||||
span: syntax_pos::Span,
|
||||
visibility: &hir::Visibility)
|
||||
-> io::Result<()> {
|
||||
self.head(&visibility_qualified(visibility, "enum"))?;
|
||||
@ -872,7 +873,7 @@ impl<'a> State<'a> {
|
||||
|
||||
pub fn print_variants(&mut self,
|
||||
variants: &[hir::Variant],
|
||||
span: codemap::Span)
|
||||
span: syntax_pos::Span)
|
||||
-> io::Result<()> {
|
||||
self.bopen()?;
|
||||
for v in variants {
|
||||
@ -902,7 +903,7 @@ impl<'a> State<'a> {
|
||||
struct_def: &hir::VariantData,
|
||||
generics: &hir::Generics,
|
||||
name: ast::Name,
|
||||
span: codemap::Span,
|
||||
span: syntax_pos::Span,
|
||||
print_finalizer: bool)
|
||||
-> io::Result<()> {
|
||||
self.print_name(name)?;
|
||||
@ -2237,7 +2238,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn maybe_print_trailing_comment(&mut self,
|
||||
span: codemap::Span,
|
||||
span: syntax_pos::Span,
|
||||
next_pos: Option<BytePos>)
|
||||
-> io::Result<()> {
|
||||
let cm = match self.cm {
|
||||
|
@ -49,7 +49,7 @@ use ty::relate::{RelateResult, TypeRelation};
|
||||
use traits::PredicateObligations;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CombineFields<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
|
@ -91,10 +91,10 @@ use std::cell::{Cell, RefCell};
|
||||
use std::char::from_u32;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::errors::{DiagnosticBuilder, check_old_skool};
|
||||
use syntax::codemap::{self, Pos, Span};
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{self, Pos, Span};
|
||||
use errors::{DiagnosticBuilder, check_old_skool};
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn note_and_explain_region(self,
|
||||
@ -1933,6 +1933,6 @@ impl LifeGiver {
|
||||
|
||||
fn name_to_dummy_lifetime(name: ast::Name) -> hir::Lifetime {
|
||||
hir::Lifetime { id: ast::DUMMY_NODE_ID,
|
||||
span: codemap::DUMMY_SP,
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
name: name }
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ use super::region_inference::{TaintDirections};
|
||||
use ty::{self, TyCtxt, Binder, TypeFoldable};
|
||||
use ty::error::TypeError;
|
||||
use ty::relate::{Relate, RelateResult, TypeRelation};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
|
||||
pub struct HrMatchResult<U> {
|
||||
|
@ -39,9 +39,8 @@ use rustc_data_structures::unify::{self, UnificationTable};
|
||||
use std::cell::{Cell, RefCell, Ref, RefMut};
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use errors::DiagnosticBuilder;
|
||||
use syntax_pos::{self, Span, DUMMY_SP};
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet, NodeMap};
|
||||
|
||||
use self::combine::CombineFields;
|
||||
@ -1036,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
-> UnitResult<'tcx>
|
||||
{
|
||||
self.probe(|_| {
|
||||
let origin = TypeOrigin::Misc(codemap::DUMMY_SP);
|
||||
let origin = TypeOrigin::Misc(syntax_pos::DUMMY_SP);
|
||||
let trace = TypeTrace::types(origin, true, a, b);
|
||||
self.sub(true, trace, &a, &b).map(|_| ())
|
||||
})
|
||||
@ -1813,7 +1812,7 @@ impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {
|
||||
|
||||
pub fn dummy(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
origin: TypeOrigin::Misc(codemap::DUMMY_SP),
|
||||
origin: TypeOrigin::Misc(syntax_pos::DUMMY_SP),
|
||||
values: Types(ExpectedFound {
|
||||
expected: tcx.types.err,
|
||||
found: tcx.types.err,
|
||||
@ -1887,7 +1886,7 @@ impl RegionVariableOrigin {
|
||||
Coercion(a) => a,
|
||||
EarlyBoundRegion(a, _) => a,
|
||||
LateBoundRegion(a, _, _) => a,
|
||||
BoundRegionInCoherence(_) => codemap::DUMMY_SP,
|
||||
BoundRegionInCoherence(_) => syntax_pos::DUMMY_SP,
|
||||
UpvarRegion(_, a) => a
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use self::TypeVariableValue::*;
|
||||
use self::UndoEntry::*;
|
||||
use hir::def_id::{DefId};
|
||||
use ty::{self, Ty};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::cmp::min;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -55,8 +55,10 @@ extern crate rustc_data_structures;
|
||||
extern crate serialize;
|
||||
extern crate collections;
|
||||
extern crate rustc_const_math;
|
||||
extern crate rustc_errors as errors;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
#[macro_use] extern crate syntax_pos;
|
||||
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
||||
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
@ -40,11 +40,11 @@ use std::cmp;
|
||||
use std::default::Default as StdDefault;
|
||||
use std::mem;
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::ast;
|
||||
use syntax::attr::ThinAttributesExt;
|
||||
use syntax_pos::Span;
|
||||
use errors::DiagnosticBuilder;
|
||||
use hir;
|
||||
use hir::intravisit as hir_visit;
|
||||
use hir::intravisit::{IdVisitor, IdVisitingOperation};
|
||||
|
@ -33,7 +33,7 @@ pub use self::LintSource::*;
|
||||
|
||||
use std::hash;
|
||||
use std::ascii::AsciiExt;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::FnKind;
|
||||
use syntax::visit as ast_visit;
|
||||
use syntax::ast;
|
||||
|
@ -17,7 +17,7 @@
|
||||
use hir::def::Def;
|
||||
use ty::{Ty, TyCtxt};
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use hir as ast;
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
|
@ -39,9 +39,9 @@ use std::rc::Rc;
|
||||
use std::path::PathBuf;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ptr::P;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::Span;
|
||||
use rustc_back::target::Target;
|
||||
use hir;
|
||||
use hir::intravisit::{IdVisitor, IdVisitingOperation, Visitor};
|
||||
|
@ -26,6 +26,7 @@ use lint;
|
||||
use std::collections::HashSet;
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::attr;
|
||||
use syntax_pos;
|
||||
|
||||
// Any local node that may call something in its body block should be
|
||||
// explored. For example, if it's a live NodeItem that is a
|
||||
@ -215,7 +216,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_variant_data(&mut self, def: &hir::VariantData, _: ast::Name,
|
||||
_: &hir::Generics, _: ast::NodeId, _: codemap::Span) {
|
||||
_: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) {
|
||||
let has_extern_repr = self.struct_has_extern_repr;
|
||||
let inherited_pub_visibility = self.inherited_pub_visibility;
|
||||
let live_fields = def.fields().iter().filter(|f| {
|
||||
@ -478,7 +479,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||
|
||||
fn warn_dead_code(&mut self,
|
||||
id: ast::NodeId,
|
||||
span: codemap::Span,
|
||||
span: syntax_pos::Span,
|
||||
name: ast::Name,
|
||||
node_type: &str) {
|
||||
let name = name.as_str();
|
||||
|
@ -18,7 +18,7 @@ use ty::{self, Ty, TyCtxt};
|
||||
use ty::MethodCall;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use hir;
|
||||
use hir::intravisit;
|
||||
use hir::intravisit::{FnKind, Visitor};
|
||||
|
@ -15,8 +15,8 @@ use hir::def_id::{CRATE_DEF_INDEX};
|
||||
use session::{config, Session};
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::entry::EntryPointType;
|
||||
use syntax_pos::Span;
|
||||
use hir::{Item, ItemFn};
|
||||
use hir::intravisit::Visitor;
|
||||
|
||||
|
@ -30,7 +30,7 @@ use hir::{self, PatKind};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// The Delegate trait
|
||||
|
@ -18,7 +18,7 @@ use ty::layout::{LayoutError, Pointer, SizeSkeleton};
|
||||
|
||||
use syntax::abi::Abi::RustIntrinsic;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
use hir;
|
||||
|
||||
|
@ -123,9 +123,10 @@ use std::io::prelude::*;
|
||||
use std::io;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::codemap::{BytePos, original_sp, Span};
|
||||
use syntax::codemap::original_sp;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{BytePos, Span};
|
||||
|
||||
use hir::Expr;
|
||||
use hir;
|
||||
|
@ -83,7 +83,7 @@ use hir::{MutImmutable, MutMutable, PatKind};
|
||||
use hir::pat_util::EnumerateAndAdjustIterator;
|
||||
use hir;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
@ -27,8 +27,9 @@ use std::cell::RefCell;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax::codemap;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
|
@ -29,8 +29,8 @@ use ty;
|
||||
use std::fmt;
|
||||
use std::mem::replace;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::keywords;
|
||||
use syntax_pos::Span;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
use rustc_data_structures::fnv::FnvHashSet;
|
||||
|
@ -23,7 +23,7 @@ use hir::def_id::{CRATE_DEF_INDEX, DefId};
|
||||
use ty::{self, TyCtxt};
|
||||
use middle::privacy::AccessLevels;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use syntax::ast;
|
||||
use syntax::ast::{NodeId, Attribute};
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version};
|
||||
|
@ -15,8 +15,8 @@ use session::Session;
|
||||
use middle::lang_items;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::Visitor;
|
||||
use hir::intravisit;
|
||||
use hir;
|
||||
|
@ -25,7 +25,7 @@ use std::fmt::{self, Debug, Formatter, Write};
|
||||
use std::{iter, u32};
|
||||
use std::ops::{Index, IndexMut};
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use super::cache::Cache;
|
||||
|
||||
|
@ -16,7 +16,7 @@ use mir::repr::*;
|
||||
use rustc_const_math::ConstUsize;
|
||||
use rustc_data_structures::tuple_slice::TupleSlice;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
// # The MIR Visitor
|
||||
//
|
||||
|
@ -26,11 +26,12 @@ use middle::cstore;
|
||||
use syntax::ast::{self, IntTy, UintTy};
|
||||
use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::errors::{ColorConfig, Handler};
|
||||
use syntax::parse;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
|
||||
use errors::{ColorConfig, Handler};
|
||||
|
||||
use getopts;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
@ -1420,12 +1421,11 @@ mod tests {
|
||||
use middle::cstore::DummyCrateStore;
|
||||
use session::config::{build_configuration, build_session_options};
|
||||
use session::build_session;
|
||||
|
||||
use errors;
|
||||
use std::rc::Rc;
|
||||
use getopts::{getopts, OptGroup};
|
||||
use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::diagnostics;
|
||||
|
||||
fn optgroups() -> Vec<OptGroup> {
|
||||
super::rustc_optgroups().into_iter()
|
||||
@ -1442,7 +1442,7 @@ mod tests {
|
||||
Ok(m) => m,
|
||||
Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
|
||||
};
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let registry = errors::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore));
|
||||
let cfg = build_configuration(&sess);
|
||||
@ -1462,7 +1462,7 @@ mod tests {
|
||||
panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
|
||||
}
|
||||
};
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let registry = errors::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry,
|
||||
Rc::new(DummyCrateStore));
|
||||
@ -1479,7 +1479,7 @@ mod tests {
|
||||
let matches = getopts(&[
|
||||
"-Awarnings".to_string()
|
||||
], &optgroups()).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let registry = errors::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry,
|
||||
Rc::new(DummyCrateStore));
|
||||
@ -1491,7 +1491,7 @@ mod tests {
|
||||
"-Awarnings".to_string(),
|
||||
"-Dwarnings".to_string()
|
||||
], &optgroups()).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let registry = errors::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry,
|
||||
Rc::new(DummyCrateStore));
|
||||
@ -1502,7 +1502,7 @@ mod tests {
|
||||
let matches = getopts(&[
|
||||
"-Adead_code".to_string()
|
||||
], &optgroups()).unwrap();
|
||||
let registry = diagnostics::registry::Registry::new(&[]);
|
||||
let registry = errors::registry::Registry::new(&[]);
|
||||
let sessopts = build_session_options(&matches);
|
||||
let sess = build_session(sessopts, &dep_graph, None, registry,
|
||||
Rc::new(DummyCrateStore));
|
||||
|
@ -21,17 +21,16 @@ use util::nodemap::{NodeMap, FnvHashMap};
|
||||
use mir::transform as mir_pass;
|
||||
|
||||
use syntax::ast::{NodeId, NodeIdAssigner, Name};
|
||||
use syntax::codemap::{Span, MultiSpan};
|
||||
use syntax::errors::{self, DiagnosticBuilder};
|
||||
use syntax::errors::emitter::{Emitter, BasicEmitter, EmitterWriter};
|
||||
use syntax::errors::json::JsonEmitter;
|
||||
use syntax::diagnostics;
|
||||
use errors::{self, DiagnosticBuilder};
|
||||
use errors::emitter::{Emitter, BasicEmitter, EmitterWriter};
|
||||
use syntax::json::JsonEmitter;
|
||||
use syntax::feature_gate;
|
||||
use syntax::parse;
|
||||
use syntax::parse::ParseSess;
|
||||
use syntax::parse::token;
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::feature_gate::AttributeType;
|
||||
use syntax_pos::{Span, MultiSpan};
|
||||
|
||||
use rustc_back::target::Target;
|
||||
use llvm;
|
||||
@ -424,7 +423,7 @@ fn split_msg_into_multilines(msg: &str) -> Option<String> {
|
||||
pub fn build_session(sopts: config::Options,
|
||||
dep_graph: &DepGraph,
|
||||
local_crate_source_file: Option<PathBuf>,
|
||||
registry: diagnostics::registry::Registry,
|
||||
registry: errors::registry::Registry,
|
||||
cstore: Rc<for<'a> CrateStore<'a>>)
|
||||
-> Session {
|
||||
build_session_with_codemap(sopts,
|
||||
@ -438,7 +437,7 @@ pub fn build_session(sopts: config::Options,
|
||||
pub fn build_session_with_codemap(sopts: config::Options,
|
||||
dep_graph: &DepGraph,
|
||||
local_crate_source_file: Option<PathBuf>,
|
||||
registry: diagnostics::registry::Registry,
|
||||
registry: errors::registry::Registry,
|
||||
cstore: Rc<for<'a> CrateStore<'a>>,
|
||||
codemap: Rc<codemap::CodeMap>)
|
||||
-> Session {
|
||||
@ -455,7 +454,10 @@ pub fn build_session_with_codemap(sopts: config::Options,
|
||||
|
||||
let emitter: Box<Emitter> = match sopts.error_format {
|
||||
config::ErrorOutputType::HumanReadable(color_config) => {
|
||||
Box::new(EmitterWriter::stderr(color_config, Some(registry), codemap.clone()))
|
||||
Box::new(EmitterWriter::stderr(color_config,
|
||||
Some(registry),
|
||||
codemap.clone(),
|
||||
errors::snippet::FormatMode::EnvironmentSelected))
|
||||
}
|
||||
config::ErrorOutputType::Json => {
|
||||
Box::new(JsonEmitter::stderr(Some(registry), codemap.clone()))
|
||||
|
@ -17,7 +17,7 @@ use hir::def_id::DefId;
|
||||
use ty::subst::TypeSpace;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
use infer::{InferCtxt, TypeOrigin};
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct InferIsLocal(bool);
|
||||
|
@ -37,8 +37,8 @@ use std::cmp;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use syntax::attr::{AttributeMethods, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use syntax_pos::Span;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct TraitErrorKey<'tcx> {
|
||||
|
@ -23,7 +23,7 @@ use infer::InferCtxt;
|
||||
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
pub use self::error_reporting::TraitErrorKey;
|
||||
pub use self::coherence::orphan_check;
|
||||
|
@ -27,7 +27,7 @@ use middle::region;
|
||||
use ty::subst::{Subst, Substs};
|
||||
use traits::{self, ProjectionMode, ObligationCause, Normalized};
|
||||
use ty::{self, TyCtxt};
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
pub mod specialization_graph;
|
||||
|
||||
|
@ -12,7 +12,7 @@ use hir::def_id::DefId;
|
||||
use infer::InferCtxt;
|
||||
use ty::subst::{Subst, Substs};
|
||||
use ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use util::common::ErrorReported;
|
||||
use util::nodemap::FnvHashSet;
|
||||
|
||||
|
@ -15,7 +15,7 @@ use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable};
|
||||
use ty::LvaluePreference::{NoPreference};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
|
||||
|
@ -862,7 +862,7 @@ pub mod tls {
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use syntax::codemap;
|
||||
use syntax_pos;
|
||||
|
||||
/// Marker types used for the scoped TLS slot.
|
||||
/// The type context cannot be used directly because the scoped TLS
|
||||
@ -875,7 +875,7 @@ pub mod tls {
|
||||
*const ThreadLocalInterners)>> = Cell::new(None)
|
||||
}
|
||||
|
||||
fn span_debug(span: codemap::Span, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
with(|tcx| {
|
||||
write!(f, "{}", tcx.sess.codemap().span_to_string(span))
|
||||
})
|
||||
@ -884,7 +884,7 @@ pub mod tls {
|
||||
pub fn enter_global<'gcx, F, R>(gcx: GlobalCtxt<'gcx>, f: F) -> R
|
||||
where F: for<'a> FnOnce(TyCtxt<'a, 'gcx, 'gcx>) -> R
|
||||
{
|
||||
codemap::SPAN_DEBUG.with(|span_dbg| {
|
||||
syntax_pos::SPAN_DEBUG.with(|span_dbg| {
|
||||
let original_span_debug = span_dbg.get();
|
||||
span_dbg.set(span_debug);
|
||||
let result = enter(&gcx, &gcx.global_interners, f);
|
||||
|
@ -16,8 +16,8 @@ use ty::{self, BoundRegion, Region, Ty, TyCtxt};
|
||||
use std::fmt;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use errors::DiagnosticBuilder;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
|
||||
|
@ -21,7 +21,7 @@ use util::common::slice_pat;
|
||||
|
||||
use syntax::ast::{FloatTy, IntTy, UintTy};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
|
@ -44,8 +44,8 @@ use std::slice;
|
||||
use std::vec::IntoIter;
|
||||
use syntax::ast::{self, CrateNum, Name, NodeId};
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
|
||||
use rustc_const_math::ConstInt;
|
||||
|
||||
|
@ -22,7 +22,7 @@ use std::fmt;
|
||||
use std::iter::IntoIterator;
|
||||
use std::slice::Iter;
|
||||
use std::vec::{Vec, IntoIter};
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -27,7 +27,7 @@ use std::cmp;
|
||||
use std::hash::{Hash, SipHasher, Hasher};
|
||||
use syntax::ast::{self, Name};
|
||||
use syntax::attr::{self, SignedInt, UnsignedInt};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
|
||||
|
@ -16,7 +16,7 @@ use traits;
|
||||
use ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable};
|
||||
use std::iter::once;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use util::common::ErrorReported;
|
||||
|
||||
/// Returns the set of obligations needed to make `ty` well-formed.
|
||||
|
@ -12,6 +12,7 @@ test = false
|
||||
[dependencies]
|
||||
log = { path = "../liblog" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
graphviz = { path = "../libgraphviz" }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
|
@ -27,7 +27,7 @@ use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
@ -27,8 +27,8 @@ use rustc::middle::mem_categorization as mc;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
enum Fragment {
|
||||
|
@ -22,7 +22,7 @@ use rustc::ty;
|
||||
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
||||
struct GatherMoveInfo<'tcx> {
|
||||
|
@ -19,7 +19,7 @@ use rustc::middle::region;
|
||||
use rustc::ty;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
type R = Result<(),()>;
|
||||
|
||||
|
@ -25,8 +25,8 @@ use rustc::middle::region;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
use rustc::hir::Expr;
|
||||
use rustc::hir::intravisit;
|
||||
|
@ -14,8 +14,8 @@ use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::middle::mem_categorization::InteriorOffsetKind as Kind;
|
||||
use rustc::ty;
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use syntax_pos;
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc::hir;
|
||||
|
||||
pub struct MoveErrorCollector<'tcx> {
|
||||
@ -56,7 +56,7 @@ impl<'tcx> MoveError<'tcx> {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MoveSpanAndPath {
|
||||
pub span: codemap::Span,
|
||||
pub span: syntax_pos::Span,
|
||||
pub name: ast::Name,
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
}
|
||||
|
||||
fn note_move_destination(mut err: DiagnosticBuilder,
|
||||
move_to_span: codemap::Span,
|
||||
move_to_span: syntax_pos::Span,
|
||||
pat_name: ast::Name,
|
||||
is_first_note: bool) -> DiagnosticBuilder {
|
||||
if is_first_note {
|
||||
|
@ -15,7 +15,7 @@ use rustc::middle::expr_use_visitor as euv;
|
||||
use rustc::middle::mem_categorization as mc;
|
||||
use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::ty;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use borrowck::ToInteriorKind;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
use syntax::abi::{Abi};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::mir::repr::{self, Mir};
|
||||
|
@ -23,7 +23,7 @@ use rustc::middle::const_val::ConstVal;
|
||||
use rustc::middle::lang_items;
|
||||
use rustc::util::nodemap::FnvHashMap;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::fmt;
|
||||
use std::u32;
|
||||
|
@ -12,8 +12,8 @@ use borrowck::BorrowckCtxt;
|
||||
|
||||
use syntax::ast::{self, MetaItem};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{FnKind};
|
||||
|
@ -43,8 +43,8 @@ use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::{MultiSpan, Span};
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::{FnDecl, Block};
|
||||
|
@ -28,7 +28,7 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::usize;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::IdRange;
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#![feature(question_mark)]
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
extern crate syntax_pos;
|
||||
extern crate rustc_errors as errors;
|
||||
|
||||
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
|
||||
// refers to the borrowck-specific graphviz adapter traits.
|
||||
|
@ -16,3 +16,4 @@ rustc_back = { path = "../librustc_back" }
|
||||
rustc_const_math = { path = "../librustc_const_math" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
graphviz = { path = "../libgraphviz" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
@ -37,7 +37,8 @@ use rustc::hir::intravisit::{self, IdVisitor, IdVisitingOperation, Visitor, FnKi
|
||||
use rustc_back::slice;
|
||||
|
||||
use syntax::ast::{self, DUMMY_NODE_ID, NodeId};
|
||||
use syntax::codemap::{Span, Spanned, DUMMY_SP};
|
||||
use syntax::codemap::Spanned;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use rustc::hir::fold::{Folder, noop_fold_pat};
|
||||
use rustc::hir::print::pat_to_string;
|
||||
use syntax::ptr::P;
|
||||
|
@ -33,10 +33,10 @@ use syntax::ast;
|
||||
use rustc::hir::{Expr, PatKind};
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::FnKind;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap;
|
||||
use syntax::attr::IntType;
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::Ordering;
|
||||
@ -301,7 +301,7 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let field_pats =
|
||||
try!(fields.iter()
|
||||
.map(|field| Ok(codemap::Spanned {
|
||||
span: codemap::DUMMY_SP,
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
node: hir::FieldPat {
|
||||
name: field.name.node,
|
||||
pat: try!(const_expr_to_pat(tcx, &field.expr,
|
||||
|
@ -38,7 +38,7 @@
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_const_math;
|
||||
extern crate graphviz;
|
||||
|
||||
extern crate syntax_pos;
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
||||
// NB: This module needs to be declared first so diagnostics are
|
||||
|
@ -17,6 +17,7 @@ rustc = { path = "../librustc" }
|
||||
rustc_back = { path = "../librustc_back" }
|
||||
rustc_borrowck = { path = "../librustc_borrowck" }
|
||||
rustc_const_eval = { path = "../librustc_const_eval" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_lint = { path = "../librustc_lint" }
|
||||
rustc_llvm = { path = "../librustc_llvm" }
|
||||
rustc_mir = { path = "../librustc_mir" }
|
||||
@ -32,3 +33,4 @@ rustc_metadata = { path = "../librustc_metadata" }
|
||||
serialize = { path = "../libserialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_ext = { path = "../libsyntax_ext" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
@ -42,6 +42,7 @@ extern crate rustc;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_borrowck;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate rustc_errors as errors;
|
||||
extern crate rustc_passes;
|
||||
extern crate rustc_lint;
|
||||
extern crate rustc_plugin;
|
||||
@ -60,6 +61,7 @@ extern crate log;
|
||||
#[macro_use]
|
||||
extern crate syntax;
|
||||
extern crate syntax_ext;
|
||||
extern crate syntax_pos;
|
||||
|
||||
use driver::CompileController;
|
||||
use pretty::{PpMode, UserIdentifiedItem};
|
||||
@ -92,11 +94,12 @@ use std::thread;
|
||||
|
||||
use rustc::session::early_error;
|
||||
|
||||
use syntax::{ast, errors, diagnostics};
|
||||
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader, MultiSpan};
|
||||
use syntax::errors::emitter::Emitter;
|
||||
use syntax::{ast, json};
|
||||
use syntax::codemap::{CodeMap, FileLoader, RealFileLoader};
|
||||
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
|
||||
use syntax::parse::{self, PResult, token};
|
||||
use syntax_pos::MultiSpan;
|
||||
use errors::emitter::Emitter;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test;
|
||||
@ -290,7 +293,7 @@ pub trait CompilerCalls<'a> {
|
||||
fn early_callback(&mut self,
|
||||
_: &getopts::Matches,
|
||||
_: &config::Options,
|
||||
_: &diagnostics::registry::Registry,
|
||||
_: &errors::registry::Registry,
|
||||
_: ErrorOutputType)
|
||||
-> Compilation {
|
||||
Compilation::Continue
|
||||
@ -329,7 +332,7 @@ pub trait CompilerCalls<'a> {
|
||||
_: &config::Options,
|
||||
_: &Option<PathBuf>,
|
||||
_: &Option<PathBuf>,
|
||||
_: &diagnostics::registry::Registry)
|
||||
_: &errors::registry::Registry)
|
||||
-> Option<(Input, Option<PathBuf>)> {
|
||||
None
|
||||
}
|
||||
@ -344,7 +347,7 @@ pub trait CompilerCalls<'a> {
|
||||
pub struct RustcDefaultCalls;
|
||||
|
||||
fn handle_explain(code: &str,
|
||||
descriptions: &diagnostics::registry::Registry,
|
||||
descriptions: &errors::registry::Registry,
|
||||
output: ErrorOutputType) {
|
||||
let normalised = if code.starts_with("E") {
|
||||
code.to_string()
|
||||
@ -374,7 +377,7 @@ fn check_cfg(sopts: &config::Options,
|
||||
config::ErrorOutputType::HumanReadable(color_config) => {
|
||||
Box::new(errors::emitter::BasicEmitter::stderr(color_config))
|
||||
}
|
||||
config::ErrorOutputType::Json => Box::new(errors::json::JsonEmitter::basic()),
|
||||
config::ErrorOutputType::Json => Box::new(json::JsonEmitter::basic()),
|
||||
};
|
||||
|
||||
let mut saw_invalid_predicate = false;
|
||||
@ -401,7 +404,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
||||
fn early_callback(&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
descriptions: &diagnostics::registry::Registry,
|
||||
descriptions: &errors::registry::Registry,
|
||||
output: ErrorOutputType)
|
||||
-> Compilation {
|
||||
if let Some(ref code) = matches.opt_str("explain") {
|
||||
@ -418,7 +421,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
||||
sopts: &config::Options,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
descriptions: &diagnostics::registry::Registry)
|
||||
descriptions: &errors::registry::Registry)
|
||||
-> Option<(Input, Option<PathBuf>)> {
|
||||
match matches.free.len() {
|
||||
0 => {
|
||||
@ -1081,8 +1084,8 @@ fn exit_on_err() -> ! {
|
||||
panic!();
|
||||
}
|
||||
|
||||
pub fn diagnostics_registry() -> diagnostics::registry::Registry {
|
||||
use syntax::diagnostics::registry::Registry;
|
||||
pub fn diagnostics_registry() -> errors::registry::Registry {
|
||||
use errors::registry::Registry;
|
||||
|
||||
let mut all_errors = Vec::new();
|
||||
all_errors.extend_from_slice(&rustc::DIAGNOSTICS);
|
||||
|
@ -31,12 +31,12 @@ use rustc_mir::pretty::write_mir_pretty;
|
||||
use rustc_mir::graphviz::write_mir_graphviz;
|
||||
|
||||
use syntax::ast::{self, BlockCheckMode};
|
||||
use syntax::codemap;
|
||||
use syntax::fold::{self, Folder};
|
||||
use syntax::print::{pp, pprust};
|
||||
use syntax::print::pprust::PrintState;
|
||||
use syntax::ptr::P;
|
||||
use syntax::util::small_vector::SmallVector;
|
||||
use syntax_pos;
|
||||
|
||||
use graphviz as dot;
|
||||
|
||||
@ -661,7 +661,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
|
||||
stmts: vec![],
|
||||
rules: rules,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: codemap::DUMMY_SP,
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
})
|
||||
}
|
||||
|
||||
@ -671,7 +671,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
|
||||
let loop_expr = P(ast::Expr {
|
||||
node: ast::ExprKind::Loop(empty_block, None),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: codemap::DUMMY_SP,
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
attrs: None,
|
||||
});
|
||||
|
||||
|
@ -31,12 +31,13 @@ use rustc::session::{self, config};
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::codemap::{CodeMap, DUMMY_SP};
|
||||
use syntax::errors;
|
||||
use syntax::errors::emitter::{CoreEmitter, Emitter};
|
||||
use syntax::errors::{Level, RenderSpan};
|
||||
use syntax::codemap::CodeMap;
|
||||
use errors;
|
||||
use errors::emitter::{CoreEmitter, Emitter};
|
||||
use errors::{Level, RenderSpan};
|
||||
use syntax::parse::token;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
14
src/librustc_errors/Cargo.toml
Normal file
14
src/librustc_errors/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustc_errors"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
name = "rustc_errors"
|
||||
path = "lib.rs"
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
log = { path = "../liblog" }
|
||||
serialize = { path = "../libserialize" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
@ -10,14 +10,14 @@
|
||||
|
||||
use self::Destination::*;
|
||||
|
||||
use codemap::{self, COMMAND_LINE_SP, DUMMY_SP, Span, MultiSpan};
|
||||
use diagnostics;
|
||||
use syntax_pos::{COMMAND_LINE_SP, DUMMY_SP, Span, MultiSpan, LineInfo};
|
||||
use registry;
|
||||
|
||||
use errors::check_old_skool;
|
||||
use errors::{Level, RenderSpan, CodeSuggestion, DiagnosticBuilder};
|
||||
use errors::RenderSpan::*;
|
||||
use errors::Level::*;
|
||||
use errors::snippet::{RenderedLineKind, SnippetData, Style};
|
||||
use check_old_skool;
|
||||
use {Level, RenderSpan, CodeSuggestion, DiagnosticBuilder, CodeMapper};
|
||||
use RenderSpan::*;
|
||||
use Level::*;
|
||||
use snippet::{RenderedLineKind, SnippetData, Style, FormatMode};
|
||||
|
||||
use std::{cmp, fmt};
|
||||
use std::io::prelude::*;
|
||||
@ -151,15 +151,15 @@ impl BasicEmitter {
|
||||
|
||||
pub struct EmitterWriter {
|
||||
dst: Destination,
|
||||
registry: Option<diagnostics::registry::Registry>,
|
||||
cm: Rc<codemap::CodeMap>,
|
||||
registry: Option<registry::Registry>,
|
||||
cm: Rc<CodeMapper>,
|
||||
|
||||
/// Is this the first error emitted thus far? If not, we emit a
|
||||
/// `\n` before the top-level errors.
|
||||
first: bool,
|
||||
|
||||
// For now, allow an old-school mode while we transition
|
||||
old_school: bool,
|
||||
format_mode: FormatMode
|
||||
}
|
||||
|
||||
impl CoreEmitter for EmitterWriter {
|
||||
@ -193,36 +193,36 @@ macro_rules! println_maybe_styled {
|
||||
|
||||
impl EmitterWriter {
|
||||
pub fn stderr(color_config: ColorConfig,
|
||||
registry: Option<diagnostics::registry::Registry>,
|
||||
code_map: Rc<codemap::CodeMap>)
|
||||
registry: Option<registry::Registry>,
|
||||
code_map: Rc<CodeMapper>,
|
||||
format_mode: FormatMode)
|
||||
-> EmitterWriter {
|
||||
let old_school = check_old_skool();
|
||||
if color_config.use_color() {
|
||||
let dst = Destination::from_stderr();
|
||||
EmitterWriter { dst: dst,
|
||||
registry: registry,
|
||||
cm: code_map,
|
||||
first: true,
|
||||
old_school: old_school }
|
||||
format_mode: format_mode.clone() }
|
||||
} else {
|
||||
EmitterWriter { dst: Raw(Box::new(io::stderr())),
|
||||
registry: registry,
|
||||
cm: code_map,
|
||||
first: true,
|
||||
old_school: old_school }
|
||||
format_mode: format_mode.clone() }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(dst: Box<Write + Send>,
|
||||
registry: Option<diagnostics::registry::Registry>,
|
||||
code_map: Rc<codemap::CodeMap>)
|
||||
registry: Option<registry::Registry>,
|
||||
code_map: Rc<CodeMapper>,
|
||||
format_mode: FormatMode)
|
||||
-> EmitterWriter {
|
||||
let old_school = check_old_skool();
|
||||
EmitterWriter { dst: Raw(dst),
|
||||
registry: registry,
|
||||
cm: code_map,
|
||||
first: true,
|
||||
old_school: old_school }
|
||||
format_mode: format_mode.clone() }
|
||||
}
|
||||
|
||||
fn emit_message_(&mut self,
|
||||
@ -233,11 +233,17 @@ impl EmitterWriter {
|
||||
is_header: bool,
|
||||
show_snippet: bool)
|
||||
-> io::Result<()> {
|
||||
let old_school = match self.format_mode {
|
||||
FormatMode::NewErrorFormat => false,
|
||||
FormatMode::OriginalErrorFormat => true,
|
||||
FormatMode::EnvironmentSelected => check_old_skool()
|
||||
};
|
||||
|
||||
if is_header {
|
||||
if self.first {
|
||||
self.first = false;
|
||||
} else {
|
||||
if !self.old_school {
|
||||
if !old_school {
|
||||
write!(self.dst, "\n")?;
|
||||
}
|
||||
}
|
||||
@ -248,7 +254,7 @@ impl EmitterWriter {
|
||||
.and_then(|registry| registry.find_description(code))
|
||||
.is_some() => {
|
||||
let code_with_explain = String::from("--explain ") + code;
|
||||
if self.old_school {
|
||||
if old_school {
|
||||
let loc = match rsp.span().primary_span() {
|
||||
Some(COMMAND_LINE_SP) | Some(DUMMY_SP) => "".to_string(),
|
||||
Some(ps) => self.cm.span_to_string(ps),
|
||||
@ -261,7 +267,7 @@ impl EmitterWriter {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if self.old_school {
|
||||
if old_school {
|
||||
let loc = match rsp.span().primary_span() {
|
||||
Some(COMMAND_LINE_SP) | Some(DUMMY_SP) => "".to_string(),
|
||||
Some(ps) => self.cm.span_to_string(ps),
|
||||
@ -303,7 +309,7 @@ impl EmitterWriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.old_school {
|
||||
if old_school {
|
||||
match code {
|
||||
Some(code) if self.registry.as_ref()
|
||||
.and_then(|registry| registry.find_description(code))
|
||||
@ -326,11 +332,13 @@ impl EmitterWriter {
|
||||
|
||||
fn highlight_suggestion(&mut self, suggestion: &CodeSuggestion) -> io::Result<()>
|
||||
{
|
||||
use std::borrow::Borrow;
|
||||
|
||||
let primary_span = suggestion.msp.primary_span().unwrap();
|
||||
let lines = self.cm.span_to_lines(primary_span).unwrap();
|
||||
assert!(!lines.lines.is_empty());
|
||||
|
||||
let complete = suggestion.splice_lines(&self.cm);
|
||||
let complete = suggestion.splice_lines(self.cm.borrow());
|
||||
let line_count = cmp::min(lines.lines.len(), MAX_HIGHLIGHT_LINES);
|
||||
let display_lines = &lines.lines[..line_count];
|
||||
|
||||
@ -356,19 +364,27 @@ impl EmitterWriter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn highlight_lines(&mut self,
|
||||
pub fn highlight_lines(&mut self,
|
||||
msp: &MultiSpan,
|
||||
lvl: Level)
|
||||
-> io::Result<()>
|
||||
{
|
||||
let old_school = match self.format_mode {
|
||||
FormatMode::NewErrorFormat => false,
|
||||
FormatMode::OriginalErrorFormat => true,
|
||||
FormatMode::EnvironmentSelected => check_old_skool()
|
||||
};
|
||||
|
||||
let mut snippet_data = SnippetData::new(self.cm.clone(),
|
||||
msp.primary_span());
|
||||
if self.old_school {
|
||||
msp.primary_span(),
|
||||
self.format_mode.clone());
|
||||
if old_school {
|
||||
let mut output_vec = vec![];
|
||||
|
||||
for span_label in msp.span_labels() {
|
||||
let mut snippet_data = SnippetData::new(self.cm.clone(),
|
||||
Some(span_label.span));
|
||||
Some(span_label.span),
|
||||
self.format_mode.clone());
|
||||
|
||||
snippet_data.push(span_label.span,
|
||||
span_label.is_primary,
|
||||
@ -430,7 +446,7 @@ impl EmitterWriter {
|
||||
}
|
||||
}
|
||||
|
||||
fn line_num_max_digits(line: &codemap::LineInfo) -> usize {
|
||||
fn line_num_max_digits(line: &LineInfo) -> usize {
|
||||
let mut max_line_num = line.line_index + 1;
|
||||
let mut digits = 0;
|
||||
while max_line_num > 0 {
|
||||
@ -617,255 +633,3 @@ impl Write for Destination {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use errors::{Level, CodeSuggestion};
|
||||
use super::EmitterWriter;
|
||||
use codemap::{mk_sp, CodeMap, Span, MultiSpan, BytePos, NO_EXPANSION};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::io::{self, Write};
|
||||
use std::str::from_utf8;
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Sink(Arc<Mutex<Vec<u8>>>);
|
||||
impl Write for Sink {
|
||||
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
|
||||
Write::write(&mut *self.0.lock().unwrap(), data)
|
||||
}
|
||||
fn flush(&mut self) -> io::Result<()> { Ok(()) }
|
||||
}
|
||||
|
||||
/// Given a string like " ^~~~~~~~~~~~ ", produces a span
|
||||
/// coverting that range. The idea is that the string has the same
|
||||
/// length as the input, and we uncover the byte positions. Note
|
||||
/// that this can span lines and so on.
|
||||
fn span_from_selection(input: &str, selection: &str) -> Span {
|
||||
assert_eq!(input.len(), selection.len());
|
||||
let left_index = selection.find('~').unwrap() as u32;
|
||||
let right_index = selection.rfind('~').map(|x|x as u32).unwrap_or(left_index);
|
||||
Span { lo: BytePos(left_index), hi: BytePos(right_index + 1), expn_id: NO_EXPANSION }
|
||||
}
|
||||
|
||||
// Diagnostic doesn't align properly in span where line number increases by one digit
|
||||
#[test]
|
||||
fn test_hilight_suggestion_issue_11715() {
|
||||
let data = Arc::new(Mutex::new(Vec::new()));
|
||||
let cm = Rc::new(CodeMap::new());
|
||||
let mut ew = EmitterWriter::new(Box::new(Sink(data.clone())), None, cm.clone());
|
||||
let content = "abcdefg
|
||||
koksi
|
||||
line3
|
||||
line4
|
||||
cinq
|
||||
line6
|
||||
line7
|
||||
line8
|
||||
line9
|
||||
line10
|
||||
e-lä-vän
|
||||
tolv
|
||||
dreizehn
|
||||
";
|
||||
let file = cm.new_filemap_and_lines("dummy.txt", None, content);
|
||||
let start = file.lines.borrow()[10];
|
||||
let end = file.lines.borrow()[11];
|
||||
let sp = mk_sp(start, end);
|
||||
let lvl = Level::Error;
|
||||
println!("highlight_lines");
|
||||
ew.highlight_lines(&sp.into(), lvl).unwrap();
|
||||
println!("done");
|
||||
let vec = data.lock().unwrap().clone();
|
||||
let vec: &[u8] = &vec;
|
||||
let str = from_utf8(vec).unwrap();
|
||||
println!("r#\"\n{}\"#", str);
|
||||
assert_eq!(str, &r#"
|
||||
--> dummy.txt:11:1
|
||||
|>
|
||||
11 |> e-lä-vän
|
||||
|> ^
|
||||
"#[1..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_span_splice() {
|
||||
// Test that a `MultiSpan` containing a single span splices a substition correctly
|
||||
let cm = CodeMap::new();
|
||||
let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n";
|
||||
let selection = " \n ~~\n~~~\n~~~~~ \n \n";
|
||||
cm.new_filemap_and_lines("blork.rs", None, inputtext);
|
||||
let sp = span_from_selection(inputtext, selection);
|
||||
let msp: MultiSpan = sp.into();
|
||||
|
||||
// check that we are extracting the text we thought we were extracting
|
||||
assert_eq!(&cm.span_to_snippet(sp).unwrap(), "BB\nCCC\nDDDDD");
|
||||
|
||||
let substitute = "ZZZZZZ".to_owned();
|
||||
let expected = "bbbbZZZZZZddddd";
|
||||
let suggest = CodeSuggestion {
|
||||
msp: msp,
|
||||
substitutes: vec![substitute],
|
||||
};
|
||||
assert_eq!(suggest.splice_lines(&cm), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multi_span_splice() {
|
||||
// Test that a `MultiSpan` containing multiple spans splices a substition correctly
|
||||
let cm = CodeMap::new();
|
||||
let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n";
|
||||
let selection1 = " \n \n \n \n ~ \n"; // intentionally out of order
|
||||
let selection2 = " \n ~~\n~~~\n~~~~~ \n \n";
|
||||
cm.new_filemap_and_lines("blork.rs", None, inputtext);
|
||||
let sp1 = span_from_selection(inputtext, selection1);
|
||||
let sp2 = span_from_selection(inputtext, selection2);
|
||||
let msp: MultiSpan = MultiSpan::from_spans(vec![sp1, sp2]);
|
||||
|
||||
let expected = "bbbbZZZZZZddddd\neXYZe";
|
||||
let suggest = CodeSuggestion {
|
||||
msp: msp,
|
||||
substitutes: vec!["ZZZZZZ".to_owned(),
|
||||
"XYZ".to_owned()]
|
||||
};
|
||||
|
||||
assert_eq!(suggest.splice_lines(&cm), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multispan_highlight() {
|
||||
let data = Arc::new(Mutex::new(Vec::new()));
|
||||
let cm = Rc::new(CodeMap::new());
|
||||
let mut diag = EmitterWriter::new(Box::new(Sink(data.clone())), None, cm.clone());
|
||||
|
||||
let inp = "_____aaaaaa____bbbbbb__cccccdd_";
|
||||
let sp1 = " ~~~~~~ ";
|
||||
let sp2 = " ~~~~~~ ";
|
||||
let sp3 = " ~~~~~ ";
|
||||
let sp4 = " ~~~~ ";
|
||||
let sp34 = " ~~~~~~~ ";
|
||||
|
||||
let expect_start = &r#"
|
||||
--> dummy.txt:1:6
|
||||
|>
|
||||
1 |> _____aaaaaa____bbbbbb__cccccdd_
|
||||
|> ^^^^^^ ^^^^^^ ^^^^^^^
|
||||
"#[1..];
|
||||
|
||||
let span = |sp, expected| {
|
||||
let sp = span_from_selection(inp, sp);
|
||||
assert_eq!(&cm.span_to_snippet(sp).unwrap(), expected);
|
||||
sp
|
||||
};
|
||||
cm.new_filemap_and_lines("dummy.txt", None, inp);
|
||||
let sp1 = span(sp1, "aaaaaa");
|
||||
let sp2 = span(sp2, "bbbbbb");
|
||||
let sp3 = span(sp3, "ccccc");
|
||||
let sp4 = span(sp4, "ccdd");
|
||||
let sp34 = span(sp34, "cccccdd");
|
||||
|
||||
let spans = vec![sp1, sp2, sp3, sp4];
|
||||
|
||||
let test = |expected, highlight: &mut FnMut()| {
|
||||
data.lock().unwrap().clear();
|
||||
highlight();
|
||||
let vec = data.lock().unwrap().clone();
|
||||
let actual = from_utf8(&vec[..]).unwrap();
|
||||
println!("actual=\n{}", actual);
|
||||
assert_eq!(actual, expected);
|
||||
};
|
||||
|
||||
let msp = MultiSpan::from_spans(vec![sp1, sp2, sp34]);
|
||||
test(expect_start, &mut || {
|
||||
diag.highlight_lines(&msp, Level::Error).unwrap();
|
||||
});
|
||||
test(expect_start, &mut || {
|
||||
let msp = MultiSpan::from_spans(spans.clone());
|
||||
diag.highlight_lines(&msp, Level::Error).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_huge_multispan_highlight() {
|
||||
let data = Arc::new(Mutex::new(Vec::new()));
|
||||
let cm = Rc::new(CodeMap::new());
|
||||
let mut diag = EmitterWriter::new(Box::new(Sink(data.clone())), None, cm.clone());
|
||||
|
||||
let inp = "aaaaa\n\
|
||||
aaaaa\n\
|
||||
aaaaa\n\
|
||||
bbbbb\n\
|
||||
ccccc\n\
|
||||
xxxxx\n\
|
||||
yyyyy\n\
|
||||
_____\n\
|
||||
ddd__eee_\n\
|
||||
elided\n\
|
||||
__f_gg";
|
||||
let file = cm.new_filemap_and_lines("dummy.txt", None, inp);
|
||||
|
||||
let span = |lo, hi, (off_lo, off_hi)| {
|
||||
let lines = file.lines.borrow();
|
||||
let (mut lo, mut hi): (BytePos, BytePos) = (lines[lo], lines[hi]);
|
||||
lo.0 += off_lo;
|
||||
hi.0 += off_hi;
|
||||
mk_sp(lo, hi)
|
||||
};
|
||||
let sp0 = span(4, 6, (0, 5));
|
||||
let sp1 = span(0, 6, (0, 5));
|
||||
let sp2 = span(8, 8, (0, 3));
|
||||
let sp3 = span(8, 8, (5, 8));
|
||||
let sp4 = span(10, 10, (2, 3));
|
||||
let sp5 = span(10, 10, (4, 6));
|
||||
|
||||
let expect0 = &r#"
|
||||
--> dummy.txt:5:1
|
||||
|>
|
||||
5 |> ccccc
|
||||
|> ^
|
||||
...
|
||||
9 |> ddd__eee_
|
||||
|> ^^^ ^^^
|
||||
10 |> elided
|
||||
11 |> __f_gg
|
||||
|> ^ ^^
|
||||
"#[1..];
|
||||
|
||||
let expect = &r#"
|
||||
--> dummy.txt:1:1
|
||||
|>
|
||||
1 |> aaaaa
|
||||
|> ^
|
||||
...
|
||||
9 |> ddd__eee_
|
||||
|> ^^^ ^^^
|
||||
10 |> elided
|
||||
11 |> __f_gg
|
||||
|> ^ ^^
|
||||
"#[1..];
|
||||
|
||||
macro_rules! test {
|
||||
($expected: expr, $highlight: expr) => ({
|
||||
data.lock().unwrap().clear();
|
||||
$highlight();
|
||||
let vec = data.lock().unwrap().clone();
|
||||
let actual = from_utf8(&vec[..]).unwrap();
|
||||
println!("actual:");
|
||||
println!("{}", actual);
|
||||
println!("expected:");
|
||||
println!("{}", $expected);
|
||||
assert_eq!(&actual[..], &$expected[..]);
|
||||
});
|
||||
}
|
||||
|
||||
let msp0 = MultiSpan::from_spans(vec![sp0, sp2, sp3, sp4, sp5]);
|
||||
let msp = MultiSpan::from_spans(vec![sp1, sp2, sp3, sp4, sp5]);
|
||||
|
||||
test!(expect0, || {
|
||||
diag.highlight_lines(&msp0, Level::Error).unwrap();
|
||||
});
|
||||
test!(expect, || {
|
||||
diag.highlight_lines(&msp, Level::Error).unwrap();
|
||||
});
|
||||
}
|
||||
}
|
@ -8,24 +8,50 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use errors::emitter::ColorConfig;
|
||||
#![crate_name = "rustc_errors"]
|
||||
#![unstable(feature = "rustc_private", issue = "27812")]
|
||||
#![crate_type = "dylib"]
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![cfg_attr(not(stage0), deny(warnings))]
|
||||
|
||||
#![feature(custom_attribute)]
|
||||
#![allow(unused_attributes)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(question_mark)]
|
||||
#![feature(range_contains)]
|
||||
#![feature(libc)]
|
||||
#![feature(unicode)]
|
||||
|
||||
extern crate serialize;
|
||||
extern crate term;
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate libc;
|
||||
extern crate rustc_unicode;
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
extern crate syntax_pos;
|
||||
|
||||
pub use emitter::ColorConfig;
|
||||
|
||||
use self::Level::*;
|
||||
use self::RenderSpan::*;
|
||||
|
||||
use codemap::{self, CodeMap, MultiSpan, NO_EXPANSION, Span};
|
||||
use diagnostics;
|
||||
use errors::emitter::{Emitter, EmitterWriter};
|
||||
use emitter::{Emitter, EmitterWriter};
|
||||
|
||||
use std::cell::{RefCell, Cell};
|
||||
use std::{error, fmt};
|
||||
use std::rc::Rc;
|
||||
use std::thread::panicking;
|
||||
use term;
|
||||
|
||||
pub mod emitter;
|
||||
pub mod json;
|
||||
pub mod snippet;
|
||||
pub mod registry;
|
||||
|
||||
use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION };
|
||||
use syntax_pos::{MacroBacktrace};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum RenderSpan {
|
||||
@ -43,8 +69,16 @@ pub enum RenderSpan {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CodeSuggestion {
|
||||
msp: MultiSpan,
|
||||
substitutes: Vec<String>,
|
||||
pub msp: MultiSpan,
|
||||
pub substitutes: Vec<String>,
|
||||
}
|
||||
|
||||
pub trait CodeMapper {
|
||||
fn lookup_char_pos(&self, pos: BytePos) -> Loc;
|
||||
fn span_to_lines(&self, sp: Span) -> FileLinesResult;
|
||||
fn span_to_string(&self, sp: Span) -> String;
|
||||
fn span_to_filename(&self, sp: Span) -> FileName;
|
||||
fn macro_backtrace(&self, span: Span) -> Vec<MacroBacktrace>;
|
||||
}
|
||||
|
||||
impl RenderSpan {
|
||||
@ -59,8 +93,8 @@ impl RenderSpan {
|
||||
|
||||
impl CodeSuggestion {
|
||||
/// Returns the assembled code suggestion.
|
||||
pub fn splice_lines(&self, cm: &CodeMap) -> String {
|
||||
use codemap::{CharPos, Loc, Pos};
|
||||
pub fn splice_lines(&self, cm: &CodeMapper) -> String {
|
||||
use syntax_pos::{CharPos, Loc, Pos};
|
||||
|
||||
fn push_trailing(buf: &mut String, line_opt: Option<&str>,
|
||||
lo: &Loc, hi_opt: Option<&Loc>) {
|
||||
@ -181,20 +215,20 @@ impl error::Error for ExplicitBug {
|
||||
#[derive(Clone)]
|
||||
pub struct DiagnosticBuilder<'a> {
|
||||
handler: &'a Handler,
|
||||
level: Level,
|
||||
message: String,
|
||||
code: Option<String>,
|
||||
span: MultiSpan,
|
||||
children: Vec<SubDiagnostic>,
|
||||
pub level: Level,
|
||||
pub message: String,
|
||||
pub code: Option<String>,
|
||||
pub span: MultiSpan,
|
||||
pub children: Vec<SubDiagnostic>,
|
||||
}
|
||||
|
||||
/// For example a note attached to an error.
|
||||
#[derive(Clone)]
|
||||
struct SubDiagnostic {
|
||||
level: Level,
|
||||
message: String,
|
||||
span: MultiSpan,
|
||||
render_span: Option<RenderSpan>,
|
||||
pub struct SubDiagnostic {
|
||||
pub level: Level,
|
||||
pub message: String,
|
||||
pub span: MultiSpan,
|
||||
pub render_span: Option<RenderSpan>,
|
||||
}
|
||||
|
||||
impl<'a> DiagnosticBuilder<'a> {
|
||||
@ -386,12 +420,13 @@ pub struct Handler {
|
||||
|
||||
impl Handler {
|
||||
pub fn with_tty_emitter(color_config: ColorConfig,
|
||||
registry: Option<diagnostics::registry::Registry>,
|
||||
registry: Option<registry::Registry>,
|
||||
can_emit_warnings: bool,
|
||||
treat_err_as_bug: bool,
|
||||
cm: Rc<codemap::CodeMap>)
|
||||
cm: Rc<CodeMapper>)
|
||||
-> Handler {
|
||||
let emitter = Box::new(EmitterWriter::stderr(color_config, registry, cm));
|
||||
let emitter = Box::new(EmitterWriter::stderr(color_config, registry, cm,
|
||||
snippet::FormatMode::EnvironmentSelected));
|
||||
Handler::with_emitter(can_emit_warnings, treat_err_as_bug, emitter)
|
||||
}
|
||||
|
||||
@ -662,7 +697,7 @@ impl fmt::Display for Level {
|
||||
}
|
||||
|
||||
impl Level {
|
||||
fn color(self) -> term::color::Color {
|
||||
pub fn color(self) -> term::color::Color {
|
||||
match self {
|
||||
Bug | Fatal | PhaseFatal | Error => term::color::BRIGHT_RED,
|
||||
Warning => term::color::YELLOW,
|
||||
@ -672,7 +707,7 @@ impl Level {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_str(self) -> &'static str {
|
||||
pub fn to_str(self) -> &'static str {
|
||||
match self {
|
||||
Bug => "error: internal compiler error",
|
||||
Fatal | PhaseFatal | Error => "error",
|
@ -10,18 +10,25 @@
|
||||
|
||||
// Code for annotating snippets.
|
||||
|
||||
use codemap::{CharPos, CodeMap, FileMap, LineInfo, Span};
|
||||
use errors::check_old_skool;
|
||||
use syntax_pos::{Span, FileMap, CharPos, LineInfo};
|
||||
use check_old_skool;
|
||||
use CodeMapper;
|
||||
use std::cmp;
|
||||
use std::rc::Rc;
|
||||
use std::mem;
|
||||
|
||||
mod test;
|
||||
#[derive(Clone)]
|
||||
pub enum FormatMode {
|
||||
NewErrorFormat,
|
||||
OriginalErrorFormat,
|
||||
EnvironmentSelected
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SnippetData {
|
||||
codemap: Rc<CodeMap>,
|
||||
codemap: Rc<CodeMapper>,
|
||||
files: Vec<FileInfo>,
|
||||
format_mode: FormatMode,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -36,6 +43,10 @@ pub struct FileInfo {
|
||||
primary_span: Option<Span>,
|
||||
|
||||
lines: Vec<Line>,
|
||||
|
||||
/// The type of error format to render. We keep it here so that
|
||||
/// it's easy to configure for both tests and regular usage
|
||||
format_mode: FormatMode,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -111,8 +122,9 @@ pub enum RenderedLineKind {
|
||||
}
|
||||
|
||||
impl SnippetData {
|
||||
pub fn new(codemap: Rc<CodeMap>,
|
||||
primary_span: Option<Span>) // (*)
|
||||
pub fn new(codemap: Rc<CodeMapper>,
|
||||
primary_span: Option<Span>,
|
||||
format_mode: FormatMode) // (*)
|
||||
-> Self {
|
||||
// (*) The primary span indicates the file that must appear
|
||||
// first, and which will have a line number etc in its
|
||||
@ -126,7 +138,8 @@ impl SnippetData {
|
||||
|
||||
let mut data = SnippetData {
|
||||
codemap: codemap.clone(),
|
||||
files: vec![]
|
||||
files: vec![],
|
||||
format_mode: format_mode.clone()
|
||||
};
|
||||
if let Some(primary_span) = primary_span {
|
||||
let lo = codemap.lookup_char_pos(primary_span.lo);
|
||||
@ -135,6 +148,7 @@ impl SnippetData {
|
||||
file: lo.file,
|
||||
primary_span: Some(primary_span),
|
||||
lines: vec![],
|
||||
format_mode: format_mode.clone(),
|
||||
});
|
||||
}
|
||||
data
|
||||
@ -167,6 +181,7 @@ impl SnippetData {
|
||||
file: file_map.clone(),
|
||||
lines: vec![],
|
||||
primary_span: None,
|
||||
format_mode: self.format_mode.clone()
|
||||
});
|
||||
self.files.last_mut().unwrap()
|
||||
}
|
||||
@ -178,7 +193,7 @@ impl SnippetData {
|
||||
self.files.iter()
|
||||
.flat_map(|f| f.render_file_lines(&self.codemap))
|
||||
.collect();
|
||||
prepend_prefixes(&mut rendered_lines);
|
||||
prepend_prefixes(&mut rendered_lines, &self.format_mode);
|
||||
trim_lines(&mut rendered_lines);
|
||||
rendered_lines
|
||||
}
|
||||
@ -454,8 +469,12 @@ impl FileInfo {
|
||||
return line_index - first_line_index;
|
||||
}
|
||||
|
||||
fn render_file_lines(&self, codemap: &Rc<CodeMap>) -> Vec<RenderedLine> {
|
||||
let old_school = check_old_skool();
|
||||
fn render_file_lines(&self, codemap: &Rc<CodeMapper>) -> Vec<RenderedLine> {
|
||||
let old_school = match self.format_mode {
|
||||
FormatMode::OriginalErrorFormat => true,
|
||||
FormatMode::NewErrorFormat => false,
|
||||
FormatMode::EnvironmentSelected => check_old_skool()
|
||||
};
|
||||
|
||||
// As a first step, we elide any instance of more than one
|
||||
// continuous unannotated line.
|
||||
@ -591,7 +610,12 @@ impl FileInfo {
|
||||
}
|
||||
|
||||
fn render_line(&self, line: &Line) -> Vec<RenderedLine> {
|
||||
let old_school = check_old_skool();
|
||||
let old_school = match self.format_mode {
|
||||
FormatMode::OriginalErrorFormat => true,
|
||||
FormatMode::NewErrorFormat => false,
|
||||
FormatMode::EnvironmentSelected => check_old_skool()
|
||||
};
|
||||
|
||||
let source_string = self.file.get_line(line.line_index)
|
||||
.unwrap_or("");
|
||||
let source_kind = RenderedLineKind::SourceText {
|
||||
@ -776,8 +800,12 @@ impl FileInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn prepend_prefixes(rendered_lines: &mut [RenderedLine]) {
|
||||
let old_school = check_old_skool();
|
||||
fn prepend_prefixes(rendered_lines: &mut [RenderedLine], format_mode: &FormatMode) {
|
||||
let old_school = match *format_mode {
|
||||
FormatMode::OriginalErrorFormat => true,
|
||||
FormatMode::NewErrorFormat => false,
|
||||
FormatMode::EnvironmentSelected => check_old_skool()
|
||||
};
|
||||
if old_school {
|
||||
return;
|
||||
}
|
@ -16,3 +16,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
serialize = { path = "../libserialize" }
|
||||
log = { path = "../liblog" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
@ -57,8 +57,8 @@ use std::fs::File;
|
||||
use std::io::Write;
|
||||
use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax_pos::Span;
|
||||
|
||||
const IF_THIS_CHANGED: &'static str = "rustc_if_this_changed";
|
||||
const THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need";
|
||||
|
@ -114,8 +114,8 @@ mod svh_visitor {
|
||||
pub use self::SawStmtComponent::*;
|
||||
use self::SawAbiComponent::*;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax_pos::Span;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::hir;
|
||||
use rustc::hir::*;
|
||||
|
@ -30,6 +30,7 @@ extern crate serialize as rustc_serialize;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
extern crate syntax_pos;
|
||||
|
||||
mod assert_dep_graph;
|
||||
mod calculate_svh;
|
||||
|
@ -15,7 +15,7 @@ use lint::{LintPass, LateLintPass};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::intravisit::FnKind;
|
||||
|
@ -45,7 +45,7 @@ use std::collections::HashSet;
|
||||
|
||||
use syntax::{ast};
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::intravisit::FnKind;
|
||||
@ -1140,9 +1140,9 @@ impl LateLintPass for DropWithReprExtern {
|
||||
if hints.iter().any(|attr| *attr == attr::ReprExtern) &&
|
||||
self_type_def.dtor_kind().has_drop_flag() {
|
||||
let drop_impl_span = ctx.tcx.map.def_id_span(drop_impl_did,
|
||||
codemap::DUMMY_SP);
|
||||
syntax_pos::DUMMY_SP);
|
||||
let self_defn_span = ctx.tcx.map.def_id_span(self_type_did,
|
||||
codemap::DUMMY_SP);
|
||||
syntax_pos::DUMMY_SP);
|
||||
ctx.span_lint_note(DROP_WITH_REPR_EXTERN,
|
||||
drop_impl_span,
|
||||
"implementing Drop adds hidden state to types, \
|
||||
|
@ -45,6 +45,7 @@ extern crate rustc;
|
||||
extern crate log;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate syntax_pos;
|
||||
|
||||
pub use rustc::lint as lint;
|
||||
pub use rustc::middle as middle;
|
||||
|
@ -27,7 +27,8 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax_pos::Span;
|
||||
use syntax::codemap;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
@ -19,9 +19,9 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc_back::slice;
|
||||
use rustc::hir;
|
||||
|
@ -16,6 +16,8 @@ rustc = { path = "../librustc" }
|
||||
rustc_back = { path = "../librustc_back" }
|
||||
rustc_bitflags = { path = "../librustc_bitflags" }
|
||||
rustc_const_math = { path = "../librustc_const_math" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_llvm = { path = "../librustc_llvm" }
|
||||
serialize = { path = "../libserialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
@ -37,9 +37,10 @@ use middle::region;
|
||||
use rustc::ty::subst;
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::ast;
|
||||
use syntax::ast::NodeIdAssigner;
|
||||
use syntax::ptr::P;
|
||||
use syntax_pos;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::io::SeekFrom;
|
||||
@ -115,7 +116,7 @@ impl<'a, 'b, 'c, 'tcx> ast_map::FoldOps for &'a DecodeContext<'b, 'c, 'tcx> {
|
||||
fn new_def_id(&self, def_id: DefId) -> DefId {
|
||||
self.tr_def_id(def_id)
|
||||
}
|
||||
fn new_span(&self, span: codemap::Span) -> codemap::Span {
|
||||
fn new_span(&self, span: syntax_pos::Span) -> syntax_pos::Span {
|
||||
self.tr_span(span)
|
||||
}
|
||||
}
|
||||
@ -206,7 +207,7 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
|
||||
|
||||
/// Translates a `Span` from an extern crate to the corresponding `Span`
|
||||
/// within the local crate's codemap.
|
||||
pub fn tr_span(&self, span: codemap::Span) -> codemap::Span {
|
||||
pub fn tr_span(&self, span: syntax_pos::Span) -> syntax_pos::Span {
|
||||
decoder::translate_span(self.cdata,
|
||||
self.tcx.sess.codemap(),
|
||||
&self.last_filemap_index,
|
||||
@ -226,8 +227,8 @@ impl tr for Option<DefId> {
|
||||
}
|
||||
}
|
||||
|
||||
impl tr for codemap::Span {
|
||||
fn tr(&self, dcx: &DecodeContext) -> codemap::Span {
|
||||
impl tr for syntax_pos::Span {
|
||||
fn tr(&self, dcx: &DecodeContext) -> syntax_pos::Span {
|
||||
dcx.tr_span(*self)
|
||||
}
|
||||
}
|
||||
@ -1268,7 +1269,7 @@ fn decode_item_ast(item_doc: rbml::Doc) -> hir::Item {
|
||||
|
||||
#[cfg(test)]
|
||||
trait FakeExtCtxt {
|
||||
fn call_site(&self) -> codemap::Span;
|
||||
fn call_site(&self) -> syntax_pos::Span;
|
||||
fn cfg(&self) -> ast::CrateConfig;
|
||||
fn ident_of(&self, st: &str) -> ast::Ident;
|
||||
fn name_of(&self, st: &str) -> ast::Name;
|
||||
@ -1277,11 +1278,11 @@ trait FakeExtCtxt {
|
||||
|
||||
#[cfg(test)]
|
||||
impl FakeExtCtxt for parse::ParseSess {
|
||||
fn call_site(&self) -> codemap::Span {
|
||||
codemap::Span {
|
||||
lo: codemap::BytePos(0),
|
||||
hi: codemap::BytePos(0),
|
||||
expn_id: codemap::NO_EXPANSION,
|
||||
fn call_site(&self) -> syntax_pos::Span {
|
||||
syntax_pos::Span {
|
||||
lo: syntax_pos::BytePos(0),
|
||||
hi: syntax_pos::BytePos(0),
|
||||
expn_id: syntax_pos::NO_EXPANSION,
|
||||
}
|
||||
}
|
||||
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
|
||||
|
@ -34,12 +34,13 @@ use std::fs;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::codemap::{self, Span, mk_sp, Pos};
|
||||
use syntax::codemap;
|
||||
use syntax::parse;
|
||||
use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::visit;
|
||||
use syntax_pos::{self, Span, mk_sp, Pos};
|
||||
use log;
|
||||
|
||||
struct LocalCrateReader<'a> {
|
||||
@ -726,7 +727,7 @@ impl<'a> CrateReader<'a> {
|
||||
info!("panic runtime not found -- loading {}", name);
|
||||
|
||||
let (cnum, data, _) = self.resolve_crate(&None, name, name, None,
|
||||
codemap::DUMMY_SP,
|
||||
syntax_pos::DUMMY_SP,
|
||||
PathKind::Crate, false);
|
||||
|
||||
// Sanity check the loaded crate to ensure it is indeed a panic runtime
|
||||
@ -807,7 +808,7 @@ impl<'a> CrateReader<'a> {
|
||||
&self.sess.target.target.options.exe_allocation_crate
|
||||
};
|
||||
let (cnum, data, _) = self.resolve_crate(&None, name, name, None,
|
||||
codemap::DUMMY_SP,
|
||||
syntax_pos::DUMMY_SP,
|
||||
PathKind::Crate, false);
|
||||
|
||||
// Sanity check the crate we loaded to ensure that it is indeed an
|
||||
@ -1076,7 +1077,7 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
|
||||
None => {
|
||||
// We can't reuse an existing FileMap, so allocate a new one
|
||||
// containing the information we need.
|
||||
let codemap::FileMap {
|
||||
let syntax_pos::FileMap {
|
||||
name,
|
||||
abs_path,
|
||||
start_pos,
|
||||
@ -1118,8 +1119,8 @@ pub fn import_codemap(local_codemap: &codemap::CodeMap,
|
||||
|
||||
return imported_filemaps;
|
||||
|
||||
fn are_equal_modulo_startpos(fm1: &codemap::FileMap,
|
||||
fm2: &codemap::FileMap)
|
||||
fn are_equal_modulo_startpos(fm1: &syntax_pos::FileMap,
|
||||
fm2: &syntax_pos::FileMap)
|
||||
-> bool {
|
||||
if fm1.name != fm2.name {
|
||||
return false;
|
||||
|
@ -36,6 +36,7 @@ use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap;
|
||||
use syntax::parse::token::IdentInterner;
|
||||
use syntax_pos;
|
||||
|
||||
pub use middle::cstore::{NativeLibraryKind, LinkagePreference};
|
||||
pub use middle::cstore::{NativeStatic, NativeFramework, NativeUnknown};
|
||||
@ -52,15 +53,15 @@ pub enum MetadataBlob {
|
||||
MetadataArchive(loader::ArchiveMetadata),
|
||||
}
|
||||
|
||||
/// Holds information about a codemap::FileMap imported from another crate.
|
||||
/// Holds information about a syntax_pos::FileMap imported from another crate.
|
||||
/// See creader::import_codemap() for more information.
|
||||
pub struct ImportedFileMap {
|
||||
/// This FileMap's byte-offset within the codemap of its original crate
|
||||
pub original_start_pos: codemap::BytePos,
|
||||
pub original_start_pos: syntax_pos::BytePos,
|
||||
/// The end of this FileMap within the codemap of its original crate
|
||||
pub original_end_pos: codemap::BytePos,
|
||||
pub original_end_pos: syntax_pos::BytePos,
|
||||
/// The imported FileMap's representation within the local codemap
|
||||
pub translated_filemap: Rc<codemap::FileMap>
|
||||
pub translated_filemap: Rc<syntax_pos::FileMap>
|
||||
}
|
||||
|
||||
pub struct crate_metadata {
|
||||
|
@ -56,10 +56,10 @@ use syntax::attr;
|
||||
use syntax::parse::token::{self, IdentInterner};
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::codemap::{self, Span, BytePos, NO_EXPANSION};
|
||||
use syntax::codemap;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
|
||||
use syntax_pos::{self, Span, BytePos, NO_EXPANSION};
|
||||
|
||||
pub type Cmd<'a> = &'a crate_metadata;
|
||||
|
||||
@ -1230,7 +1230,7 @@ fn get_attributes(md: rbml::Doc) -> Vec<ast::Attribute> {
|
||||
value: meta_item,
|
||||
is_sugared_doc: is_sugared_doc,
|
||||
},
|
||||
span: codemap::DUMMY_SP
|
||||
span: syntax_pos::DUMMY_SP
|
||||
}
|
||||
}).collect()
|
||||
},
|
||||
@ -1380,8 +1380,8 @@ fn reverse_translate_def_id(cdata: Cmd, did: DefId) -> Option<DefId> {
|
||||
pub fn translate_span(cdata: Cmd,
|
||||
codemap: &codemap::CodeMap,
|
||||
last_filemap_index_hint: &Cell<usize>,
|
||||
span: codemap::Span)
|
||||
-> codemap::Span {
|
||||
span: syntax_pos::Span)
|
||||
-> syntax_pos::Span {
|
||||
let span = if span.lo > span.hi {
|
||||
// Currently macro expansion sometimes produces invalid Span values
|
||||
// where lo > hi. In order not to crash the compiler when trying to
|
||||
@ -1390,7 +1390,7 @@ pub fn translate_span(cdata: Cmd,
|
||||
// least some of the time).
|
||||
// This workaround is only necessary as long as macro expansion is
|
||||
// not fixed. FIXME(#23480)
|
||||
codemap::mk_sp(span.lo, span.lo)
|
||||
syntax_pos::mk_sp(span.lo, span.lo)
|
||||
} else {
|
||||
span
|
||||
};
|
||||
@ -1430,7 +1430,7 @@ pub fn translate_span(cdata: Cmd,
|
||||
let hi = (span.hi - filemap.original_start_pos) +
|
||||
filemap.translated_filemap.start_pos;
|
||||
|
||||
codemap::mk_sp(lo, hi)
|
||||
syntax_pos::mk_sp(lo, hi)
|
||||
}
|
||||
|
||||
pub fn each_inherent_implementation_for_type<F>(cdata: Cmd,
|
||||
@ -1733,7 +1733,7 @@ pub fn is_default_impl(cdata: Cmd, impl_id: DefIndex) -> bool {
|
||||
item_family(impl_doc) == Family::DefaultImpl
|
||||
}
|
||||
|
||||
pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<codemap::FileMap> {
|
||||
pub fn get_imported_filemaps(metadata: &[u8]) -> Vec<syntax_pos::FileMap> {
|
||||
let crate_doc = rbml::Doc::new(metadata);
|
||||
let cm_doc = reader::get_doc(crate_doc, tag_codemap);
|
||||
|
||||
|
@ -44,10 +44,10 @@ use std::rc::Rc;
|
||||
use std::u32;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast::{self, NodeId, Name, CRATE_NODE_ID, CrateNum};
|
||||
use syntax::codemap::BytePos;
|
||||
use syntax::attr;
|
||||
use syntax::errors::Handler;
|
||||
use errors::Handler;
|
||||
use syntax;
|
||||
use syntax_pos::BytePos;
|
||||
use rbml::writer::Encoder;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
@ -28,10 +28,11 @@
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
||||
|
||||
extern crate syntax_pos;
|
||||
extern crate flate;
|
||||
extern crate rbml;
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
extern crate rustc_errors as errors;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
|
@ -225,8 +225,8 @@ use rustc::util::common;
|
||||
use rustc_llvm as llvm;
|
||||
use rustc_llvm::{False, ObjectFile, mk_section_iter};
|
||||
use rustc_llvm::archive_ro::ArchiveRO;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::errors::DiagnosticBuilder;
|
||||
use errors::DiagnosticBuilder;
|
||||
use syntax_pos::Span;
|
||||
use rustc_back::target::Target;
|
||||
|
||||
use std::cmp;
|
||||
|
@ -16,12 +16,12 @@ use cstore::CStore;
|
||||
use rustc::session::Session;
|
||||
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::ext;
|
||||
use syntax_pos::Span;
|
||||
|
||||
pub struct MacroLoader<'a> {
|
||||
sess: &'a Session,
|
||||
|
@ -29,7 +29,7 @@ use rustc::hir;
|
||||
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::errors::Handler;
|
||||
use errors::Handler;
|
||||
|
||||
use rbml::leb128;
|
||||
use encoder;
|
||||
|
@ -24,7 +24,7 @@ use rustc::middle::const_val::ConstVal;
|
||||
use rustc::ty;
|
||||
use rustc::mir::repr::*;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
/// Compile `expr`, yielding an rvalue.
|
||||
|
@ -13,7 +13,7 @@ use build::scope::LoopScope;
|
||||
use hair::*;
|
||||
use rustc::middle::region::CodeExtent;
|
||||
use rustc::mir::repr::*;
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
|
@ -21,7 +21,7 @@ use rustc::ty::{AdtDef, Ty};
|
||||
use rustc::mir::repr::*;
|
||||
use hair::*;
|
||||
use syntax::ast::{Name, NodeId};
|
||||
use syntax::codemap::Span;
|
||||
use syntax_pos::Span;
|
||||
|
||||
// helper functions, broken out by category:
|
||||
mod simplify;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user