Skip to content

Commit 7eb444e

Browse files
committed
Revert "add coherence future-compat warnings for marker-only trait objects"
This reverts commit 7606396.
1 parent e030aa8 commit 7eb444e

File tree

17 files changed

+54
-254
lines changed

17 files changed

+54
-254
lines changed

src/librustc/infer/combine.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
337337
self.infcx.tcx
338338
}
339339

340-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
341-
self.infcx.trait_object_mode()
342-
}
343-
344340
fn tag(&self) -> &'static str {
345341
"Generalizer"
346342
}

src/librustc/infer/equate.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
2929

3030
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
3131

32-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
33-
self.fields.infcx.trait_object_mode()
34-
}
35-
3632
fn a_is_expected(&self) -> bool { self.a_is_expected }
3733

3834
fn relate_item_substs(&mut self,

src/librustc/infer/glb.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::Subtype;
55

66
use traits::ObligationCause;
77
use ty::{self, Ty, TyCtxt};
8-
use ty::relate::{self, Relate, RelateResult, TypeRelation};
8+
use ty::relate::{Relate, RelateResult, TypeRelation};
99

1010
/// "Greatest lower bound" (common subtype)
1111
pub struct Glb<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> {
@@ -26,10 +26,6 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
2626
{
2727
fn tag(&self) -> &'static str { "Glb" }
2828

29-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
30-
self.fields.infcx.trait_object_mode()
31-
}
32-
3329
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
3430

3531
fn a_is_expected(&self) -> bool { self.a_is_expected }

src/librustc/infer/lub.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::Subtype;
55

66
use traits::ObligationCause;
77
use ty::{self, Ty, TyCtxt};
8-
use ty::relate::{self, Relate, RelateResult, TypeRelation};
8+
use ty::relate::{Relate, RelateResult, TypeRelation};
99

1010
/// "Least upper bound" (common supertype)
1111
pub struct Lub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> {
@@ -26,10 +26,6 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
2626
{
2727
fn tag(&self) -> &'static str { "Lub" }
2828

29-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
30-
self.fields.infcx.trait_object_mode()
31-
}
32-
3329
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.tcx() }
3430

3531
fn a_is_expected(&self) -> bool { self.a_is_expected }

src/librustc/infer/mod.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use syntax_pos::{self, Span};
2525
use traits::{self, ObligationCause, PredicateObligations, TraitEngine};
2626
use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
2727
use ty::fold::TypeFoldable;
28-
use ty::relate::{RelateResult, TraitObjectMode};
28+
use ty::relate::RelateResult;
2929
use ty::subst::{Kind, Substs};
3030
use ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
3131
use ty::{FloatVid, IntVid, TyVid};
@@ -171,9 +171,6 @@ pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
171171
// This flag is true while there is an active snapshot.
172172
in_snapshot: Cell<bool>,
173173

174-
// The TraitObjectMode used here,
175-
trait_object_mode: TraitObjectMode,
176-
177174
// A set of constraints that regionck must validate. Each
178175
// constraint has the form `T:'a`, meaning "some type `T` must
179176
// outlive the lifetime 'a". These constraints derive from
@@ -465,7 +462,6 @@ pub struct InferCtxtBuilder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
465462
arena: SyncDroplessArena,
466463
interners: Option<CtxtInterners<'tcx>>,
467464
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
468-
trait_object_mode: TraitObjectMode,
469465
}
470466

471467
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
@@ -475,7 +471,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
475471
arena: SyncDroplessArena::default(),
476472
interners: None,
477473
fresh_tables: None,
478-
trait_object_mode: TraitObjectMode::NoSquash,
479474
}
480475
}
481476
}
@@ -488,12 +483,6 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
488483
self
489484
}
490485

