Skip to content

Commit 562389d

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 766fba3 commit 562389d

File tree

103 files changed

+562
-573
lines changed

Some content is hidden

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

103 files changed

+562
-573
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,6 +3774,7 @@ version = "0.0.0"
37743774
dependencies = [
37753775
"rustc",
37763776
"rustc_error_codes",
3777+
"rustc_errors",
37773778
"rustc_metadata",
37783779
"rustc_span",
37793780
"syntax",
@@ -3787,6 +3788,7 @@ dependencies = [
37873788
"rustc",
37883789
"rustc_data_structures",
37893790
"rustc_error_codes",
3791+
"rustc_errors",
37903792
"rustc_span",
37913793
"rustc_typeck",
37923794
"syntax",

src/librustc/hir/check_attr.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ use crate::hir::def_id::DefId;
88
use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
99
use crate::hir::DUMMY_HIR_ID;
1010
use crate::hir::{self, Attribute, HirId, Item, ItemKind, TraitItem, TraitItemKind};
11-
use crate::lint::builtin::UNUSED_ATTRIBUTES;
11+
use crate::lint::builtin::{CONFLICTING_REPR_HINTS, UNUSED_ATTRIBUTES};
1212
use crate::ty::query::Providers;
1313
use crate::ty::TyCtxt;
1414

15+
use errors::{error_code, struct_span_err};
1516
use rustc_span::Span;
17+
1618
use std::fmt::{self, Display};
1719
use syntax::{attr, symbol::sym};
1820

@@ -192,7 +194,7 @@ impl CheckAttrVisitor<'tcx> {
192194
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(hir_id));
193195
}
194196

195-
self.check_repr(attrs, span, target, item);
197+
self.check_repr(attrs, span, target, item, hir_id);
196198
self.check_used(attrs, target);
197199
}
198200

@@ -353,6 +355,7 @@ impl CheckAttrVisitor<'tcx> {
353355
span: &Span,
354356
target: Target,
355357
item: Option<&Item<'_>>,
358+
hir_id: HirId,
356359
) {
357360
// Extract the names of all repr hints, e.g., [foo, bar, align] for:
358361
// ```
@@ -428,21 +431,29 @@ impl CheckAttrVisitor<'tcx> {
428431
// Error on repr(transparent, <anything else>).
429432
if is_transparent && hints.len() > 1 {
430433
let hint_spans: Vec<_> = hint_spans.clone().collect();
431-
span_err!(
434+
struct_span_err!(
432435
self.tcx.sess,
433436
hint_spans,
434437
E0692,
435438
"transparent {} cannot have other repr hints",
436439
target
437-
);
440+
)
441+
.emit();
438442
}
439443
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
440444
if (int_reprs > 1)
441445
|| (is_simd && is_c)
442446
|| (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item)))
443447
{
444-
let hint_spans: Vec<_> = hint_spans.collect();
445-
span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints");
448+
self.tcx
449+
.struct_span_lint_hir(
450+
CONFLICTING_REPR_HINTS,
451+
hir_id,
452+
hint_spans.collect::<Vec<Span>>(),
453+
"conflicting representation hints",
454+
)
455+
.code(error_code!(E0566))
456+
.emit();
446457
}
447458
}
448459

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use crate::ty::{
6565
Region, Ty, TyCtxt, TypeFoldable,
6666
};
6767

