Skip to content

Commit 2c3e5d3

Browse files
committed
- 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
1 parent 7e393b5 commit 2c3e5d3

File tree

110 files changed

+626
-653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+626
-653
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,6 +3804,7 @@ version = "0.0.0"
38043804
dependencies = [
38053805
"rustc",
38063806
"rustc_error_codes",
3807+
"rustc_errors",
38073808
"rustc_hir",
38083809
"rustc_metadata",
38093810
"rustc_span",
@@ -3818,6 +3819,7 @@ dependencies = [
38183819
"rustc",
38193820
"rustc_data_structures",
38203821
"rustc_error_codes",
3822+
"rustc_errors",
38213823
"rustc_hir",
38223824
"rustc_span",
38233825
"rustc_typeck",

src/librustc/hir/check_attr.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
88
use crate::lint::builtin::UNUSED_ATTRIBUTES;
99
use crate::ty::query::Providers;
1010
use crate::ty::TyCtxt;
11+
12+
use errors::struct_span_err;
1113
use rustc_error_codes::*;
1214
use rustc_hir as hir;
1315
use rustc_hir::def_id::DefId;
@@ -430,21 +432,27 @@ impl CheckAttrVisitor<'tcx> {
430432
// Error on repr(transparent, <anything else>).
431433
if is_transparent && hints.len() > 1 {
432434
let hint_spans: Vec<_> = hint_spans.clone().collect();
433-
span_err!(
435+
struct_span_err!(
434436
self.tcx.sess,
435437
hint_spans,
436438
E0692,
437439
"transparent {} cannot have other repr hints",
438440
target
439-
);
441+
)
442+
.emit();
440443
}
441444
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
442445
if (int_reprs > 1)
443446
|| (is_simd && is_c)
444447
|| (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item)))
445448
{
446-
let hint_spans: Vec<_> = hint_spans.collect();
447-
span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints");
449+
struct_span_err!(
450+
self.tcx.sess,
451+
hint_spans.collect::<Vec<Span>>(),
452+
E0566,
453+
"conflicting representation hints",
454+
)
455+
.emit();
448456
}
449457
}
450458

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use rustc_hir as hir;
6868
use rustc_hir::def_id::DefId;
6969
use rustc_hir::Node;
7070

71-
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
71+
use errors::{struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString};
7272
use rustc_error_codes::*;
7373
use rustc_span::{Pos, Span};
7474
use rustc_target::spec::abi;

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
44
use crate::infer::InferCtxt;
55
use crate::ty::print::Print;
66
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
7-
use errors::{Applicability, DiagnosticBuilder};
7+
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
88
use rustc_hir as hir;
99
use rustc_hir::def::{DefKind, Namespace};
1010
use rustc_hir::{Body, Expr, ExprKind, FunctionRetTy, HirId, Local, Pat};
@@ -151,14 +151,11 @@ pub enum TypeAnnotationNeeded {
151151

152152
impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
153153
fn into(self) -> errors::DiagnosticId {
154-
syntax::diagnostic_used!(E0282);
155-
syntax::diagnostic_used!(E0283);
156-
syntax::diagnostic_used!(E0284);
157-
errors::DiagnosticId::Error(match self {
158-
Self::E0282 => "E0282".to_string(),
159-
Self::E0283 => "E0283".to_string(),
160-
Self::E0284 => "E0284".to_string(),
161-
})
154+
match self {
155+
Self::E0282 => errors::error_code!(E0282),
156+
Self::E0283 => errors::error_code!(E0283),
157+
Self::E0284 => errors::error_code!(E0284),
158+
}
162159
}
163160
}
164161

src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
55
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
66
use crate::util::common::ErrorReported;
77

8+
use errors::struct_span_err;
89
use rustc_error_codes::*;
910

1011
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {

src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! where one region is named and the other is anonymous.
33
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
44
use crate::ty;
5-
use errors::{Applicability, DiagnosticBuilder};
5+
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
66
use rustc_hir::{FunctionRetTy, TyKind};
77

88
use rustc_error_codes::*;

src/librustc/infer/error_reporting/note.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::infer::{self, InferCtxt, SubregionOrigin};
33
use crate::middle::region;
44
use crate::ty::error::TypeError;
55
use crate::ty::{self, Region};
6-
use errors::DiagnosticBuilder;
6+
use errors::{struct_span_err, DiagnosticBuilder};
77

88
use rustc_error_codes::*;
99

src/librustc/infer/opaque_types/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
66
use crate::ty::free_region_map::FreeRegionRelations;
77
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef};
88
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
9-
use errors::DiagnosticBuilder;
9+
use errors::{struct_span_err, DiagnosticBuilder};
1010
use rustc::session::config::nightly_options;
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::sync::Lrc;
@@ -524,11 +524,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
524524
err.span_label(span, label);
525525

526526
if nightly_options::is_nightly_build() {
527-
help!(
528-
err,
529-
"add #![feature(member_constraints)] to the crate attributes \
530-
to enable"
531-
);
527+
err.help("add #![feature(member_constraints)] to the crate attributes to enable");
532528
}
533529

534530
err.emit();

src/librustc/lint/builtin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ declare_lint! {
9595
"detects overlapping patterns"
9696
}
9797

98+
declare_lint! {
99+
pub BINDINGS_WITH_VARIANT_NAME,
100+
Warn,
101+
"detects pattern bindings with the same name as one of the matched variants"
102+
}
103+
98104
declare_lint! {
99105
pub UNUSED_MACROS,
100106
Warn,
@@ -459,6 +465,7 @@ declare_lint_pass! {
459465
UNREACHABLE_CODE,
460466
UNREACHABLE_PATTERNS,
461467
OVERLAPPING_PATTERNS,
468+
BINDINGS_WITH_VARIANT_NAME,
462469
UNUSED_MACROS,
463470
WARNINGS,
464471
UNUSED_FEATURES,

src/librustc/lint/context.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ use crate::middle::privacy::AccessLevels;
2525
use crate::session::Session;
2626
use crate::ty::layout::{LayoutError, LayoutOf, TyLayout};
2727
use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
28-
use errors::DiagnosticBuilder;
28+
use errors::{struct_span_err, DiagnosticBuilder};
2929
use rustc_data_structures::fx::FxHashMap;
3030
use rustc_data_structures::sync;
31+
use rustc_error_codes::*;
3132
use rustc_hir as hir;
3233
use rustc_hir::def_id::{CrateNum, DefId};
33-
use rustc_span::{symbol::Symbol, MultiSpan, Span};
34-
use std::slice;
34+
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
3535
use syntax::ast;
3636
use syntax::util::lev_distance::find_best_match_for_name;
3737

38-
use rustc_error_codes::*;
38+
use std::slice;
3939

4040
/// Information about the registered lints.
4141
///
@@ -290,7 +290,8 @@ impl LintStore {
290290
CheckLintNameResult::Ok(_) => None,
291291
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),
292292
CheckLintNameResult::NoLint(suggestion) => {
293-
let mut err = struct_err!(sess, E0602, "unknown lint: `{}`", lint_name);
293+
let mut err =
294+
struct_span_err!(sess, DUMMY_SP, E0602, "unknown lint: `{}`", lint_name);
294295

295296
if let Some(suggestion) = suggestion {
296297
err.help(&format!("did you mean: `{}`", suggestion));

0 commit comments

Comments
 (0)