mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 09:53:26 +00:00
Auto merge of #68101 - JohnTitor:rollup-mvmjukr, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #66045 (Add method Result::into_ok) - #67258 (Introduce `X..`, `..X`, and `..=X` range patterns) - #68014 (Unify output of "variant not found" errors) - #68019 (Build compiletest with in-tree libtest) - #68039 (remove explicit strip-hidden pass from compiler doc generation) - #68050 (Canonicalize rustc_error imports) - #68059 (Allow specifying LLVM args in target specifications) - #68075 (rustbuild: Cleanup book generation) Failed merges: - #68089 (Unstabilize `Vec::remove_item`) r? @ghost
This commit is contained in:
commit
1756313117
@ -3654,6 +3654,7 @@ dependencies = [
|
||||
"log",
|
||||
"rustc",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_feature",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
|
@ -49,7 +49,7 @@ macro_rules! book {
|
||||
builder.ensure(RustbookSrc {
|
||||
target: self.target,
|
||||
name: INTERNER.intern_str($book_name),
|
||||
src: doc_src(builder),
|
||||
src: INTERNER.intern_path(builder.src.join($path)),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -60,6 +60,7 @@ macro_rules! book {
|
||||
// NOTE: When adding a book here, make sure to ALSO build the book by
|
||||
// adding a build step in `src/bootstrap/builder.rs`!
|
||||
book!(
|
||||
CargoBook, "src/tools/cargo/src/doc", "cargo";
|
||||
EditionGuide, "src/doc/edition-guide", "edition-guide";
|
||||
EmbeddedBook, "src/doc/embedded-book", "embedded-book";
|
||||
Nomicon, "src/doc/nomicon", "nomicon";
|
||||
@ -69,10 +70,6 @@ book!(
|
||||
RustdocBook, "src/doc/rustdoc", "rustdoc";
|
||||
);
|
||||
|
||||
fn doc_src(builder: &Builder<'_>) -> Interned<PathBuf> {
|
||||
INTERNER.intern_path(builder.src.join("src/doc"))
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct UnstableBook {
|
||||
target: Interned<String>,
|
||||
@ -96,48 +93,11 @@ impl Step for UnstableBook {
|
||||
builder.ensure(RustbookSrc {
|
||||
target: self.target,
|
||||
name: INTERNER.intern_str("unstable-book"),
|
||||
src: builder.md_doc_out(self.target),
|
||||
src: INTERNER.intern_path(builder.md_doc_out(self.target).join("unstable-book")),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct CargoBook {
|
||||
target: Interned<String>,
|
||||
name: Interned<String>,
|
||||
}
|
||||
|
||||
impl Step for CargoBook {
|
||||
type Output = ();
|
||||
const DEFAULT: bool = true;
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
let builder = run.builder;
|
||||
run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs)
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(CargoBook { target: run.target, name: INTERNER.intern_str("cargo") });
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let target = self.target;
|
||||
let name = self.name;
|
||||
let src = builder.src.join("src/tools/cargo/src/doc");
|
||||
|
||||
let out = builder.doc_out(target);
|
||||
t!(fs::create_dir_all(&out));
|
||||
|
||||
let out = out.join(name);
|
||||
|
||||
builder.info(&format!("Cargo Book ({}) - {}", target, name));
|
||||
|
||||
let _ = fs::remove_dir_all(&out);
|
||||
|
||||
builder.run(builder.tool_cmd(Tool::Rustbook).arg("build").arg(&src).arg("-d").arg(out));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
struct RustbookSrc {
|
||||
target: Interned<String>,
|
||||
@ -164,7 +124,6 @@ impl Step for RustbookSrc {
|
||||
t!(fs::create_dir_all(&out));
|
||||
|
||||
let out = out.join(name);
|
||||
let src = src.join(name);
|
||||
let index = out.join("index.html");
|
||||
let rustbook = builder.tool_exe(Tool::Rustbook);
|
||||
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
||||
@ -182,7 +141,6 @@ impl Step for RustbookSrc {
|
||||
pub struct TheBook {
|
||||
compiler: Compiler,
|
||||
target: Interned<String>,
|
||||
name: &'static str,
|
||||
}
|
||||
|
||||
impl Step for TheBook {
|
||||
@ -198,7 +156,6 @@ impl Step for TheBook {
|
||||
run.builder.ensure(TheBook {
|
||||
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
|
||||
target: run.target,
|
||||
name: "book",
|
||||
});
|
||||
}
|
||||
|
||||
@ -206,45 +163,30 @@ impl Step for TheBook {
|
||||
///
|
||||
/// We need to build:
|
||||
///
|
||||
/// * Book (first edition)
|
||||
/// * Book (second edition)
|
||||
/// * Book
|
||||
/// * Older edition redirects
|
||||
/// * Version info and CSS
|
||||
/// * Index page
|
||||
/// * Redirect pages
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let compiler = self.compiler;
|
||||
let target = self.target;
|
||||
let name = self.name;
|
||||
|
||||
// build book
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(name.to_string()),
|
||||
src: doc_src(builder),
|
||||
name: INTERNER.intern_str("book"),
|
||||
src: INTERNER.intern_path(builder.src.join("src/doc/book")),
|
||||
});
|
||||
|
||||
// building older edition redirects
|
||||
|
||||
let source_name = format!("{}/first-edition", name);
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(source_name),
|
||||
src: doc_src(builder),
|
||||
});
|
||||
|
||||
let source_name = format!("{}/second-edition", name);
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(source_name),
|
||||
src: doc_src(builder),
|
||||
});
|
||||
|
||||
let source_name = format!("{}/2018-edition", name);
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(source_name),
|
||||
src: doc_src(builder),
|
||||
});
|
||||
for edition in &["first-edition", "second-edition", "2018-edition"] {
|
||||
builder.ensure(RustbookSrc {
|
||||
target,
|
||||
name: INTERNER.intern_string(format!("book/{}", edition)),
|
||||
src: INTERNER.intern_path(builder.src.join("src/doc/book").join(edition)),
|
||||
});
|
||||
}
|
||||
|
||||
// build the version info page and CSS
|
||||
builder.ensure(Standalone { compiler, target });
|
||||
@ -531,7 +473,7 @@ impl Step for Rustc {
|
||||
|
||||
// Build cargo command.
|
||||
let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc");
|
||||
cargo.env("RUSTDOCFLAGS", "--document-private-items --passes strip-hidden");
|
||||
cargo.env("RUSTDOCFLAGS", "--document-private-items");
|
||||
compile::rustc_cargo(builder, &mut cargo, target);
|
||||
|
||||
// Only include compiler crates, no dependencies of those, such as `libc`.
|
||||
|
@ -289,8 +289,8 @@ fn rustbook_features() -> Vec<String> {
|
||||
macro_rules! bootstrap_tool {
|
||||
($(
|
||||
$name:ident, $path:expr, $tool_name:expr
|
||||
$(,llvm_tools = $llvm:expr)*
|
||||
$(,is_external_tool = $external:expr)*
|
||||
$(,is_unstable_tool = $unstable:expr)*
|
||||
$(,features = $features:expr)*
|
||||
;
|
||||
)+) => {
|
||||
@ -301,15 +301,6 @@ macro_rules! bootstrap_tool {
|
||||
)+
|
||||
}
|
||||
|
||||
impl Tool {
|
||||
/// Whether this tool requires LLVM to run
|
||||
pub fn uses_llvm_tools(&self) -> bool {
|
||||
match self {
|
||||
$(Tool::$name => false $(|| $llvm)*,)+
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Builder<'a> {
|
||||
pub fn tool_exe(&self, tool: Tool) -> PathBuf {
|
||||
match tool {
|
||||
@ -350,7 +341,12 @@ macro_rules! bootstrap_tool {
|
||||
compiler: self.compiler,
|
||||
target: self.target,
|
||||
tool: $tool_name,
|
||||
mode: Mode::ToolBootstrap,
|
||||
mode: if false $(|| $unstable)* {
|
||||
// use in-tree libraries for unstable features
|
||||
Mode::ToolStd
|
||||
} else {
|
||||
Mode::ToolBootstrap
|
||||
},
|
||||
path: $path,
|
||||
is_optional_tool: false,
|
||||
source_type: if false $(|| $external)* {
|
||||
@ -377,7 +373,7 @@ bootstrap_tool!(
|
||||
Tidy, "src/tools/tidy", "tidy";
|
||||
Linkchecker, "src/tools/linkchecker", "linkchecker";
|
||||
CargoTest, "src/tools/cargotest", "cargotest";
|
||||
Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
|
||||
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true;
|
||||
BuildManifest, "src/tools/build-manifest", "build-manifest";
|
||||
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
|
||||
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
|
||||
|
@ -1092,6 +1092,44 @@ impl<T: Default, E> Result<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "unwrap_infallible", reason = "newly added", issue = "61695")]
|
||||
impl<T, E: Into<!>> Result<T, E> {
|
||||
/// Unwraps a result that can never be an [`Err`], yielding the content of the [`Ok`].
|
||||
///
|
||||
/// Unlike [`unwrap`], this method is known to never panic on the
|
||||
/// result types it is implemented for. Therefore, it can be used
|
||||
/// instead of `unwrap` as a maintainability safeguard that will fail
|
||||
/// to compile if the error type of the `Result` is later changed
|
||||
/// to an error that can actually occur.
|
||||
///
|
||||
/// [`Ok`]: enum.Result.html#variant.Ok
|
||||
/// [`Err`]: enum.Result.html#variant.Err
|
||||
/// [`unwrap`]: enum.Result.html#method.unwrap
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// # #![feature(never_type)]
|
||||
/// # #![feature(unwrap_infallible)]
|
||||
///
|
||||
/// fn only_good_news() -> Result<String, !> {
|
||||
/// Ok("this is fine".into())
|
||||
/// }
|
||||
///
|
||||
/// let s: String = only_good_news().into_ok();
|
||||
/// println!("{}", s);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn into_ok(self) -> T {
|
||||
match self {
|
||||
Ok(x) => x,
|
||||
Err(e) => e.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
|
||||
impl<T: Deref, E> Result<T, E> {
|
||||
/// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E>`.
|
||||
|
@ -40,6 +40,8 @@
|
||||
#![feature(slice_from_raw_parts)]
|
||||
#![feature(const_slice_from_raw_parts)]
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(never_type)]
|
||||
#![feature(unwrap_infallible)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
|
@ -183,6 +183,28 @@ pub fn test_unwrap_or_default() {
|
||||
assert_eq!(op2().unwrap_or_default(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_into_ok() {
|
||||
fn infallible_op() -> Result<isize, !> {
|
||||
Ok(666)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op().into_ok(), 666);
|
||||
|
||||
enum MyNeverToken {}
|
||||
impl From<MyNeverToken> for ! {
|
||||
fn from(never: MyNeverToken) -> ! {
|
||||
match never {}
|
||||
}
|
||||
}
|
||||
|
||||
fn infallible_op2() -> Result<isize, MyNeverToken> {
|
||||
Ok(667)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op2().into_ok(), 667);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_try() {
|
||||
fn try_result_some() -> Option<u8> {
|
||||
|
@ -26,8 +26,8 @@ rustc_hir = { path = "../librustc_hir" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
rustc_macros = { path = "../librustc_macros" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use errors::Diagnostic;
|
||||
use parking_lot::{Condvar, Mutex};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::profiling::QueryInvocationId;
|
||||
use rustc_data_structures::sharded::{self, Sharded};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -9,8 +9,8 @@ use crate::lint::builtin::UNUSED_ATTRIBUTES;
|
||||
use crate::ty::query::Providers;
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
|
@ -64,15 +64,13 @@ use crate::ty::{
|
||||
subst::{Subst, SubstsRef},
|
||||
Region, Ty, TyCtxt, TypeFoldable,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::{pluralize, struct_span_err};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::Node;
|
||||
|
||||
use errors::{
|
||||
pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_error_codes::*;
|
||||
use rustc_span::{DesugaringKind, Pos, Span};
|
||||
use rustc_target::spec::abi;
|
||||
use std::{cmp, fmt};
|
||||
|
@ -3,7 +3,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::ty::print::Print;
|
||||
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
|
||||
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
@ -151,12 +151,12 @@ pub enum TypeAnnotationNeeded {
|
||||
E0284,
|
||||
}
|
||||
|
||||
impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
|
||||
fn into(self) -> errors::DiagnosticId {
|
||||
impl Into<rustc_errors::DiagnosticId> for TypeAnnotationNeeded {
|
||||
fn into(self) -> rustc_errors::DiagnosticId {
|
||||
match self {
|
||||
Self::E0282 => errors::error_code!(E0282),
|
||||
Self::E0283 => errors::error_code!(E0283),
|
||||
Self::E0284 => errors::error_code!(E0284),
|
||||
Self::E0282 => rustc_errors::error_code!(E0282),
|
||||
Self::E0283 => rustc_errors::error_code!(E0283),
|
||||
Self::E0284 => rustc_errors::error_code!(E0284),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::util::common::ErrorReported;
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::struct_span_err;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Print the error message for lifetime errors when both the concerned regions are anonymous.
|
||||
|
@ -3,7 +3,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError::*;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use crate::util::common::ErrorReported;
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_span::source_map::Span;
|
||||
|
||||
mod different_lifetimes;
|
||||
|
@ -2,7 +2,7 @@
|
||||
//! where one region is named and the other is anonymous.
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::ty;
|
||||
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir::{FunctionRetTy, TyKind};
|
||||
|
||||
use rustc_error_codes::*;
|
||||
|
@ -7,7 +7,7 @@ use crate::ty::error::ExpectedFound;
|
||||
use crate::ty::print::{FmtPrinter, Print, RegionHighlightMode};
|
||||
use crate::ty::subst::SubstsRef;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
|
@ -5,7 +5,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::ty::{BoundRegion, FreeRegion, RegionKind};
|
||||
use crate::util::common::ErrorReported;
|
||||
use errors::Applicability;
|
||||
use rustc_errors::Applicability;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Print the error message for lifetime errors when the return type is a static impl Trait.
|
||||
|
@ -3,7 +3,7 @@ use crate::infer::{self, InferCtxt, SubregionOrigin};
|
||||
use crate::middle::region;
|
||||
use crate::ty::error::TypeError;
|
||||
use crate::ty::{self, Region};
|
||||
use errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
|
||||
use rustc_error_codes::*;
|
||||
|
||||
|
@ -21,10 +21,10 @@ use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef};
|
||||
use crate::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
|
||||
use crate::ty::{ConstVid, FloatVid, IntVid, TyVid};
|
||||
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::unify as ut;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
@ -6,10 +6,10 @@ use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use crate::ty::free_region_map::FreeRegionRelations;
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef};
|
||||
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
|
||||
use errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc::session::config::nightly_options;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, DefIdMap};
|
||||
use rustc_hir::Node;
|
||||
|
@ -7,7 +7,7 @@
|
||||
use crate::lint::{FutureIncompatibleInfo, LateLintPass, LintArray, LintPass};
|
||||
use crate::middle::stability;
|
||||
use crate::session::Session;
|
||||
use errors::{pluralize, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
|
||||
use rustc_session::declare_lint;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Span;
|
||||
|
@ -25,10 +25,10 @@ use crate::middle::privacy::AccessLevels;
|
||||
use crate::session::Session;
|
||||
use crate::ty::layout::{LayoutError, LayoutOf, TyLayout};
|
||||
use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
|
||||
use errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||
|
@ -4,8 +4,8 @@
|
||||
use crate::lint::{
|
||||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass,
|
||||
};
|
||||
use errors::Applicability;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{GenericArg, HirId, MutTy, Mutability, Path, PathSegment, QPath, Ty, TyKind};
|
||||
use rustc_session::declare_tool_lint;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
@ -5,9 +5,9 @@ use crate::lint::builtin;
|
||||
use crate::lint::context::{CheckLintNameResult, LintStore};
|
||||
use crate::lint::{self, Level, Lint, LintId, LintSource};
|
||||
use crate::session::Session;
|
||||
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_span::source_map::MultiSpan;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
|
@ -23,8 +23,8 @@ pub use self::LintSource::*;
|
||||
|
||||
use crate::lint::builtin::BuiltinLintDiagnostics;
|
||||
use crate::ty::TyCtxt;
|
||||
use errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_hir as hir;
|
||||
use rustc_session::node_id::NodeMap;
|
||||
use rustc_session::{DiagnosticMessageId, Session};
|
||||
|
@ -14,8 +14,8 @@ use crate::middle::cstore::ExternCrate;
|
||||
use crate::middle::weak_lang_items;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
@ -7,8 +7,8 @@ use crate::lint::builtin::BuiltinLintDiagnostics;
|
||||
use crate::lint::{self, in_derive_expansion, Lint};
|
||||
use crate::session::{DiagnosticMessageId, Session};
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_feature::GateIssue;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
@ -18,7 +18,6 @@ use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
use syntax::ast::CRATE_NODE_ID;
|
||||
use syntax::attr::{self, ConstStability, Deprecation, RustcDeprecation, Stability};
|
||||
use syntax::errors::Applicability;
|
||||
use syntax::feature_gate::feature_err_issue;
|
||||
|
||||
use std::num::NonZeroU32;
|
||||
|
@ -5,8 +5,8 @@ use crate::session::config;
|
||||
|
||||
use crate::hir::map::Map;
|
||||
use crate::ty::TyCtxt;
|
||||
use errors::struct_span_err;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
|
@ -7,8 +7,8 @@ use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::{self, layout, Ty};
|
||||
|
||||
use backtrace::Backtrace;
|
||||
use errors::{struct_span_err, DiagnosticBuilder};
|
||||
use hir::GeneratorKind;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
@ -38,7 +38,7 @@ pub struct OverlapResult<'tcx> {
|
||||
pub involves_placeholder: bool,
|
||||
}
|
||||
|
||||
pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) {
|
||||
pub fn add_placeholder_note(err: &mut rustc_errors::DiagnosticBuilder<'_>) {
|
||||
err.note(&format!(
|
||||
"this behavior recently changed as a result of a bug fix; \
|
||||
see rust-lang/rust#56105 for details"
|
||||
|
@ -21,8 +21,8 @@ use crate::ty::SubtypePredicate;
|
||||
use crate::ty::TypeckTables;
|
||||
use crate::ty::{self, AdtKind, DefIdTree, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
|
||||
|
||||
use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::Node;
|
||||
|
@ -3,8 +3,8 @@ use fmt_macros::{Parser, Piece, Position};
|
||||
use crate::ty::{self, GenericParamDefKind, TyCtxt};
|
||||
use crate::util::common::ErrorReported;
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
@ -76,7 +76,7 @@ pub struct DropckOutlivesResult<'tcx> {
|
||||
impl<'tcx> DropckOutlivesResult<'tcx> {
|
||||
pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
|
||||
if let Some(overflow_ty) = self.overflows.iter().next() {
|
||||
errors::struct_span_err!(
|
||||
rustc_errors::struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
E0320,
|
||||
|
@ -102,7 +102,7 @@ pub enum IntercrateAmbiguityCause {
|
||||
impl IntercrateAmbiguityCause {
|
||||
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
|
||||
/// See #23980 for details.
|
||||
pub fn add_intercrate_ambiguity_hint(&self, err: &mut errors::DiagnosticBuilder<'_>) {
|
||||
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
|
||||
err.note(&self.intercrate_ambiguity_hint());
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ use crate::traits::select::IntercrateAmbiguityCause;
|
||||
use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine};
|
||||
use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::{self, TyCtxt, TypeFoldable};
|
||||
use errors::struct_span_err;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_span::Span;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
@ -51,7 +51,6 @@ use rustc_hir::{HirId, Node, TraitCandidate};
|
||||
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
|
||||
|
||||
use arena::SyncDroplessArena;
|
||||
use errors::DiagnosticBuilder;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||
use rustc_data_structures::sharded::ShardedHashMap;
|
||||
@ -59,6 +58,7 @@ use rustc_data_structures::stable_hasher::{
|
||||
hash_stable_hashmap, HashStable, StableHasher, StableVec,
|
||||
};
|
||||
use rustc_data_structures::sync::{Lock, Lrc, WorkerLocal};
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::node_id::NodeMap;
|
||||
@ -1613,10 +1613,10 @@ pub mod tls {
|
||||
|
||||
use crate::dep_graph::TaskDeps;
|
||||
use crate::ty::query;
|
||||
use errors::Diagnostic;
|
||||
use rustc_data_structures::sync::{self, Lock, Lrc};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_data_structures::OnDrop;
|
||||
use rustc_errors::Diagnostic;
|
||||
use std::mem;
|
||||
|
||||
#[cfg(not(parallel_compiler))]
|
||||
|
@ -1,12 +1,10 @@
|
||||
use crate::ty::{self, BoundRegion, Region, Ty, TyCtxt};
|
||||
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::abi;
|
||||
use syntax::ast;
|
||||
use syntax::errors::pluralize;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
@ -7,10 +7,10 @@ use crate::session::{CrateDisambiguator, Session};
|
||||
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
|
||||
use crate::ty::context::TyCtxt;
|
||||
use crate::ty::{self, Ty};
|
||||
use errors::Diagnostic;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::{HashMapExt, Lock, Lrc, Once};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
|
@ -9,7 +9,6 @@ use crate::ty::query::Query;
|
||||
use crate::ty::tls;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
|
||||
use errors::{struct_span_err, Diagnostic, DiagnosticBuilder, FatalError, Handler, Level};
|
||||
#[cfg(not(parallel_compiler))]
|
||||
use rustc_data_structures::cold_path;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHasher};
|
||||
@ -18,6 +17,7 @@ use rustc_data_structures::profiling::TimingGuard;
|
||||
use rustc_data_structures::sharded::Sharded;
|
||||
use rustc_data_structures::sync::{Lock, Lrc};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, FatalError, Handler, Level};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_span::Span;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -3,18 +3,18 @@
|
||||
use crate::hir::map::DefPathData;
|
||||
use crate::ich::NodeIdHashingMode;
|
||||
use crate::mir::interpret::{sign_extend, truncate};
|
||||
use crate::ty::layout::{Integer, IntegerExt};
|
||||
use crate::ty::layout::{Integer, IntegerExt, Size};
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{self, DefIdTree, GenericParamDefKind, Ty, TyCtxt, TypeFoldable};
|
||||
use crate::util::common::ErrorReported;
|
||||
use rustc_apfloat::Float as _;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::Span;
|
||||
use std::{cmp, fmt};
|
||||
@ -43,26 +43,38 @@ impl<'tcx> fmt::Display for Discr<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn signed_min(size: Size) -> i128 {
|
||||
sign_extend(1_u128 << (size.bits() - 1), size) as i128
|
||||
}
|
||||
|
||||
fn signed_max(size: Size) -> i128 {
|
||||
i128::max_value() >> (128 - size.bits())
|
||||
}
|
||||
|
||||
fn unsigned_max(size: Size) -> u128 {
|
||||
u128::max_value() >> (128 - size.bits())
|
||||
}
|
||||
|
||||
fn int_size_and_signed<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (Size, bool) {
|
||||
let (int, signed) = match ty.kind {
|
||||
Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true),
|
||||
Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false),
|
||||
_ => bug!("non integer discriminant"),
|
||||
};
|
||||
(int.size(), signed)
|
||||
}
|
||||
|
||||
impl<'tcx> Discr<'tcx> {
|
||||
/// Adds `1` to the value and wraps around if the maximum for the type is reached.
|
||||
pub fn wrap_incr(self, tcx: TyCtxt<'tcx>) -> Self {
|
||||
self.checked_add(tcx, 1).0
|
||||
}
|
||||
pub fn checked_add(self, tcx: TyCtxt<'tcx>, n: u128) -> (Self, bool) {
|
||||
let (int, signed) = match self.ty.kind {
|
||||
Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true),
|
||||
Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false),
|
||||
_ => bug!("non integer discriminant"),
|
||||
};
|
||||
|
||||
let size = int.size();
|
||||
let bit_size = int.size().bits();
|
||||
let shift = 128 - bit_size;
|
||||
if signed {
|
||||
let sext = |u| sign_extend(u, size) as i128;
|
||||
let min = sext(1_u128 << (bit_size - 1));
|
||||
let max = i128::max_value() >> shift;
|
||||
let val = sext(self.val);
|
||||
let (size, signed) = int_size_and_signed(tcx, self.ty);
|
||||
let (val, oflo) = if signed {
|
||||
let min = signed_min(size);
|
||||
let max = signed_max(size);
|
||||
let val = sign_extend(self.val, size) as i128;
|
||||
assert!(n < (i128::max_value() as u128));
|
||||
let n = n as i128;
|
||||
let oflo = val > max - n;
|
||||
@ -70,14 +82,15 @@ impl<'tcx> Discr<'tcx> {
|
||||
// zero the upper bits
|
||||
let val = val as u128;
|
||||
let val = truncate(val, size);
|
||||
(Self { val: val as u128, ty: self.ty }, oflo)
|
||||
(val, oflo)
|
||||
} else {
|
||||
let max = u128::max_value() >> shift;
|
||||
let max = unsigned_max(size);
|
||||
let val = self.val;
|
||||
let oflo = val > max - n;
|
||||
let val = if oflo { n - (max - val) - 1 } else { val + n };
|
||||
(Self { val: val, ty: self.ty }, oflo)
|
||||
}
|
||||
(val, oflo)
|
||||
};
|
||||
(Self { val, ty: self.ty }, oflo)
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,6 +634,44 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> ty::TyS<'tcx> {
|
||||
/// Returns the maximum value for the given numeric type (including `char`s)
|
||||
/// or returns `None` if the type is not numeric.
|
||||
pub fn numeric_max_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
let val = match self.kind {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
let val = if signed { signed_max(size) as u128 } else { unsigned_max(size) };
|
||||
Some(val)
|
||||
}
|
||||
ty::Char => Some(std::char::MAX as u128),
|
||||
ty::Float(fty) => Some(match fty {
|
||||
ast::FloatTy::F32 => ::rustc_apfloat::ieee::Single::INFINITY.to_bits(),
|
||||
ast::FloatTy::F64 => ::rustc_apfloat::ieee::Double::INFINITY.to_bits(),
|
||||
}),
|
||||
_ => None,
|
||||
};
|
||||
val.map(|v| ty::Const::from_bits(tcx, v, ty::ParamEnv::empty().and(self)))
|
||||
}
|
||||
|
||||
/// Returns the minimum value for the given numeric type (including `char`s)
|
||||
/// or returns `None` if the type is not numeric.
|
||||
pub fn numeric_min_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
let val = match self.kind {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
let val = if signed { truncate(signed_min(size) as u128, size) } else { 0 };
|
||||
Some(val)
|
||||
}
|
||||
ty::Char => Some(0),
|
||||
ty::Float(fty) => Some(match fty {
|
||||
ast::FloatTy::F32 => (-::rustc_apfloat::ieee::Single::INFINITY).to_bits(),
|
||||
ast::FloatTy::F64 => (-::rustc_apfloat::ieee::Double::INFINITY).to_bits(),
|
||||
}),
|
||||
_ => None,
|
||||
};
|
||||
val.map(|v| ty::Const::from_bits(tcx, v, ty::ParamEnv::empty().and(self)))
|
||||
}
|
||||
|
||||
/// Checks whether values of this type `T` are *moved* or *copied*
|
||||
/// when referenced -- this amounts to a check for whether `T:
|
||||
/// Copy`, but note that we **don't** consider lifetimes when
|
||||
|
@ -8,7 +8,7 @@ use std::time::{Duration, Instant};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use errors::ErrorReported;
|
||||
pub use rustc_errors::ErrorReported;
|
||||
|
||||
pub fn to_readable_str(mut val: usize) -> String {
|
||||
let mut groups = vec![];
|
||||
|
@ -65,9 +65,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
PatKind::Box(ref inner) => hir::PatKind::Box(self.lower_pat(inner)),
|
||||
PatKind::Ref(ref inner, mutbl) => hir::PatKind::Ref(self.lower_pat(inner), mutbl),
|
||||
PatKind::Range(ref e1, ref e2, Spanned { node: ref end, .. }) => hir::PatKind::Range(
|
||||
self.lower_expr(e1),
|
||||
self.lower_expr(e2),
|
||||
self.lower_range_end(end),
|
||||
e1.as_deref().map(|e| self.lower_expr(e)),
|
||||
e2.as_deref().map(|e| self.lower_expr(e)),
|
||||
self.lower_range_end(end, e2.is_some()),
|
||||
),
|
||||
PatKind::Slice(ref pats) => self.lower_pat_slice(pats),
|
||||
PatKind::Rest => {
|
||||
@ -253,10 +253,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::PatKind::Wild
|
||||
}
|
||||
|
||||
fn lower_range_end(&mut self, e: &RangeEnd) -> hir::RangeEnd {
|
||||
fn lower_range_end(&mut self, e: &RangeEnd, has_end: bool) -> hir::RangeEnd {
|
||||
match *e {
|
||||
RangeEnd::Included(_) => hir::RangeEnd::Included,
|
||||
RangeEnd::Excluded => hir::RangeEnd::Excluded,
|
||||
RangeEnd::Excluded if has_end => hir::RangeEnd::Excluded,
|
||||
// No end; so `X..` behaves like `RangeFrom`.
|
||||
RangeEnd::Excluded | RangeEnd::Included(_) => hir::RangeEnd::Included,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ path = "lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
fmt_macros = { path = "../libfmt_macros" }
|
||||
log = "0.4"
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_parse = { path = "../librustc_parse" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
use State::*;
|
||||
|
||||
use errors::{struct_span_err, DiagnosticBuilder, PResult};
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder, PResult};
|
||||
use rustc_expand::base::*;
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
|
||||
use rustc_expand::base::*;
|
||||
use rustc_parse::parser::Parser;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/// The compiler code necessary to support the cfg! extension, which expands to
|
||||
/// a literal `true` or `false` based on whether the given cfg matches the
|
||||
/// current compilation environment.
|
||||
use errors::DiagnosticBuilder;
|
||||
//! The compiler code necessary to support the cfg! extension, which expands to
|
||||
//! a literal `true` or `false` based on whether the given cfg matches the
|
||||
//! current compilation environment.
|
||||
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_span::Span;
|
||||
use syntax::ast;
|
||||
|
@ -2,7 +2,7 @@ use crate::deriving::generic::ty::*;
|
||||
use crate::deriving::generic::*;
|
||||
use crate::deriving::path_std;
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use rustc_span::Span;
|
||||
|
@ -3,10 +3,8 @@ use Position::*;
|
||||
|
||||
use fmt_macros as parse;
|
||||
|
||||
use errors::pluralize;
|
||||
use errors::Applicability;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
@ -15,7 +13,6 @@ use syntax::ptr::P;
|
||||
use syntax::token;
|
||||
use syntax::tokenstream::TokenStream;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
/// Module-level assembly support.
|
||||
///
|
||||
/// The macro defined here allows you to specify "top-level",
|
||||
/// "file-scoped", or "module-level" assembly. These synonyms
|
||||
/// all correspond to LLVM's module-level inline assembly instruction.
|
||||
///
|
||||
/// For example, `global_asm!("some assembly here")` codegens to
|
||||
/// LLVM's `module asm "some assembly here"`. All of LLVM's caveats
|
||||
/// therefore apply.
|
||||
use errors::DiagnosticBuilder;
|
||||
//! Module-level assembly support.
|
||||
//!
|
||||
//! The macro defined here allows you to specify "top-level",
|
||||
//! "file-scoped", or "module-level" assembly. These synonyms
|
||||
//! all correspond to LLVM's module-level inline assembly instruction.
|
||||
//!
|
||||
//! For example, `global_asm!("some assembly here")` codegens to
|
||||
//! LLVM's `module asm "some assembly here"`. All of LLVM's caveats
|
||||
//! therefore apply.
|
||||
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_expand::base::{self, *};
|
||||
use rustc_span::source_map::respan;
|
||||
use rustc_span::Span;
|
||||
|
@ -40,7 +40,7 @@ enum ProcMacro {
|
||||
struct CollectProcMacros<'a> {
|
||||
macros: Vec<ProcMacro>,
|
||||
in_root: bool,
|
||||
handler: &'a errors::Handler,
|
||||
handler: &'a rustc_errors::Handler,
|
||||
is_proc_macro_crate: bool,
|
||||
is_test_crate: bool,
|
||||
}
|
||||
@ -53,7 +53,7 @@ pub fn inject(
|
||||
has_proc_macro_decls: bool,
|
||||
is_test_crate: bool,
|
||||
num_crate_types: usize,
|
||||
handler: &errors::Handler,
|
||||
handler: &rustc_errors::Handler,
|
||||
) -> ast::Crate {
|
||||
let ecfg = ExpansionConfig::default("proc_macro".to_string());
|
||||
let mut cx = ExtCtxt::new(sess, ecfg, resolver);
|
||||
|
@ -40,7 +40,7 @@ pub fn inject(
|
||||
resolver: &mut dyn Resolver,
|
||||
should_test: bool,
|
||||
krate: &mut ast::Crate,
|
||||
span_diagnostic: &errors::Handler,
|
||||
span_diagnostic: &rustc_errors::Handler,
|
||||
features: &Features,
|
||||
panic_strategy: PanicStrategy,
|
||||
platform_panic_strategy: PanicStrategy,
|
||||
@ -351,7 +351,7 @@ fn is_test_case(i: &ast::Item) -> bool {
|
||||
attr::contains_name(&i.attrs, sym::rustc_test_marker)
|
||||
}
|
||||
|
||||
fn get_test_runner(sd: &errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
|
||||
fn get_test_runner(sd: &rustc_errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
|
||||
let test_attr = attr::find_by_name(&krate.attrs, sym::test_runner)?;
|
||||
test_attr.meta_item_list().map(|meta_list| {
|
||||
if meta_list.len() != 1 {
|
||||
|
@ -46,7 +46,7 @@ fn require_inited() {
|
||||
}
|
||||
|
||||
unsafe fn configure_llvm(sess: &Session) {
|
||||
let n_args = sess.opts.cg.llvm_args.len();
|
||||
let n_args = sess.opts.cg.llvm_args.len() + sess.target.target.options.llvm_args.len();
|
||||
let mut llvm_c_strs = Vec::with_capacity(n_args + 1);
|
||||
let mut llvm_args = Vec::with_capacity(n_args + 1);
|
||||
|
||||
@ -56,14 +56,11 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||
full_arg.trim().split(|c: char| c == '=' || c.is_whitespace()).next().unwrap_or("")
|
||||
}
|
||||
|
||||
let user_specified_args: FxHashSet<_> = sess
|
||||
.opts
|
||||
.cg
|
||||
.llvm_args
|
||||
.iter()
|
||||
.map(|s| llvm_arg_to_arg_name(s))
|
||||
.filter(|s| s.len() > 0)
|
||||
.collect();
|
||||
let cg_opts = sess.opts.cg.llvm_args.iter();
|
||||
let tg_opts = sess.target.target.options.llvm_args.iter();
|
||||
|
||||
let user_specified_args: FxHashSet<_> =
|
||||
cg_opts.chain(tg_opts).map(|s| llvm_arg_to_arg_name(s)).filter(|s| s.len() > 0).collect();
|
||||
|
||||
{
|
||||
// This adds the given argument to LLVM. Unless `force` is true
|
||||
|
@ -17,7 +17,7 @@ rustc = { path = "../librustc" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
rustc_lint = { path = "../librustc_lint" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_hir = { path = "../librustc_hir" }
|
||||
rustc_metadata = { path = "../librustc_metadata" }
|
||||
|
@ -24,7 +24,6 @@ extern crate lazy_static;
|
||||
pub extern crate rustc_plugin_impl as plugin;
|
||||
|
||||
//use rustc_resolve as resolve;
|
||||
use errors::{registry::Registry, PResult};
|
||||
use rustc::lint;
|
||||
use rustc::lint::Lint;
|
||||
use rustc::middle::cstore::MetadataLoader;
|
||||
@ -37,6 +36,7 @@ use rustc::util::common::ErrorReported;
|
||||
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
||||
use rustc_data_structures::profiling::print_time_passes_entry;
|
||||
use rustc_data_structures::sync::SeqCst;
|
||||
use rustc_errors::{registry::Registry, PResult};
|
||||
use rustc_feature::{find_gated_cfg, UnstableFeatures};
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_interface::util::get_builtin_codegen_backend;
|
||||
@ -1134,7 +1134,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
|
||||
/// the panic into a `Result` instead.
|
||||
pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorReported> {
|
||||
catch_unwind(panic::AssertUnwindSafe(f)).map_err(|value| {
|
||||
if value.is::<errors::FatalErrorMarker>() {
|
||||
if value.is::<rustc_errors::FatalErrorMarker>() {
|
||||
ErrorReported
|
||||
} else {
|
||||
panic::resume_unwind(value);
|
||||
@ -1163,20 +1163,20 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
|
||||
// Separate the output with an empty line
|
||||
eprintln!();
|
||||
|
||||
let emitter = Box::new(errors::emitter::EmitterWriter::stderr(
|
||||
errors::ColorConfig::Auto,
|
||||
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
|
||||
rustc_errors::ColorConfig::Auto,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
));
|
||||
let handler = errors::Handler::with_emitter(true, None, emitter);
|
||||
let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
|
||||
|
||||
// a .span_bug or .bug call has already printed what
|
||||
// it wants to print.
|
||||
if !info.payload().is::<errors::ExplicitBug>() {
|
||||
let d = errors::Diagnostic::new(errors::Level::Bug, "unexpected panic");
|
||||
if !info.payload().is::<rustc_errors::ExplicitBug>() {
|
||||
let d = rustc_errors::Diagnostic::new(rustc_errors::Level::Bug, "unexpected panic");
|
||||
handler.emit_diagnostic(&d);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ doctest = false
|
||||
rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
log = "0.4"
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_lexer = { path = "../librustc_lexer" }
|
||||
rustc_parse = { path = "../librustc_parse" }
|
||||
|
@ -1,9 +1,15 @@
|
||||
use crate::expand::{self, AstFragment, Invocation};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_parse::{self, parser, DirectoryOwnership, MACRO_ARGUMENTS};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::{AstPass, ExpnData, ExpnId, ExpnKind};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{FileName, MultiSpan, Span, DUMMY_SP};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use syntax::ast::{self, Attribute, Name, NodeId, PatKind};
|
||||
use syntax::attr::{self, Deprecation, HasAttrs, Stability};
|
||||
use syntax::mut_visit::{self, MutVisitor};
|
||||
@ -13,13 +19,6 @@ use syntax::token;
|
||||
use syntax::tokenstream::{self, TokenStream};
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
use errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::{self, Lrc};
|
||||
use rustc_span::hygiene::{AstPass, ExpnData, ExpnId, ExpnKind};
|
||||
use rustc_span::{FileName, MultiSpan, Span, DUMMY_SP};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use std::default::Default;
|
||||
use std::iter;
|
||||
use std::path::PathBuf;
|
||||
|
@ -5,6 +5,8 @@ use crate::mbe::macro_rules::annotate_err_with_kind;
|
||||
use crate::placeholders::{placeholder, PlaceholderExpander};
|
||||
use crate::proc_macro::collect_derives;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, FatalError, PResult};
|
||||
use rustc_feature::Features;
|
||||
use rustc_parse::configure;
|
||||
use rustc_parse::parser::Parser;
|
||||
@ -26,10 +28,7 @@ use syntax::tokenstream::{TokenStream, TokenTree};
|
||||
use syntax::util::map_in_place::MapInPlace;
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
use errors::{Applicability, FatalError, PResult};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::io::ErrorKind;
|
||||
use std::ops::DerefMut;
|
||||
use std::path::PathBuf;
|
||||
|
@ -13,7 +13,7 @@ extern crate proc_macro as pm;
|
||||
#[macro_export]
|
||||
macro_rules! panictry {
|
||||
($e:expr) => {{
|
||||
use errors::FatalError;
|
||||
use rustc_errors::FatalError;
|
||||
use std::result::Result::{Err, Ok};
|
||||
match $e {
|
||||
Ok(e) => e,
|
||||
|
@ -85,7 +85,7 @@ use syntax::sess::ParseSess;
|
||||
use syntax::token::{self, DocComment, Nonterminal, Token};
|
||||
use syntax::tokenstream::TokenStream;
|
||||
|
||||
use errors::{FatalError, PResult};
|
||||
use rustc_errors::{FatalError, PResult};
|
||||
use rustc_span::Span;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
|
@ -8,6 +8,9 @@ use crate::mbe::macro_parser::{Error, Failure, Success};
|
||||
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
|
||||
use crate::mbe::transcribe::transcribe;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder, FatalError};
|
||||
use rustc_feature::Features;
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_parse::Directory;
|
||||
@ -22,17 +25,11 @@ use syntax::sess::ParseSess;
|
||||
use syntax::token::{self, NtTT, Token, TokenKind::*};
|
||||
use syntax::tokenstream::{DelimSpan, TokenStream};
|
||||
|
||||
use errors::{DiagnosticBuilder, FatalError};
|
||||
use log::debug;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::{mem, slice};
|
||||
|
||||
use errors::Applicability;
|
||||
|
||||
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
|
||||
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
|
||||
`literal`, `path`, `meta`, `tt`, `item` and `vis`";
|
||||
|
@ -2,19 +2,17 @@ use crate::base::ExtCtxt;
|
||||
use crate::mbe;
|
||||
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::pluralize;
|
||||
use rustc_span::hygiene::{ExpnId, Transparency};
|
||||
use rustc_span::Span;
|
||||
use syntax::ast::{Ident, Mac};
|
||||
use syntax::mut_visit::{self, MutVisitor};
|
||||
use syntax::token::{self, NtTT, Token};
|
||||
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
|
||||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use errors::pluralize;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_span::hygiene::{ExpnId, Transparency};
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::mem;
|
||||
|
||||
// A Marker adds the given mark to the syntax context.
|
||||
|
@ -1,4 +1,5 @@
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{emitter::EmitterWriter, Handler};
|
||||
use rustc_parse::lexer::StringReader;
|
||||
use rustc_span::source_map::{FilePathMapping, SourceMap};
|
||||
use rustc_span::symbol::Symbol;
|
||||
@ -8,7 +9,6 @@ use syntax::token::{self, Token, TokenKind};
|
||||
use syntax::util::comments::is_doc_comment;
|
||||
use syntax::with_default_globals;
|
||||
|
||||
use errors::{emitter::EmitterWriter, Handler};
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse};
|
||||
|
||||
use errors::PResult;
|
||||
use rustc_errors::PResult;
|
||||
use rustc_parse::new_parser_from_source_str;
|
||||
use rustc_span::source_map::FilePathMapping;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
@ -1,15 +1,14 @@
|
||||
use crate::base::{self, *};
|
||||
use crate::proc_macro_server;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, FatalError};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use syntax::ast::{self, ItemKind, MetaItemKind, NestedMetaItem};
|
||||
use syntax::errors::{Applicability, FatalError};
|
||||
use syntax::token;
|
||||
use syntax::tokenstream::{self, TokenStream};
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
const EXEC_STRATEGY: pm::bridge::server::SameThread = pm::bridge::server::SameThread;
|
||||
|
||||
pub struct BangProcMacro {
|
||||
|
@ -1,5 +1,7 @@
|
||||
use crate::base::ExtCtxt;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_parse::lexer::nfc_normalize;
|
||||
use rustc_parse::{nt_to_tokenstream, parse_stream_from_source_str};
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
@ -11,9 +13,6 @@ use syntax::token;
|
||||
use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
|
||||
use syntax::util::comments;
|
||||
|
||||
use errors::Diagnostic;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
use pm::bridge::{server, TokenTree};
|
||||
use pm::{Delimiter, Level, LineColumn, Spacing};
|
||||
use std::ops::Bound;
|
||||
@ -265,13 +264,13 @@ impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToInternal<errors::Level> for Level {
|
||||
fn to_internal(self) -> errors::Level {
|
||||
impl ToInternal<rustc_errors::Level> for Level {
|
||||
fn to_internal(self) -> rustc_errors::Level {
|
||||
match self {
|
||||
Level::Error => errors::Level::Error,
|
||||
Level::Warning => errors::Level::Warning,
|
||||
Level::Note => errors::Level::Note,
|
||||
Level::Help => errors::Level::Help,
|
||||
Level::Error => rustc_errors::Level::Error,
|
||||
Level::Warning => rustc_errors::Level::Warning,
|
||||
Level::Note => rustc_errors::Level::Note,
|
||||
Level::Help => rustc_errors::Level::Help,
|
||||
_ => unreachable!("unknown proc_macro::Level variant: {:?}", self),
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ use syntax::sess::ParseSess;
|
||||
use syntax::tokenstream::TokenStream;
|
||||
use syntax::with_default_globals;
|
||||
|
||||
use errors::emitter::EmitterWriter;
|
||||
use errors::{Handler, PResult};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::emitter::EmitterWriter;
|
||||
use rustc_errors::{Handler, PResult};
|
||||
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
|
@ -534,6 +534,9 @@ declare_features! (
|
||||
/// Allows the use of `#[cfg(sanitize = "option")]`; set when -Zsanitizer is used.
|
||||
(active, cfg_sanitize, "1.41.0", Some(39699), None),
|
||||
|
||||
/// Allows using `..X`, `..=X`, `...X`, and `X..` as a pattern.
|
||||
(active, half_open_range_patterns, "1.41.0", Some(67264), None),
|
||||
|
||||
/// Allows using `&mut` in constant functions.
|
||||
(active, const_mut_refs, "1.41.0", Some(57349), None),
|
||||
|
||||
|
@ -905,7 +905,7 @@ pub enum PatKind<'hir> {
|
||||
Lit(&'hir Expr<'hir>),
|
||||
|
||||
/// A range pattern (e.g., `1..=2` or `1..2`).
|
||||
Range(&'hir Expr<'hir>, &'hir Expr<'hir>, RangeEnd),
|
||||
Range(Option<&'hir Expr<'hir>>, Option<&'hir Expr<'hir>>, RangeEnd),
|
||||
|
||||
/// A slice pattern, `[before_0, ..., before_n, (slice, after_0, ..., after_n)?]`.
|
||||
///
|
||||
|
@ -766,8 +766,8 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
|
||||
}
|
||||
PatKind::Lit(ref expression) => visitor.visit_expr(expression),
|
||||
PatKind::Range(ref lower_bound, ref upper_bound, _) => {
|
||||
visitor.visit_expr(lower_bound);
|
||||
visitor.visit_expr(upper_bound)
|
||||
walk_list!(visitor, visit_expr, lower_bound);
|
||||
walk_list!(visitor, visit_expr, upper_bound);
|
||||
}
|
||||
PatKind::Wild => (),
|
||||
PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
|
||||
|
@ -1767,13 +1767,17 @@ impl<'a> State<'a> {
|
||||
}
|
||||
PatKind::Lit(ref e) => self.print_expr(&e),
|
||||
PatKind::Range(ref begin, ref end, ref end_kind) => {
|
||||
self.print_expr(&begin);
|
||||
self.s.space();
|
||||
if let Some(expr) = begin {
|
||||
self.print_expr(expr);
|
||||
self.s.space();
|
||||
}
|
||||
match *end_kind {
|
||||
RangeEnd::Included => self.s.word("..."),
|
||||
RangeEnd::Excluded => self.s.word(".."),
|
||||
}
|
||||
self.print_expr(&end);
|
||||
if let Some(expr) = end {
|
||||
self.print_expr(expr);
|
||||
}
|
||||
}
|
||||
PatKind::Slice(ref before, ref slice, ref after) => {
|
||||
self.s.word("[");
|
||||
|
@ -12,6 +12,7 @@ path = "lib.rs"
|
||||
log = "0.4"
|
||||
unicode-security = "0.0.2"
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_hir = { path = "../librustc_hir" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
|
@ -2,9 +2,9 @@ use crate::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||
use rustc::lint::FutureIncompatibleInfo;
|
||||
use rustc::ty;
|
||||
use rustc::ty::adjustment::{Adjust, Adjustment};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_span::symbol::sym;
|
||||
use syntax::errors::Applicability;
|
||||
|
||||
declare_lint! {
|
||||
pub ARRAY_INTO_ITER,
|
||||
|
@ -31,6 +31,7 @@ use rustc::lint::FutureIncompatibleInfo;
|
||||
use rustc::traits::misc::can_type_implement_copy;
|
||||
use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_feature::Stability;
|
||||
use rustc_feature::{deprecated_attributes, AttributeGate, AttributeTemplate, AttributeType};
|
||||
use rustc_hir as hir;
|
||||
@ -44,9 +45,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use syntax::ast::{self, Expr};
|
||||
use syntax::attr::{self, HasAttrs};
|
||||
use syntax::errors::{Applicability, DiagnosticBuilder};
|
||||
use syntax::print::pprust::{self, expr_to_string};
|
||||
use syntax::ptr::P;
|
||||
use syntax::tokenstream::{TokenStream, TokenTree};
|
||||
use syntax::visit::FnKind;
|
||||
|
||||
@ -1309,11 +1308,13 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
|
||||
/// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
|
||||
/// corresponding to the ellipsis.
|
||||
fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
|
||||
fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(Option<&Expr>, &Expr, Span)> {
|
||||
match &pat.kind {
|
||||
PatKind::Range(a, b, Spanned { span, node: RangeEnd::Included(DotDotDot), .. }) => {
|
||||
Some((a, b, *span))
|
||||
}
|
||||
PatKind::Range(
|
||||
a,
|
||||
Some(b),
|
||||
Spanned { span, node: RangeEnd::Included(DotDotDot) },
|
||||
) => Some((a.as_deref(), b, *span)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -1328,11 +1329,16 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
let suggestion = "use `..=` for an inclusive range";
|
||||
if parenthesise {
|
||||
self.node_id = Some(pat.id);
|
||||
let end = expr_to_string(&end);
|
||||
let replace = match start {
|
||||
Some(start) => format!("&({}..={})", expr_to_string(&start), end),
|
||||
None => format!("&(..={})", end),
|
||||
};
|
||||
let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, msg);
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
format!("&({}..={})", expr_to_string(&start), expr_to_string(&end)),
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
|
@ -2,6 +2,7 @@ use lint::{EarlyContext, LateContext, LintArray, LintContext};
|
||||
use lint::{EarlyLintPass, LateLintPass, LintPass};
|
||||
use rustc::lint;
|
||||
use rustc::ty;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
@ -11,7 +12,6 @@ use rustc_span::{symbol::Ident, BytePos, Span};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::errors::Applicability;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum MethodLateContext {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
|
||||
use rustc_errors::Applicability;
|
||||
use syntax::ast::{ExprKind, Stmt, StmtKind};
|
||||
use syntax::errors::Applicability;
|
||||
|
||||
declare_lint! {
|
||||
pub REDUNDANT_SEMICOLON,
|
||||
|
@ -9,6 +9,7 @@ use rustc::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx};
|
||||
use rustc::ty::subst::SubstsRef;
|
||||
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{is_range_literal, ExprKind, Node};
|
||||
use rustc_index::vec::Idx;
|
||||
@ -16,7 +17,6 @@ use rustc_span::source_map;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::errors::Applicability;
|
||||
use syntax::{ast, attr};
|
||||
|
||||
use log::debug;
|
||||
|
@ -5,17 +5,16 @@ use rustc::lint::builtin::UNUSED_ATTRIBUTES;
|
||||
use rustc::ty::adjustment;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{pluralize, Applicability};
|
||||
use rustc_feature::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::errors::{pluralize, Applicability};
|
||||
use syntax::print::pprust;
|
||||
use syntax::util::parser;
|
||||
|
||||
|
@ -16,8 +16,8 @@ memmap = "0.7"
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_hir = { path = "../librustc_hir" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
rustc_serialize = { path = "../libserialize", package = "serialize" }
|
||||
|
@ -12,25 +12,23 @@ use rustc::session::{CrateDisambiguator, Session};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
||||
|
||||
use std::path::Path;
|
||||
use std::{cmp, fs};
|
||||
|
||||
use errors::struct_span_err;
|
||||
use log::{debug, info, log_enabled};
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::expand::allocator::{global_allocator_spans, AllocatorKind};
|
||||
|
||||
use rustc_error_codes::*;
|
||||
use log::{debug, info, log_enabled};
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
use std::path::Path;
|
||||
use std::{cmp, fs};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CStore {
|
||||
|
@ -215,7 +215,6 @@
|
||||
use crate::creader::Library;
|
||||
use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
|
||||
|
||||
use errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc::middle::cstore::{CrateSource, MetadataLoader};
|
||||
use rustc::session::filesearch::{FileDoesntMatch, FileMatches, FileSearch};
|
||||
use rustc::session::search_paths::PathKind;
|
||||
@ -223,6 +222,7 @@ use rustc::session::{config, CrateDisambiguator, Session};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::MetadataRef;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::{Target, TargetTriple};
|
||||
|
@ -1,9 +1,9 @@
|
||||
use errors::struct_span_err;
|
||||
use rustc::middle::cstore::{self, NativeLibrary};
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_span::source_map::Span;
|
||||
|
@ -6,13 +6,12 @@ use rustc::infer::{
|
||||
};
|
||||
use rustc::mir::{Body, ConstraintCategory, Location};
|
||||
use rustc::ty::{self, RegionVid, Ty};
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::Span;
|
||||
use std::collections::VecDeque;
|
||||
use syntax::errors::Applicability;
|
||||
|
||||
use crate::util::borrowck_errors;
|
||||
|
||||
|
@ -429,14 +429,87 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
) -> (PatKind<'tcx>, Option<Ascription<'tcx>>) {
|
||||
match self.lower_lit(expr) {
|
||||
PatKind::AscribeUserType {
|
||||
ascription: lo_ascription,
|
||||
subpattern: Pat { kind: box kind, .. },
|
||||
} => (kind, Some(lo_ascription)),
|
||||
PatKind::AscribeUserType { ascription, subpattern: Pat { kind: box kind, .. } } => {
|
||||
(kind, Some(ascription))
|
||||
}
|
||||
kind => (kind, None),
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_pattern_range(
|
||||
&mut self,
|
||||
ty: Ty<'tcx>,
|
||||
lo: &'tcx ty::Const<'tcx>,
|
||||
hi: &'tcx ty::Const<'tcx>,
|
||||
end: RangeEnd,
|
||||
span: Span,
|
||||
) -> PatKind<'tcx> {
|
||||
assert_eq!(lo.ty, ty);
|
||||
assert_eq!(hi.ty, ty);
|
||||
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env, ty);
|
||||
match (end, cmp) {
|
||||
// `x..y` where `x < y`.
|
||||
// Non-empty because the range includes at least `x`.
|
||||
(RangeEnd::Excluded, Some(Ordering::Less)) => PatKind::Range(PatRange { lo, hi, end }),
|
||||
// `x..y` where `x >= y`. The range is empty => error.
|
||||
(RangeEnd::Excluded, _) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
span,
|
||||
E0579,
|
||||
"lower range bound must be less than upper"
|
||||
)
|
||||
.emit();
|
||||
PatKind::Wild
|
||||
}
|
||||
// `x..=y` where `x == y`.
|
||||
(RangeEnd::Included, Some(Ordering::Equal)) => PatKind::Constant { value: lo },
|
||||
// `x..=y` where `x < y`.
|
||||
(RangeEnd::Included, Some(Ordering::Less)) => PatKind::Range(PatRange { lo, hi, end }),
|
||||
// `x..=y` where `x > y` hence the range is empty => error.
|
||||
(RangeEnd::Included, _) => {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
span,
|
||||
E0030,
|
||||
"lower range bound must be less than or equal to upper"
|
||||
);
|
||||
err.span_label(span, "lower bound larger than upper bound");
|
||||
if self.tcx.sess.teach(&err.get_code().unwrap()) {
|
||||
err.note(
|
||||
"When matching against a range, the compiler \
|
||||
verifies that the range is non-empty. Range \
|
||||
patterns include both end-points, so this is \
|
||||
equivalent to requiring the start of the range \
|
||||
to be less than or equal to the end of the range.",
|
||||
);
|
||||
}
|
||||
err.emit();
|
||||
PatKind::Wild
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_range_pattern_ends(
|
||||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
lo: Option<&PatKind<'tcx>>,
|
||||
hi: Option<&PatKind<'tcx>>,
|
||||
) -> Option<(&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>)> {
|
||||
match (lo, hi) {
|
||||
(Some(PatKind::Constant { value: lo }), Some(PatKind::Constant { value: hi })) => {
|
||||
Some((lo, hi))
|
||||
}
|
||||
(Some(PatKind::Constant { value: lo }), None) => {
|
||||
Some((lo, ty.numeric_max_val(self.tcx)?))
|
||||
}
|
||||
(None, Some(PatKind::Constant { value: hi })) => {
|
||||
Some((ty.numeric_min_val(self.tcx)?, hi))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat<'tcx>) -> Pat<'tcx> {
|
||||
let mut ty = self.tables.node_type(pat.hir_id);
|
||||
|
||||
@ -451,65 +524,20 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
hir::PatKind::Lit(ref value) => self.lower_lit(value),
|
||||
|
||||
hir::PatKind::Range(ref lo_expr, ref hi_expr, end) => {
|
||||
let (lo, lo_ascription) = self.lower_range_expr(lo_expr);
|
||||
let (hi, hi_ascription) = self.lower_range_expr(hi_expr);
|
||||
let (lo_expr, hi_expr) = (lo_expr.as_deref(), hi_expr.as_deref());
|
||||
let lo_span = lo_expr.map_or(pat.span, |e| e.span);
|
||||
let lo = lo_expr.map(|e| self.lower_range_expr(e));
|
||||
let hi = hi_expr.map(|e| self.lower_range_expr(e));
|
||||
|
||||
let mut kind = match (lo, hi) {
|
||||
(PatKind::Constant { value: lo }, PatKind::Constant { value: hi }) => {
|
||||
assert_eq!(lo.ty, ty);
|
||||
assert_eq!(hi.ty, ty);
|
||||
let cmp = compare_const_vals(self.tcx, lo, hi, self.param_env, ty);
|
||||
match (end, cmp) {
|
||||
(RangeEnd::Excluded, Some(Ordering::Less)) => {
|
||||
PatKind::Range(PatRange { lo, hi, end })
|
||||
}
|
||||
(RangeEnd::Excluded, _) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
lo_expr.span,
|
||||
E0579,
|
||||
"lower range bound must be less than upper",
|
||||
)
|
||||
.emit();
|
||||
PatKind::Wild
|
||||
}
|
||||
(RangeEnd::Included, Some(Ordering::Equal)) => {
|
||||
PatKind::Constant { value: lo }
|
||||
}
|
||||
(RangeEnd::Included, Some(Ordering::Less)) => {
|
||||
PatKind::Range(PatRange { lo, hi, end })
|
||||
}
|
||||
(RangeEnd::Included, _) => {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
lo_expr.span,
|
||||
E0030,
|
||||
"lower range bound must be less than or equal to upper"
|
||||
);
|
||||
err.span_label(lo_expr.span, "lower bound larger than upper bound");
|
||||
if self.tcx.sess.teach(&err.get_code().unwrap()) {
|
||||
err.note(
|
||||
"When matching against a range, the compiler \
|
||||
verifies that the range is non-empty. Range \
|
||||
patterns include both end-points, so this is \
|
||||
equivalent to requiring the start of the range \
|
||||
to be less than or equal to the end of the range.",
|
||||
);
|
||||
}
|
||||
err.emit();
|
||||
PatKind::Wild
|
||||
}
|
||||
}
|
||||
}
|
||||
ref pats => {
|
||||
self.tcx.sess.delay_span_bug(
|
||||
pat.span,
|
||||
&format!(
|
||||
"found bad range pattern `{:?}` outside of error recovery",
|
||||
pats,
|
||||
),
|
||||
let (lp, hp) = (lo.as_ref().map(|x| &x.0), hi.as_ref().map(|x| &x.0));
|
||||
let mut kind = match self.normalize_range_pattern_ends(ty, lp, hp) {
|
||||
Some((lc, hc)) => self.lower_pattern_range(ty, lc, hc, end, lo_span),
|
||||
None => {
|
||||
let msg = &format!(
|
||||
"found bad range pattern `{:?}` outside of error recovery",
|
||||
(&lo, &hi),
|
||||
);
|
||||
|
||||
self.tcx.sess.delay_span_bug(pat.span, msg);
|
||||
PatKind::Wild
|
||||
}
|
||||
};
|
||||
@ -517,12 +545,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
// If we are handling a range with associated constants (e.g.
|
||||
// `Foo::<'a>::A..=Foo::B`), we need to put the ascriptions for the associated
|
||||
// constants somewhere. Have them on the range pattern.
|
||||
for ascription in &[lo_ascription, hi_ascription] {
|
||||
if let Some(ascription) = ascription {
|
||||
kind = PatKind::AscribeUserType {
|
||||
ascription: *ascription,
|
||||
subpattern: Pat { span: pat.span, ty, kind: Box::new(kind) },
|
||||
};
|
||||
for end in &[lo, hi] {
|
||||
if let Some((_, Some(ascription))) = end {
|
||||
let subpattern = Pat { span: pat.span, ty, kind: Box::new(kind) };
|
||||
kind = PatKind::AscribeUserType { ascription: *ascription, subpattern };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@
|
||||
use std::iter::once;
|
||||
use std::ops::Range;
|
||||
|
||||
use rustc_errors::{Applicability, Handler};
|
||||
use rustc_lexer::unescape::{EscapeError, Mode};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use syntax::errors::{Applicability, Handler};
|
||||
|
||||
pub(crate) fn emit_unescape_error(
|
||||
handler: &Handler,
|
||||
// interior part of the literal, without quotes
|
||||
|
@ -51,7 +51,6 @@ pub enum Error {
|
||||
secondary_path: String,
|
||||
},
|
||||
UselessDocComment,
|
||||
InclusiveRangeWithNoEnd,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@ -102,11 +101,6 @@ impl Error {
|
||||
);
|
||||
err
|
||||
}
|
||||
Error::InclusiveRangeWithNoEnd => {
|
||||
let mut err = struct_span_err!(handler, sp, E0586, "inclusive range with no end",);
|
||||
err.help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)");
|
||||
err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
use super::diagnostics::Error;
|
||||
use super::pat::{GateOr, PARAM_EXPECTED};
|
||||
use super::{BlockMode, Parser, PathStyle, PrevTokenKind, Restrictions, TokenType};
|
||||
use super::{SemiColonMode, SeqSep, TokenExpectType};
|
||||
@ -1967,7 +1966,8 @@ impl<'a> Parser<'a> {
|
||||
limits: RangeLimits,
|
||||
) -> PResult<'a, ExprKind> {
|
||||
if end.is_none() && limits == RangeLimits::Closed {
|
||||
Err(self.span_fatal_err(self.token.span, Error::InclusiveRangeWithNoEnd))
|
||||
self.error_inclusive_range_with_no_end(self.token.span);
|
||||
Ok(ExprKind::Err)
|
||||
} else {
|
||||
Ok(ExprKind::Range(start, end, limits))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::{Parser, PathStyle};
|
||||
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder, PResult};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, PResult};
|
||||
use rustc_span::source_map::{respan, Span, Spanned};
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use syntax::ast::{self, AttrVec, Attribute, FieldPat, Mac, Pat, PatKind, RangeEnd, RangeSyntax};
|
||||
@ -281,91 +281,73 @@ impl<'a> Parser<'a> {
|
||||
maybe_whole!(self, NtPat, |x| x);
|
||||
|
||||
let lo = self.token.span;
|
||||
let pat = match self.token.kind {
|
||||
token::BinOp(token::And) | token::AndAnd => self.parse_pat_deref(expected)?,
|
||||
token::OpenDelim(token::Paren) => self.parse_pat_tuple_or_parens()?,
|
||||
token::OpenDelim(token::Bracket) => {
|
||||
// Parse `[pat, pat,...]` as a slice pattern.
|
||||
let (pats, _) =
|
||||
self.parse_delim_comma_seq(token::Bracket, |p| p.parse_pat_with_or_inner())?;
|
||||
PatKind::Slice(pats)
|
||||
|
||||
let pat = if self.check(&token::BinOp(token::And)) || self.token.kind == token::AndAnd {
|
||||
self.parse_pat_deref(expected)?
|
||||
} else if self.check(&token::OpenDelim(token::Paren)) {
|
||||
self.parse_pat_tuple_or_parens()?
|
||||
} else if self.check(&token::OpenDelim(token::Bracket)) {
|
||||
// Parse `[pat, pat,...]` as a slice pattern.
|
||||
let (pats, _) =
|
||||
self.parse_delim_comma_seq(token::Bracket, |p| p.parse_pat_with_or_inner())?;
|
||||
PatKind::Slice(pats)
|
||||
} else if self.check(&token::DotDot) && !self.is_pat_range_end_start(1) {
|
||||
// A rest pattern `..`.
|
||||
self.bump(); // `..`
|
||||
PatKind::Rest
|
||||
} else if let Some(form) = self.parse_range_end() {
|
||||
self.parse_pat_range_to(form)? // `..=X`, `...X`, or `..X`.
|
||||
} else if self.eat_keyword(kw::Underscore) {
|
||||
// Parse _
|
||||
PatKind::Wild
|
||||
} else if self.eat_keyword(kw::Mut) {
|
||||
self.parse_pat_ident_mut()?
|
||||
} else if self.eat_keyword(kw::Ref) {
|
||||
// Parse ref ident @ pat / ref mut ident @ pat
|
||||
let mutbl = self.parse_mutability();
|
||||
self.parse_pat_ident(BindingMode::ByRef(mutbl))?
|
||||
} else if self.eat_keyword(kw::Box) {
|
||||
// Parse `box pat`
|
||||
let pat = self.parse_pat_with_range_pat(false, None)?;
|
||||
self.sess.gated_spans.gate(sym::box_patterns, lo.to(self.prev_span));
|
||||
PatKind::Box(pat)
|
||||
} else if self.can_be_ident_pat() {
|
||||
// Parse `ident @ pat`
|
||||
// This can give false positives and parse nullary enums,
|
||||
// they are dealt with later in resolve.
|
||||
self.parse_pat_ident(BindingMode::ByValue(Mutability::Not))?
|
||||
} else if self.is_start_of_pat_with_path() {
|
||||
// Parse pattern starting with a path
|
||||
let (qself, path) = if self.eat_lt() {
|
||||
// Parse a qualified path
|
||||
let (qself, path) = self.parse_qpath(PathStyle::Expr)?;
|
||||
(Some(qself), path)
|
||||
} else {
|
||||
// Parse an unqualified path
|
||||
(None, self.parse_path(PathStyle::Expr)?)
|
||||
};
|
||||
let span = lo.to(self.prev_span);
|
||||
|
||||
if qself.is_none() && self.check(&token::Not) {
|
||||
self.parse_pat_mac_invoc(path)?
|
||||
} else if let Some(form) = self.parse_range_end() {
|
||||
let begin = self.mk_expr(span, ExprKind::Path(qself, path), AttrVec::new());
|
||||
self.parse_pat_range_begin_with(begin, form)?
|
||||
} else if self.check(&token::OpenDelim(token::Brace)) {
|
||||
self.parse_pat_struct(qself, path)?
|
||||
} else if self.check(&token::OpenDelim(token::Paren)) {
|
||||
self.parse_pat_tuple_struct(qself, path)?
|
||||
} else {
|
||||
PatKind::Path(qself, path)
|
||||
}
|
||||
token::DotDot => {
|
||||
self.bump();
|
||||
if self.is_pat_range_end_start() {
|
||||
// Parse `..42` for recovery.
|
||||
self.parse_pat_range_to(RangeEnd::Excluded, "..")?
|
||||
} else {
|
||||
// A rest pattern `..`.
|
||||
PatKind::Rest
|
||||
}
|
||||
}
|
||||
token::DotDotEq => {
|
||||
// Parse `..=42` for recovery.
|
||||
self.bump();
|
||||
self.parse_pat_range_to(RangeEnd::Included(RangeSyntax::DotDotEq), "..=")?
|
||||
}
|
||||
token::DotDotDot => {
|
||||
// Parse `...42` for recovery.
|
||||
self.bump();
|
||||
self.parse_pat_range_to(RangeEnd::Included(RangeSyntax::DotDotDot), "...")?
|
||||
}
|
||||
// At this point, token != `&`, `&&`, `(`, `[`, `..`, `..=`, or `...`.
|
||||
_ => {
|
||||
if self.eat_keyword(kw::Underscore) {
|
||||
// Parse _
|
||||
PatKind::Wild
|
||||
} else if self.eat_keyword(kw::Mut) {
|
||||
self.parse_pat_ident_mut()?
|
||||
} else if self.eat_keyword(kw::Ref) {
|
||||
// Parse ref ident @ pat / ref mut ident @ pat
|
||||
let mutbl = self.parse_mutability();
|
||||
self.parse_pat_ident(BindingMode::ByRef(mutbl))?
|
||||
} else if self.eat_keyword(kw::Box) {
|
||||
// Parse `box pat`
|
||||
let pat = self.parse_pat_with_range_pat(false, None)?;
|
||||
self.sess.gated_spans.gate(sym::box_patterns, lo.to(self.prev_span));
|
||||
PatKind::Box(pat)
|
||||
} else if self.can_be_ident_pat() {
|
||||
// Parse `ident @ pat`
|
||||
// This can give false positives and parse nullary enums,
|
||||
// they are dealt with later in resolve.
|
||||
self.parse_pat_ident(BindingMode::ByValue(Mutability::Not))?
|
||||
} else if self.is_start_of_pat_with_path() {
|
||||
// Parse pattern starting with a path
|
||||
let (qself, path) = if self.eat_lt() {
|
||||
// Parse a qualified path
|
||||
let (qself, path) = self.parse_qpath(PathStyle::Expr)?;
|
||||
(Some(qself), path)
|
||||
} else {
|
||||
// Parse an unqualified path
|
||||
(None, self.parse_path(PathStyle::Expr)?)
|
||||
};
|
||||
match self.token.kind {
|
||||
token::Not if qself.is_none() => self.parse_pat_mac_invoc(path)?,
|
||||
token::DotDotDot | token::DotDotEq | token::DotDot => {
|
||||
self.parse_pat_range_starting_with_path(lo, qself, path)?
|
||||
}
|
||||
token::OpenDelim(token::Brace) => self.parse_pat_struct(qself, path)?,
|
||||
token::OpenDelim(token::Paren) => {
|
||||
self.parse_pat_tuple_struct(qself, path)?
|
||||
}
|
||||
_ => PatKind::Path(qself, path),
|
||||
}
|
||||
} else {
|
||||
// Try to parse everything else as literal with optional minus
|
||||
match self.parse_literal_maybe_minus() {
|
||||
Ok(begin)
|
||||
if self.check(&token::DotDot)
|
||||
|| self.check(&token::DotDotEq)
|
||||
|| self.check(&token::DotDotDot) =>
|
||||
{
|
||||
self.parse_pat_range_starting_with_lit(begin)?
|
||||
}
|
||||
Ok(begin) => PatKind::Lit(begin),
|
||||
Err(err) => return self.fatal_unexpected_non_pat(err, expected),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Try to parse everything else as literal with optional minus
|
||||
match self.parse_literal_maybe_minus() {
|
||||
Ok(begin) => match self.parse_range_end() {
|
||||
Some(form) => self.parse_pat_range_begin_with(begin, form)?,
|
||||
None => PatKind::Lit(begin),
|
||||
},
|
||||
Err(err) => return self.fatal_unexpected_non_pat(err, expected),
|
||||
}
|
||||
};
|
||||
|
||||
@ -374,7 +356,7 @@ impl<'a> Parser<'a> {
|
||||
let pat = self.recover_intersection_pat(pat)?;
|
||||
|
||||
if !allow_range_pat {
|
||||
self.ban_pat_range_if_ambiguous(&pat)?
|
||||
self.ban_pat_range_if_ambiguous(&pat)
|
||||
}
|
||||
|
||||
Ok(pat)
|
||||
@ -441,26 +423,25 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
/// Ban a range pattern if it has an ambiguous interpretation.
|
||||
fn ban_pat_range_if_ambiguous(&self, pat: &Pat) -> PResult<'a, ()> {
|
||||
fn ban_pat_range_if_ambiguous(&self, pat: &Pat) {
|
||||
match pat.kind {
|
||||
PatKind::Range(
|
||||
..,
|
||||
Spanned { node: RangeEnd::Included(RangeSyntax::DotDotDot), .. },
|
||||
) => return Ok(()),
|
||||
) => return,
|
||||
PatKind::Range(..) => {}
|
||||
_ => return Ok(()),
|
||||
_ => return,
|
||||
}
|
||||
|
||||
let mut err =
|
||||
self.struct_span_err(pat.span, "the range pattern here has ambiguous interpretation");
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
"add parentheses to clarify the precedence",
|
||||
format!("({})", pprust::pat_to_string(&pat)),
|
||||
// "ambiguous interpretation" implies that we have to be guessing
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
Err(err)
|
||||
self.struct_span_err(pat.span, "the range pattern here has ambiguous interpretation")
|
||||
.span_suggestion(
|
||||
pat.span,
|
||||
"add parentheses to clarify the precedence",
|
||||
format!("({})", pprust::pat_to_string(&pat)),
|
||||
// "ambiguous interpretation" implies that we have to be guessing
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
||||
/// Parse `&pat` / `&mut pat`.
|
||||
@ -618,51 +599,6 @@ impl<'a> Parser<'a> {
|
||||
Ok(PatKind::Mac(mac))
|
||||
}
|
||||
|
||||
fn excluded_range_end(&self, span: Span) -> RangeEnd {
|
||||
self.sess.gated_spans.gate(sym::exclusive_range_pattern, span);
|
||||
RangeEnd::Excluded
|
||||
}
|
||||
|
||||
/// Parse a range pattern `$path $form $end?` where `$form = ".." | "..." | "..=" ;`.
|
||||
/// The `$path` has already been parsed and the next token is the `$form`.
|
||||
fn parse_pat_range_starting_with_path(
|
||||
&mut self,
|
||||
lo: Span,
|
||||
qself: Option<QSelf>,
|
||||
path: Path,
|
||||
) -> PResult<'a, PatKind> {
|
||||
let (end_kind, form) = match self.token.kind {
|
||||
token::DotDot => (self.excluded_range_end(self.token.span), ".."),
|
||||
token::DotDotDot => (RangeEnd::Included(RangeSyntax::DotDotDot), "..."),
|
||||
token::DotDotEq => (RangeEnd::Included(RangeSyntax::DotDotEq), "..="),
|
||||
_ => panic!("can only parse `..`/`...`/`..=` for ranges (checked above)"),
|
||||
};
|
||||
let op_span = self.token.span;
|
||||
// Parse range
|
||||
let span = lo.to(self.prev_span);
|
||||
let begin = self.mk_expr(span, ExprKind::Path(qself, path), AttrVec::new());
|
||||
self.bump();
|
||||
let end = self.parse_pat_range_end_opt(&begin, form)?;
|
||||
Ok(PatKind::Range(begin, end, respan(op_span, end_kind)))
|
||||
}
|
||||
|
||||
/// Parse a range pattern `$literal $form $end?` where `$form = ".." | "..." | "..=" ;`.
|
||||
/// The `$path` has already been parsed and the next token is the `$form`.
|
||||
fn parse_pat_range_starting_with_lit(&mut self, begin: P<Expr>) -> PResult<'a, PatKind> {
|
||||
let op_span = self.token.span;
|
||||
let (end_kind, form) = if self.eat(&token::DotDotDot) {
|
||||
(RangeEnd::Included(RangeSyntax::DotDotDot), "...")
|
||||
} else if self.eat(&token::DotDotEq) {
|
||||
(RangeEnd::Included(RangeSyntax::DotDotEq), "..=")
|
||||
} else if self.eat(&token::DotDot) {
|
||||
(self.excluded_range_end(op_span), "..")
|
||||
} else {
|
||||
panic!("impossible case: we already matched on a range-operator token")
|
||||
};
|
||||
let end = self.parse_pat_range_end_opt(&begin, form)?;
|
||||
Ok(PatKind::Range(begin, end, respan(op_span, end_kind)))
|
||||
}
|
||||
|
||||
fn fatal_unexpected_non_pat(
|
||||
&mut self,
|
||||
mut err: DiagnosticBuilder<'a>,
|
||||
@ -684,57 +620,66 @@ impl<'a> Parser<'a> {
|
||||
Err(err)
|
||||
}
|
||||
|
||||
/// Is the current token suitable as the start of a range patterns end?
|
||||
fn is_pat_range_end_start(&self) -> bool {
|
||||
self.token.is_path_start() // e.g. `MY_CONST`;
|
||||
|| self.token == token::Dot // e.g. `.5` for recovery;
|
||||
|| self.token.can_begin_literal_or_bool() // e.g. `42`.
|
||||
|| self.token.is_whole_expr()
|
||||
/// Parses the range pattern end form `".." | "..." | "..=" ;`.
|
||||
fn parse_range_end(&mut self) -> Option<Spanned<RangeEnd>> {
|
||||
let re = if self.eat(&token::DotDotDot) {
|
||||
RangeEnd::Included(RangeSyntax::DotDotDot)
|
||||
} else if self.eat(&token::DotDotEq) {
|
||||
RangeEnd::Included(RangeSyntax::DotDotEq)
|
||||
} else if self.eat(&token::DotDot) {
|
||||
self.sess.gated_spans.gate(sym::exclusive_range_pattern, self.prev_span);
|
||||
RangeEnd::Excluded
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
Some(respan(self.prev_span, re))
|
||||
}
|
||||
|
||||
/// Parse a range-to pattern, e.g. `..X` and `..=X` for recovery.
|
||||
fn parse_pat_range_to(&mut self, re: RangeEnd, form: &str) -> PResult<'a, PatKind> {
|
||||
let lo = self.prev_span;
|
||||
let end = self.parse_pat_range_end()?;
|
||||
let range_span = lo.to(end.span);
|
||||
let begin = self.mk_expr(range_span, ExprKind::Err, AttrVec::new());
|
||||
|
||||
self.struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
|
||||
.span_suggestion(
|
||||
range_span,
|
||||
"try using the minimum value for the type",
|
||||
format!("MIN{}{}", form, pprust::expr_to_string(&end)),
|
||||
Applicability::HasPlaceholders,
|
||||
)
|
||||
.emit();
|
||||
|
||||
Ok(PatKind::Range(begin, end, respan(lo, re)))
|
||||
}
|
||||
|
||||
/// Parse the end of a `X..Y`, `X..=Y`, or `X...Y` range pattern or recover
|
||||
/// if that end is missing treating it as `X..`, `X..=`, or `X...` respectively.
|
||||
fn parse_pat_range_end_opt(&mut self, begin: &Expr, form: &str) -> PResult<'a, P<Expr>> {
|
||||
if self.is_pat_range_end_start() {
|
||||
/// Parse a range pattern `$begin $form $end?` where `$form = ".." | "..." | "..=" ;`.
|
||||
/// `$begin $form` has already been parsed.
|
||||
fn parse_pat_range_begin_with(
|
||||
&mut self,
|
||||
begin: P<Expr>,
|
||||
re: Spanned<RangeEnd>,
|
||||
) -> PResult<'a, PatKind> {
|
||||
let end = if self.is_pat_range_end_start(0) {
|
||||
// Parsing e.g. `X..=Y`.
|
||||
self.parse_pat_range_end()
|
||||
Some(self.parse_pat_range_end()?)
|
||||
} else {
|
||||
// Parsing e.g. `X..`.
|
||||
let range_span = begin.span.to(self.prev_span);
|
||||
self.sess.gated_spans.gate(sym::half_open_range_patterns, begin.span.to(re.span));
|
||||
if let RangeEnd::Included(_) = re.node {
|
||||
// FIXME(Centril): Consider semantic errors instead in `ast_validation`.
|
||||
// Possibly also do this for `X..=` in *expression* contexts.
|
||||
self.error_inclusive_range_with_no_end(re.span);
|
||||
}
|
||||
None
|
||||
};
|
||||
Ok(PatKind::Range(Some(begin), end, re))
|
||||
}
|
||||
|
||||
self.struct_span_err(
|
||||
range_span,
|
||||
&format!("`X{}` range patterns are not supported", form),
|
||||
)
|
||||
.span_suggestion(
|
||||
range_span,
|
||||
"try using the maximum value for the type",
|
||||
format!("{}{}MAX", pprust::expr_to_string(&begin), form),
|
||||
Applicability::HasPlaceholders,
|
||||
)
|
||||
pub(super) fn error_inclusive_range_with_no_end(&self, span: Span) {
|
||||
use rustc_error_codes::E0586;
|
||||
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
|
||||
.help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
|
||||
.emit();
|
||||
}
|
||||
|
||||
Ok(self.mk_expr(range_span, ExprKind::Err, AttrVec::new()))
|
||||
}
|
||||
/// Parse a range-to pattern, e.g. `..X` and `..=X` where `X` remains to be parsed.
|
||||
fn parse_pat_range_to(&mut self, re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
|
||||
let end = self.parse_pat_range_end()?;
|
||||
self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_span));
|
||||
Ok(PatKind::Range(None, Some(end), re))
|
||||
}
|
||||
|
||||
/// Is the token `dist` away from the current suitable as the start of a range patterns end?
|
||||
fn is_pat_range_end_start(&self, dist: usize) -> bool {
|
||||
self.look_ahead(dist, |t| {
|
||||
t.is_path_start() // e.g. `MY_CONST`;
|
||||
|| t.kind == token::Dot // e.g. `.5` for recovery;
|
||||
|| t.can_begin_literal_or_bool() // e.g. `42`.
|
||||
|| t.is_whole_expr()
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
|
||||
|
@ -12,6 +12,7 @@ path = "lib.rs"
|
||||
log = "0.4"
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_hir = { path = "../librustc_hir" }
|
||||
rustc_index = { path = "../librustc_index" }
|
||||
@ -19,5 +20,4 @@ rustc_parse = { path = "../librustc_parse" }
|
||||
rustc_target = { path = "../librustc_target" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_error_codes = { path = "../librustc_error_codes" }
|
||||
|
@ -6,10 +6,10 @@
|
||||
// This pass is supposed to perform only simple checks not requiring name resolution
|
||||
// or type checking or some other kind of complex analysis.
|
||||
|
||||
use errors::{struct_span_err, Applicability, FatalError};
|
||||
use rustc::lint;
|
||||
use rustc::session::Session;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{struct_span_err, Applicability, FatalError};
|
||||
use rustc_parse::validate_attr;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
@ -158,7 +158,7 @@ impl<'a> AstValidator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn err_handler(&self) -> &errors::Handler {
|
||||
fn err_handler(&self) -> &rustc_errors::Handler {
|
||||
&self.session.diagnostic()
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ enum GenericPosition {
|
||||
|
||||
fn validate_generics_order<'a>(
|
||||
sess: &Session,
|
||||
handler: &errors::Handler,
|
||||
handler: &rustc_errors::Handler,
|
||||
generics: impl Iterator<Item = (ParamKindOrd, Option<&'a [GenericBound]>, Span, Option<String>)>,
|
||||
pos: GenericPosition,
|
||||
span: Span,
|
||||
@ -920,8 +920,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
self.check_expr_within_pat(expr, false);
|
||||
}
|
||||
PatKind::Range(ref start, ref end, _) => {
|
||||
self.check_expr_within_pat(start, true);
|
||||
self.check_expr_within_pat(end, true);
|
||||
if let Some(expr) = start {
|
||||
self.check_expr_within_pat(expr, true);
|
||||
}
|
||||
if let Some(expr) = end {
|
||||
self.check_expr_within_pat(expr, true);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -7,12 +7,12 @@
|
||||
//! errors. We still look for those primitives in the MIR const-checker to ensure nothing slips
|
||||
//! through, but errors for structured control flow in a `const` should be emitted here.
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::session::config::nightly_options;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
|
@ -1,9 +1,9 @@
|
||||
use errors::struct_span_err;
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::session::config::EntryFnType;
|
||||
use rustc::session::{config, Session};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::{HirId, ImplItem, Item, ItemKind, TraitItem};
|
||||
|
@ -1,8 +1,8 @@
|
||||
use errors::struct_span_err;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
@ -4,11 +4,11 @@
|
||||
// and `#[unstable (..)]`), but are not declared in one single location
|
||||
// (unlike lang features), which means we need to collect them instead.
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::middle::lib_features::LibFeatures;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
@ -96,12 +96,12 @@
|
||||
use self::LiveNodeKind::*;
|
||||
use self::VarKind::*;
|
||||
|
||||
use errors::Applicability;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::lint;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::*;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -1064,7 +1064,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
.sess
|
||||
.struct_span_err(expr.span, "`break` to unknown label")
|
||||
.emit();
|
||||
errors::FatalError.raise()
|
||||
rustc_errors::FatalError.raise()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ use Context::*;
|
||||
|
||||
use rustc::session::Session;
|
||||
|
||||
use errors::{struct_span_err, Applicability};
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! A pass that annotates every item and method with its stability level,
|
||||
//! propagating default levels lexically from parent to children ast nodes.
|
||||
|
||||
use errors::struct_span_err;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::lint;
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
@ -11,6 +10,7 @@ use rustc::traits::misc::can_type_implement_copy;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
|
@ -14,16 +14,16 @@ doctest = false
|
||||
bitflags = "1.2.1"
|
||||
log = "0.4"
|
||||
syntax = { path = "../libsyntax" }
|
||||
rustc_expand = { path = "../librustc_expand" }
|
||||
arena = { path = "../libarena" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_ast_lowering = { path = "../librustc_ast_lowering" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
rustc_errors = { path = "../librustc_errors" }
|
||||
rustc_expand = { path = "../librustc_expand" }
|
||||
rustc_feature = { path = "../librustc_feature" }
|
||||
rustc_hir = { path = "../librustc_hir" }
|
||||
rustc_metadata = { path = "../librustc_metadata" }
|
||||
rustc_error_codes = { path = "../librustc_error_codes" }
|
||||
rustc_session = { path = "../librustc_session" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
|
@ -20,18 +20,14 @@ use rustc::bug;
|
||||
use rustc::hir::exports::Export;
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use rustc::ty;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_error_codes::*;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir::def::{self, *};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_metadata::creader::LoadedMacro;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
|
||||
use errors::{struct_span_err, Applicability};
|
||||
|
||||
use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_span::hygiene::{ExpnId, MacroKind};
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
@ -44,8 +40,8 @@ use syntax::token::{self, Token};
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
use log::debug;
|
||||
|
||||
use rustc_error_codes::*;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
|
||||
type Res = def::Res<NodeId>;
|
||||
|
||||
|
@ -26,9 +26,9 @@
|
||||
use crate::imports::ImportDirectiveSubclass;
|
||||
use crate::Resolver;
|
||||
|
||||
use errors::pluralize;
|
||||
use rustc::{lint, ty};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::pluralize;
|
||||
use rustc_session::node_id::NodeMap;
|
||||
use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
||||
use syntax::ast;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::cmp::Reverse;
|
||||
|
||||
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use log::debug;
|
||||
use rustc::bug;
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::{self, DefIdTree};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user