68-
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
68+
use errors::{struct_span_err, Applicability, DiagnosticBuilder, DiagnosticStyledString};
6969
use rustc_error_codes::*;
7070
use rustc_span::{Pos, Span};
7171
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
@@ -5,7 +5,7 @@ use crate::infer::type_variable::TypeVariableOriginKind;
55
use crate::infer::InferCtxt;
66
use crate::ty::print::Print;
77
use crate::ty::{self, DefIdTree, Infer, Ty, TyVar};
8-
use errors::{Applicability, DiagnosticBuilder};
8+
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
99
use rustc_span::Span;
1010
use std::borrow::Cow;
1111
use syntax::source_map::DesugaringKind;
@@ -153,14 +153,11 @@ pub enum TypeAnnotationNeeded {
153153

154154
impl Into<errors::DiagnosticId> for TypeAnnotationNeeded {
155155
fn into(self) -> errors::DiagnosticId {
156-
syntax::diagnostic_used!(E0282);
157-
syntax::diagnostic_used!(E0283);
158-
syntax::diagnostic_used!(E0284);
159-
errors::DiagnosticId::Error(match self {
160-
Self::E0282 => "E0282".to_string(),
161-
Self::E0283 => "E0283".to_string(),
162-
Self::E0284 => "E0284".to_string(),
163-
})
156+
match self {
157+
Self::E0282 => errors::error_code!(E0282),
158+
Self::E0283 => errors::error_code!(E0283),
159+
Self::E0284 => errors::error_code!(E0284),
160+
}
164161
}
165162
}
166163

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
@@ -3,7 +3,7 @@
33
use crate::hir::{FunctionRetTy, TyKind};
44
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
55
use crate::ty;
6-
use errors::{Applicability, DiagnosticBuilder};
6+
use errors::{struct_span_err, Applicability, DiagnosticBuilder};
77

88
use rustc_error_codes::*;
99

src/librustc/infer/error_reporting/note.rs

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

77
use rustc_error_codes::*;
88

src/librustc/infer/opaque_types/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
99
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef};
1010
use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt};
1111
use crate::util::nodemap::DefIdMap;
12-
use errors::DiagnosticBuilder;
12+
use errors::{struct_span_err, DiagnosticBuilder};
1313
use rustc::session::config::nightly_options;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_data_structures::sync::Lrc;
@@ -523,11 +523,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
523523
err.span_label(span, label);
524524

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

533529
err.emit();

src/librustc/lint/builtin.rs

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

98+
declare_lint! {
99+
pub BINDING_VARIANT_NAME,
100+
Warn,
101+
"detects pattern bindings with the same name as one of the matched variants"
102+
}
103+
104+
declare_lint! {
105+
pub CONFLICTING_REPR_HINTS,
106+
Warn,
107+
"detects when more than one `#[repr(..)]` attribute, with different meaning, is applied"
108+
}
109+
98110
declare_lint! {
99111
pub UNUSED_MACROS,
100112
Warn,
@@ -459,6 +471,7 @@ declare_lint_pass! {
459471
UNREACHABLE_CODE,
460472
UNREACHABLE_PATTERNS,
461473
OVERLAPPING_PATTERNS,
474+
BINDING_VARIANT_NAME,
462475
UNUSED_MACROS,
463476
WARNINGS,
464477
UNUSED_FEATURES,

src/librustc/lint/context.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
3232
use crate::util::common::time;
3333
use crate::util::nodemap::FxHashMap;
3434

35-
use errors::DiagnosticBuilder;
35+
use errors::{struct_span_err, DiagnosticBuilder};
3636
use rustc_data_structures::sync::{self, join, par_iter, ParallelIterator};
37-
use rustc_span::{symbol::Symbol, MultiSpan, Span};
37+
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
3838
use std::slice;
3939
use syntax::ast;
4040
use syntax::util::lev_distance::find_best_match_for_name;
@@ -295,7 +295,8 @@ impl LintStore {
295295
CheckLintNameResult::Ok(_) => None,
296296
CheckLintNameResult::Warning(ref msg, _) => Some(sess.struct_warn(msg)),
297297
CheckLintNameResult::NoLint(suggestion) => {
298-
let mut err = struct_err!(sess, E0602, "unknown lint: `{}`", lint_name);
298+
let mut err =
299+
struct_span_err!(sess, DUMMY_SP, E0602, "unknown lint: `{}`", lint_name);
299300

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

0 commit comments

Comments
 (0)