Skip to content

Commit ecb60b3

Browse files
committed
Auto merge of #49799 - hdhoang:46205_deny_incoherent_fundamental_impls, r=<try>
lint: convert incoherent_fundamental_impls into hard error implement #46205 r? @nikomatsakis
2 parents 67712d7 + 70a2d80 commit ecb60b3

File tree

6 files changed

+20
-119
lines changed

6 files changed

+20
-119
lines changed

src/librustc/lint/builtin.rs

-7
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,6 @@ declare_lint! {
206206
"detects generic lifetime arguments in path segments with late bound lifetime parameters"
207207
}
208208

209-
declare_lint! {
210-
pub INCOHERENT_FUNDAMENTAL_IMPLS,
211-
Warn,
212-
"potentially-conflicting impls were erroneously allowed"
213-
}
214-
215209
declare_lint! {
216210
pub DEPRECATED,
217211
Warn,
@@ -306,7 +300,6 @@ impl LintPass for HardwiredLints {
306300
MISSING_FRAGMENT_SPECIFIER,
307301
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
308302
LATE_BOUND_LIFETIME_ARGUMENTS,
309-
INCOHERENT_FUNDAMENTAL_IMPLS,
310303
DEPRECATED,
311304
UNUSED_UNSAFE,
312305
UNUSED_MUT,

src/librustc/traits/specialize/mod.rs

+6-23
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ use ty::{self, TyCtxt, TypeFoldable};
3232
use syntax_pos::DUMMY_SP;
3333
use rustc_data_structures::sync::Lrc;
3434

35-
use lint;
36-
3735
pub mod specialization_graph;
3836

3937
/// Information pertinent to an overlapping impl error.
@@ -329,36 +327,21 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
329327
// This is where impl overlap checking happens:
330328
let insert_result = sg.insert(tcx, impl_def_id);
331329
// Report error if there was one.
332-
let (overlap, used_to_be_allowed) = match insert_result {
333-
Err(overlap) => (Some(overlap), false),
334-
Ok(opt_overlap) => (opt_overlap, true)
335-
};
336-
337-
if let Some(overlap) = overlap {
338-
let msg = format!("conflicting implementations of trait `{}`{}:{}",
330+
if let Some(overlap) = match insert_result {
331+
Err(overlap) => Some(overlap),
332+
Ok(opt_overlap) => opt_overlap,
333+
} {
334+
let msg = format!("conflicting implementations of trait `{}`{}:",
339335
overlap.trait_desc,
340336
overlap.self_desc.clone().map_or(
341337
String::new(), |ty| {
342338
format!(" for type `{}`", ty)
343339
}),
344-
if used_to_be_allowed { " (E0119)" } else { "" }
345340
);
346341
let impl_span = tcx.sess.codemap().def_span(
347342
tcx.span_of_impl(impl_def_id).unwrap()
348343
);
349-
let mut err = if used_to_be_allowed {
350-
tcx.struct_span_lint_node(
351-
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
352-
tcx.hir.as_local_node_id(impl_def_id).unwrap(),
353-
impl_span,
354-
&msg)
355-
} else {
356-
struct_span_err!(tcx.sess,
357-
impl_span,
358-
E0119,
359-
"{}",
360-
msg)
361-
};
344+
let mut err = struct_span_err!(tcx.sess, impl_span, E0119, "{}", msg);
362345

363346
match tcx.span_of_impl(overlap.with_impl) {
364347
Ok(span) => {

src/librustc_lint/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
262262
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
263263
edition: None,
264264
},
265-
FutureIncompatibleInfo {
266-
id: LintId::of(INCOHERENT_FUNDAMENTAL_IMPLS),
267-
reference: "issue #46205 <https://github.com/rust-lang/rust/issues/46205>",
268-
edition: None,
269-
},
270265
FutureIncompatibleInfo {
271266
id: LintId::of(TYVAR_BEHIND_RAW_POINTER),
272267
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
@@ -314,4 +309,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
314309
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
315310
store.register_removed("resolve_trait_on_defaulted_unit",
316311
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
312+
store.register_removed("incoherent_fundamental_impls",
313+
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
317314
}

src/librustc_typeck/coherence/inherent_impls_overlap.rs

+12-45
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
1515
use rustc::traits::{self, IntercrateMode};
1616
use rustc::ty::TyCtxt;
1717

18-
use lint;
19-
2018
pub fn crate_inherent_impls_overlap_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2119
crate_num: CrateNum) {
2220
assert_eq!(crate_num, LOCAL_CRATE);
@@ -30,8 +28,7 @@ struct InherentOverlapChecker<'a, 'tcx: 'a> {
3028

3129
impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
3230
fn check_for_common_items_in_impls(&self, impl1: DefId, impl2: DefId,
33-
overlap: traits::OverlapResult,
34-
used_to_be_allowed: bool) {
31+
overlap: traits::OverlapResult) {
3532

3633
let name_and_namespace = |def_id| {
3734
let item = self.tcx.associated_item(def_id);
@@ -46,21 +43,13 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
4643

4744
for &item2 in &impl_items2[..] {
4845
if (name, namespace) == name_and_namespace(item2) {
49-
let node_id = self.tcx.hir.as_local_node_id(impl1);
50-
let mut err = if used_to_be_allowed && node_id.is_some() {
51-
self.tcx.struct_span_lint_node(
52-
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
53-
node_id.unwrap(),
54-
self.tcx.span_of_impl(item1).unwrap(),
55-
&format!("duplicate definitions with name `{}` (E0592)", name)
56-
)
57-
} else {
58-
struct_span_err!(self.tcx.sess,
59-
self.tcx.span_of_impl(item1).unwrap(),
60-
E0592,
61-
"duplicate definitions with name `{}`",
62-
name)
63-
};
46+
let mut err = struct_span_err!(
47+
self.tcx.sess,
48+
self.tcx.span_of_impl(item1).unwrap(),
49+
E0592,
50+
"duplicate definitions with name `{}`",
51+
name
52+
);
6453

6554
err.span_label(self.tcx.span_of_impl(item1).unwrap(),
6655
format!("duplicate definitions for `{}`", name));
@@ -82,38 +71,16 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
8271

8372
for (i, &impl1_def_id) in impls.iter().enumerate() {
8473
for &impl2_def_id in &impls[(i + 1)..] {
85-
let used_to_be_allowed = traits::overlapping_impls(
74+
traits::overlapping_impls(
8675
self.tcx,
8776
impl1_def_id,
8877
impl2_def_id,
8978
IntercrateMode::Issue43355,
9079
|overlap| {
91-
self.check_for_common_items_in_impls(
92-
impl1_def_id,
93-
impl2_def_id,
94-
overlap,
95-
false,
96-
);
97-
false
80+
self.check_for_common_items_in_impls(impl1_def_id, impl2_def_id, overlap)
9881
},
99-
|| true,
100-
);
101-
102-
if used_to_be_allowed {
103-
traits::overlapping_impls(
104-
self.tcx,
105-
impl1_def_id,
106-
impl2_def_id,
107-
IntercrateMode::Fixed,
108-
|overlap| self.check_for_common_items_in_impls(
109-
impl1_def_id,
110-
impl2_def_id,
111-
overlap,
112-
true,
113-
),
114-
|| (),
115-
);
116-
}
82+
|| (),
83+
)
11784
}
11885
}
11986
}

src/test/compile-fail/issue-43355.rs

-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(incoherent_fundamental_impls)]
12-
1311
pub trait Trait1<X> {
1412
type Output;
1513
}
@@ -24,7 +22,6 @@ impl<X, T> Trait1<X> for T where T: Trait2<X> {
2422

2523
impl<X> Trait1<Box<X>> for A {
2624
//~^ ERROR conflicting implementations of trait
27-
//~| hard error
2825
//~| downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A`
2926
type Output = i32;
3027
}

src/test/run-pass/issue-43355.rs

-36
This file was deleted.

0 commit comments

Comments
 (0)