491-
pub fn with_trait_object_mode(mut self, mode: TraitObjectMode) -> Self {
492-
debug!("with_trait_object_mode: setting mode to {:?}", mode);
493-
self.trait_object_mode = mode;
494-
self
495-
}
496-
497486
/// Given a canonical value `C` as a starting point, create an
498487
/// inference context that contains each of the bound values
499488
/// within instantiated as a fresh variable. The `f` closure is
@@ -520,7 +509,6 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
520509
pub fn enter<R>(&'tcx mut self, f: impl for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>) -> R) -> R {
521510
let InferCtxtBuilder {
522511
global_tcx,
523-
trait_object_mode,
524512
ref arena,
525513
ref mut interners,
526514
ref fresh_tables,
@@ -532,7 +520,6 @@ impl<'a, 'gcx, 'tcx> InferCtxtBuilder<'a, 'gcx, 'tcx> {
532520
f(InferCtxt {
533521
tcx,
534522
in_progress_tables,
535-
trait_object_mode,
536523
projection_cache: Default::default(),
537524
type_variables: RefCell::new(type_variable::TypeVariableTable::new()),
538525
int_unification_table: RefCell::new(ut::UnificationTable::new()),
@@ -614,10 +601,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
614601
self.in_snapshot.get()
615602
}
616603

617-
pub fn trait_object_mode(&self) -> TraitObjectMode {
618-
self.trait_object_mode
619-
}
620-
621604
pub fn freshen<T: TypeFoldable<'tcx>>(&self, t: T) -> T {
622605
t.fold_with(&mut self.freshener())
623606
}

src/librustc/infer/nll_relate/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,6 @@ where
372372
self.infcx.tcx
373373
}
374374

375-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
376-
// squashing should only be done in coherence, not NLL
377-
assert_eq!(self.infcx.trait_object_mode(),
378-
relate::TraitObjectMode::NoSquash);
379-
relate::TraitObjectMode::NoSquash
380-
}
381-
382375
fn tag(&self) -> &'static str {
383376
"nll::subtype"
384377
}
@@ -693,13 +686,6 @@ where
693686
self.infcx.tcx
694687
}
695688

696-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
697-
// squashing should only be done in coherence, not NLL
698-
assert_eq!(self.infcx.trait_object_mode(),
699-
relate::TraitObjectMode::NoSquash);
700-
relate::TraitObjectMode::NoSquash
701-
}
702-
703689
fn tag(&self) -> &'static str {
704690
"nll::generalizer"
705691
}

src/librustc/infer/sub.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use traits::Obligation;
55
use ty::{self, Ty, TyCtxt};
66
use ty::TyVar;
77
use ty::fold::TypeFoldable;
8-
use ty::relate::{self, Cause, Relate, RelateResult, TypeRelation};
8+
use ty::relate::{Cause, Relate, RelateResult, TypeRelation};
99
use std::mem;
1010

1111
/// Ensures `a` is made a subtype of `b`. Returns `a` on success.
@@ -33,10 +33,6 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
3333
for Sub<'combine, 'infcx, 'gcx, 'tcx>
3434
{
3535
fn tag(&self) -> &'static str { "Sub" }
36-
fn trait_object_mode(&self) -> relate::TraitObjectMode {
37-
self.fields.infcx.trait_object_mode()
38-
}
39-
4036
fn tcx(&self) -> TyCtxt<'infcx, 'gcx, 'tcx> { self.fields.infcx.tcx }
4137
fn a_is_expected(&self) -> bool { self.a_is_expected }
4238

src/librustc/traits/coherence.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use traits::{self, Normalized, SelectionContext, Obligation, ObligationCause};
1111
use traits::IntercrateMode;
1212
use traits::select::IntercrateAmbiguityCause;
1313
use ty::{self, Ty, TyCtxt};
14-
use ty::relate::TraitObjectMode;
1514
use ty::fold::TypeFoldable;
1615
use ty::subst::Subst;
1716

@@ -55,7 +54,6 @@ pub fn overlapping_impls<'gcx, F1, F2, R>(
5554
impl1_def_id: DefId,
5655
impl2_def_id: DefId,
5756
intercrate_mode: IntercrateMode,
58-
trait_object_mode: TraitObjectMode,
5957
on_overlap: F1,
6058
no_overlap: F2,
6159
) -> R
@@ -66,14 +64,12 @@ where
6664
debug!("overlapping_impls(\
6765
impl1_def_id={:?}, \
6866
impl2_def_id={:?},
69-
intercrate_mode={:?},
70-
trait_object_mode={:?})",
67+
intercrate_mode={:?})",
7168
impl1_def_id,
7269
impl2_def_id,
73-
intercrate_mode,
74-
trait_object_mode);
70+
intercrate_mode);
7571

