diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-31 21:25:16 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-01-08 04:25:33 +0100 |
| commit | 2c3e5d3de023c0bfbf4a4c4d3b0d7a9844e96ffe (patch) | |
| tree | d8a6e6281016eab3b52f1e0bbd0b89b7ea09035e /src/librustc | |
| parent | 7e393b5b3b543d355ae16c1940cf98b6c7fcb8aa (diff) | |
| download | rust-2c3e5d3de023c0bfbf4a4c4d3b0d7a9844e96ffe.tar.gz rust-2c3e5d3de023c0bfbf4a4c4d3b0d7a9844e96ffe.zip | |
- remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/hir/check_attr.rs | 16 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/need_type_info.rs | 15 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs | 1 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs | 2 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/note.rs | 2 | ||||
| -rw-r--r-- | src/librustc/infer/opaque_types/mod.rs | 8 | ||||
| -rw-r--r-- | src/librustc/lint/builtin.rs | 7 | ||||
| -rw-r--r-- | src/librustc/lint/context.rs | 11 | ||||
| -rw-r--r-- | src/librustc/lint/levels.rs | 7 | ||||
| -rw-r--r-- | src/librustc/middle/lang_items.rs | 6 | ||||
| -rw-r--r-- | src/librustc/middle/weak_lang_items.rs | 10 | ||||
| -rw-r--r-- | src/librustc/mir/interpret/error.rs | 2 | ||||
| -rw-r--r-- | src/librustc/traits/error_reporting.rs | 3 | ||||
| -rw-r--r-- | src/librustc/traits/on_unimplemented.rs | 12 | ||||
| -rw-r--r-- | src/librustc/traits/query/dropck_outlives.rs | 8 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ty/query/plumbing.rs | 6 |
18 files changed, 69 insertions, 50 deletions
diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 7395b03c4eb..d525f364593 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -8,6 +8,8 @@ use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; 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_hir as hir; use rustc_hir::def_id::DefId; @@ -430,21 +432,27 @@ impl CheckAttrVisitor<'tcx> { // Error on repr(transparent, <anything else>). if is_transparent && hints.len() > 1 { let hint_spans: Vec<_> = hint_spans.clone().collect(); - span_err!( + struct_span_err!( self.tcx.sess, hint_spans, E0692, "transparent {} cannot have other repr hints", target - ); + ) + .emit(); } // Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8) if (int_reprs > 1) || (is_simd && is_c) || (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item))) { - let hint_spans: Vec<_> = hint_spans.collect(); - span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints"); + struct_span_err!( + self.tcx.sess, + hint_spans.collect::<Vec<Span>>(), + E0566, + "conflicting representation hints", + ) + .emit(); } } diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index f262672fdc8..92292b3d35f 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -68,7 +68,7 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::Node; -use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; +use errors::{struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString}; use rustc_error_codes::*; use rustc_span::{Pos, Span}; use rustc_target::spec::abi; diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 091bfba7ca6..4dedf0a23e8 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -4,7 +4,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::{Applicability, DiagnosticBuilder}; +use errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::{Body, Expr, ExprKind, FunctionRetTy, HirId, Local, Pat}; @@ -151,14 +151,11 @@ pub enum TypeAnnotationNeeded { impl Into<errors::DiagnosticId> for TypeAnnotationNeeded { fn into(self) -> errors::DiagnosticId { - syntax::diagnostic_used!(E0282); - syntax::diagnostic_used!(E0283); - syntax::diagnostic_used!(E0284); - errors::DiagnosticId::Error(match self { - Self::E0282 => "E0282".to_string(), - Self::E0283 => "E0283".to_string(), - Self::E0284 => "E0284".to_string(), - }) + match self { + Self::E0282 => errors::error_code!(E0282), + Self::E0283 => errors::error_code!(E0283), + Self::E0284 => errors::error_code!(E0284), + } } } diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs index cfb6d5bd244..b73fb40f637 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -5,6 +5,7 @@ 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::*; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 0d56fc57230..dacd2025da5 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -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::{Applicability, DiagnosticBuilder}; +use errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir::{FunctionRetTy, TyKind}; use rustc_error_codes::*; diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index 7919274c373..a3fdcb44f99 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -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::DiagnosticBuilder; +use errors::{struct_span_err, DiagnosticBuilder}; use rustc_error_codes::*; diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index a22ed940961..839e8588ff0 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -6,7 +6,7 @@ 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::DiagnosticBuilder; +use errors::{struct_span_err, DiagnosticBuilder}; use rustc::session::config::nightly_options; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; @@ -524,11 +524,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.span_label(span, label); if nightly_options::is_nightly_build() { - help!( - err, - "add #![feature(member_constraints)] to the crate attributes \ - to enable" - ); + err.help("add #![feature(member_constraints)] to the crate attributes to enable"); } err.emit(); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 847c61033da..3726e6ace54 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -96,6 +96,12 @@ declare_lint! { } declare_lint! { + pub BINDINGS_WITH_VARIANT_NAME, + Warn, + "detects pattern bindings with the same name as one of the matched variants" +} + +declare_lint! { pub UNUSED_MACROS, Warn, "detects macros that were not used" @@ -459,6 +465,7 @@ declare_lint_pass! { UNREACHABLE_CODE, UNREACHABLE_PATTERNS, OVERLAPPING_PATTERNS, + BINDINGS_WITH_VARIANT_NAME, UNUSED_MACROS, WARNINGS, UNUSED_FEATURES, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 0ac682428d6..ea96b15a162 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -25,17 +25,17 @@ 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::DiagnosticBuilder; +use errors::{struct_span_err, DiagnosticBuilder}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync; +use rustc_error_codes::*; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId}; -use rustc_span::{symbol::Symbol, MultiSpan, Span}; -use std::slice; +use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; use syntax::ast; use syntax::util::lev_distance::find_best_match_for_name; -use rustc_error_codes::*; +use std::slice; /// Information about the registered lints. /// @@ -290,7 +290,8 @@ impl LintStore { CheckLintNameResult::Ok(_) => None, CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)), CheckLintNameResult::NoLint(suggestion) => { - let mut err = struct_err!(sess, E0602, "unknown lint: `{}`", lint_name); + let mut err = + struct_span_err!(sess, DUMMY_SP, E0602, "unknown lint: `{}`", lint_name); if let Some(suggestion) = suggestion { err.help(&format!("did you mean: `{}`", suggestion)); diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 78d01ff4fed..abd52a9de50 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -5,7 +5,7 @@ use crate::lint::builtin; use crate::lint::context::{CheckLintNameResult, LintStore}; use crate::lint::{self, Level, Lint, LintId, LintSource}; use crate::session::Session; -use errors::{Applicability, DiagnosticBuilder}; +use errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir::HirId; @@ -274,13 +274,14 @@ impl<'a> LintLevelsBuilder<'a> { let tool_name = if meta_item.path.segments.len() > 1 { let tool_ident = meta_item.path.segments[0].ident; if !attr::is_known_lint_tool(tool_ident) { - span_err!( + struct_span_err!( sess, tool_ident.span, E0710, "an unknown tool name found in scoped lint: `{}`", pprust::path_to_string(&meta_item.path), - ); + ) + .emit(); continue; } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 220560a67e0..6f59df01a52 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -14,6 +14,7 @@ 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_hir as hir; use rustc_hir::def_id::DefId; @@ -184,7 +185,8 @@ impl LanguageItemCollector<'tcx> { span, E0152, "duplicate lang item found: `{}`.", - name), + name + ), None => { match self.tcx.extern_crate(item_def_id) { Some(ExternCrate {dependency_of, ..}) => { @@ -204,7 +206,7 @@ impl LanguageItemCollector<'tcx> { }, }; if let Some(span) = self.tcx.hir().span_if_local(original_def_id) { - span_note!(&mut err, span, "first defined here."); + err.span_note(span, "first defined here."); } else { match self.tcx.extern_crate(original_def_id) { Some(ExternCrate {dependency_of, ..}) => { diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 8e6ac165fab..e9e35b7617c 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -6,6 +6,7 @@ use crate::session::config; use crate::hir::intravisit; use crate::hir::intravisit::{NestedVisitorMap, Visitor}; use crate::ty::TyCtxt; +use errors::struct_span_err; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -124,9 +125,12 @@ impl<'a, 'tcx> Context<'a, 'tcx> { self.items.missing.push(lang_items::$item); } } else)* { - span_err!(self.tcx.sess, span, E0264, - "unknown external lang item: `{}`", - name); + struct_span_err!( + self.tcx.sess, span, E0264, + "unknown external lang item: `{}`", + name + ) + .emit(); } } } diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index f54b9231d1a..cb11ac49cec 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -7,7 +7,7 @@ use crate::ty::query::TyCtxtAt; use crate::ty::{self, layout, Ty}; use backtrace::Backtrace; -use errors::DiagnosticBuilder; +use errors::{struct_span_err, DiagnosticBuilder}; use hir::GeneratorKind; use rustc_hir as hir; use rustc_macros::HashStable; diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 172330dbc7e..00251d55706 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -20,7 +20,8 @@ use crate::ty::GenericParamDefKind; use crate::ty::SubtypePredicate; use crate::ty::TypeckTables; use crate::ty::{self, AdtKind, DefIdTree, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; -use errors::{pluralize, Applicability, DiagnosticBuilder, Style}; + +use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 92984b48ae9..f1b830e43fc 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -2,6 +2,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_hir::def_id::DefId; use rustc_span::symbol::{kw, sym, Symbol}; @@ -292,26 +294,28 @@ impl<'tcx> OnUnimplementedFormatString { match generics.params.iter().find(|param| param.name == s) { Some(_) => (), None => { - span_err!( + struct_span_err!( tcx.sess, span, E0230, "there is no parameter `{}` on trait `{}`", s, name - ); + ) + .emit(); result = Err(ErrorReported); } } } // `{:1}` and `{}` are not to be used Position::ArgumentIs(_) | Position::ArgumentImplicitlyIs(_) => { - span_err!( + struct_span_err!( tcx.sess, span, E0231, "only named substitution parameters are allowed" - ); + ) + .emit(); result = Err(ErrorReported); } }, diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 87f7f674dab..370acb53896 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -76,15 +76,15 @@ 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() { - let mut err = struct_span_err!( + errors::struct_span_err!( tcx.sess, span, E0320, "overflow while adding drop-check rules for {}", ty, - ); - err.note(&format!("overflowed on {}", overflow_ty)); - err.emit(); + ) + .note(&format!("overflowed on {}", overflow_ty)) + .emit(); } } diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 520cd3e3852..d1897148838 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -17,6 +17,7 @@ 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_hir::def_id::DefId; use rustc_span::DUMMY_SP; diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index e56955b0e44..35608540383 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -9,11 +9,7 @@ use crate::ty::query::Query; use crate::ty::tls; use crate::ty::{self, TyCtxt}; -use errors::Diagnostic; -use errors::DiagnosticBuilder; -use errors::FatalError; -use errors::Handler; -use errors::Level; +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}; |