76-
let overlaps = tcx.infer_ctxt().with_trait_object_mode(trait_object_mode).enter(|infcx| {
72+
let overlaps = tcx.infer_ctxt().enter(|infcx| {
7773
let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode);
7874
overlap(selcx, impl1_def_id, impl2_def_id).is_some()
7975
});
@@ -85,7 +81,7 @@ where
8581
// In the case where we detect an error, run the check again, but
8682
// this time tracking intercrate ambuiguity causes for better
8783
// diagnostics. (These take time and can lead to false errors.)
88-
tcx.infer_ctxt().with_trait_object_mode(trait_object_mode).enter(|infcx| {
84+
tcx.infer_ctxt().enter(|infcx| {
8985
let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode);
9086
selcx.enable_tracking_intercrate_ambiguity_causes();
9187
on_overlap(overlap(selcx, impl1_def_id, impl2_def_id).unwrap())

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
449449
{
450450
let simp = fast_reject::simplify_type(self.tcx,
451451
trait_ref.skip_binder().self_ty(),
452-
true,);
452+
true);
453453
let all_impls = self.tcx.all_impls(trait_ref.def_id());
454454

455455
match simp {

src/librustc/traits/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ pub use self::select::{EvaluationCache, SelectionContext, SelectionCache};
5656
pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError};
5757
pub use self::specialize::{OverlapError, specialization_graph, translate_substs};
5858
pub use self::specialize::find_associated_item;
59-
pub use self::specialize::specialization_graph::FutureCompatOverlapError;
60-
pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
6159
pub use self::engine::{TraitEngine, TraitEngineExt};
6260
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
6361
pub use self::util::{supertraits, supertrait_def_ids, transitive_bounds,

src/librustc/traits/select.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use infer::{InferCtxt, InferOk, TypeFreshener};
3333
use middle::lang_items;
3434
use mir::interpret::GlobalId;
3535
use ty::fast_reject;
36-
use ty::relate::{TypeRelation, TraitObjectMode};
36+
use ty::relate::TypeRelation;
3737
use ty::subst::{Subst, Substs};
3838
use ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
3939

@@ -1416,13 +1416,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
14161416
return false;
14171417
}
14181418

1419-
// Same idea as the above, but for alt trait object modes. These
1420-
// should only be used in intercrate mode - better safe than sorry.
1421-
if self.infcx.trait_object_mode() != TraitObjectMode::NoSquash {
1422-
bug!("using squashing TraitObjectMode outside of intercrate mode? param_env={:?}",
1423-
param_env);
1424-
}
1425-
14261419
// Otherwise, we can use the global cache.
14271420
true
14281421
}
@@ -3580,8 +3573,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35803573
previous: &ty::PolyTraitRef<'tcx>,
35813574
current: &ty::PolyTraitRef<'tcx>,
35823575
) -> bool {
3583-
let mut matcher = ty::_match::Match::new(
3584-
self.tcx(), self.infcx.trait_object_mode());
3576+
let mut matcher = ty::_match::Match::new(self.tcx());
35853577
matcher.relate(previous, current).is_ok()
35863578
}
35873579

src/librustc/traits/specialize/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub mod specialization_graph;
1414
use hir::def_id::DefId;
1515
use infer::{InferCtxt, InferOk};
1616
use lint;
17-
use traits::{self, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine};
1817
use traits::coherence;
1918
use rustc_data_structures::fx::FxHashSet;
2019
use rustc_data_structures::sync::Lrc;
2120
use syntax_pos::DUMMY_SP;
21+
use traits::{self, ObligationCause, TraitEngine};
2222
use traits::select::IntercrateAmbiguityCause;
2323
use ty::{self, TyCtxt, TypeFoldable};
2424
use ty::subst::{Subst, Substs};
@@ -27,7 +27,6 @@ use super::{SelectionContext, FulfillmentContext};
2727
use super::util::impl_trait_ref_and_oblig;
2828

2929
/// Information pertinent to an overlapping impl error.
30-
#[derive(Debug)]
3130
pub struct OverlapError {
3231
pub with_impl: DefId,
3332
pub trait_desc: String,
@@ -311,9 +310,8 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
311310
let insert_result = sg.insert(tcx, impl_def_id);
312311
// Report error if there was one.
313312
let (overlap, used_to_be_allowed) = match insert_result {
314-
Err(overlap) => (Some(overlap), None),
315-
Ok(Some(overlap)) => (Some(overlap.error), Some(overlap.kind)),
316-
Ok(None) => (None, None)
313+
Err(overlap) => (Some(overlap), false),
314+
Ok(opt_overlap) => (opt_overlap, true)
317315
};
318316

319317
if let Some(overlap) = overlap {
@@ -323,20 +321,14 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
323321
String::new(), |ty| {
324322
format!(" for type `{}`", ty)
325323
}),
326-
if used_to_be_allowed.is_some() { " (E0119)" } else { "" }
324+
if used_to_be_allowed { " (E0119)" } else { "" }
327325
);
328326
let impl_span = tcx.sess.source_map().def_span(
329327
tcx.span_of_impl(impl_def_id).unwrap()
330328
);
331-
let mut err = if let Some(kind) = used_to_be_allowed {
332-
let lint = match kind {
333-
FutureCompatOverlapErrorKind::Issue43355 =>
334-
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
335-
FutureCompatOverlapErrorKind::Issue33140 =>
336-
lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS,
337-
};
329+
let mut err = if used_to_be_allowed {
338330
tcx.struct_span_lint_node(
339-
lint,
331+
lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
340332
tcx.hir().as_local_node_id(impl_def_id).unwrap(),
341333
impl_span,
342334
&msg)

0 commit comments

Comments
 (0)