turn the RFC1592 warnings into hard errors

The warnings have already reached stable

The test rfc1592_deprecated is covered by `bad_sized` and
`unsized6`.

Fixes #33242
Fixes #33243
This commit is contained in:
Ariel Ben-Yehuda 2016-09-01 13:34:56 +03:00
parent 7a187c39c7
commit 7b92d05804
28 changed files with 50 additions and 314 deletions

View File

@ -186,18 +186,6 @@ declare_lint! {
"detects super or self keywords at the beginning of global path" "detects super or self keywords at the beginning of global path"
} }
declare_lint! {
pub UNSIZED_IN_TUPLE,
Warn,
"unsized types in the interior of a tuple were erroneously allowed"
}
declare_lint! {
pub OBJECT_UNSAFE_FRAGMENT,
Warn,
"object-unsafe non-principal fragments in object types were erroneously allowed"
}
declare_lint! { declare_lint! {
pub LIFETIME_UNDERSCORE, pub LIFETIME_UNDERSCORE,
Warn, Warn,
@ -239,8 +227,6 @@ impl LintPass for HardwiredLints {
OVERLAPPING_INHERENT_IMPLS, OVERLAPPING_INHERENT_IMPLS,
RENAMED_AND_REMOVED_LINTS, RENAMED_AND_REMOVED_LINTS,
SUPER_OR_SELF_IN_GLOBAL_PATH, SUPER_OR_SELF_IN_GLOBAL_PATH,
UNSIZED_IN_TUPLE,
OBJECT_UNSAFE_FRAGMENT,
HR_LIFETIME_IN_ASSOC_TYPE, HR_LIFETIME_IN_ASSOC_TYPE,
LIFETIME_UNDERSCORE LIFETIME_UNDERSCORE
) )

View File

@ -55,7 +55,6 @@ impl FreeRegionMap {
match *predicate { match *predicate {
ty::Predicate::Projection(..) | ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) | ty::Predicate::Trait(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) | ty::Predicate::Equate(..) |
ty::Predicate::WellFormed(..) | ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) | ty::Predicate::ObjectSafe(..) |

View File

@ -36,27 +36,23 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
use std::cmp; use std::cmp;
use std::fmt; use std::fmt;
use syntax::ast;
use syntax_pos::Span; use syntax_pos::Span;
use errors::DiagnosticBuilder; use errors::DiagnosticBuilder;
#[derive(Debug, PartialEq, Eq, Hash)] #[derive(Debug, PartialEq, Eq, Hash)]
pub struct TraitErrorKey<'tcx> { pub struct TraitErrorKey<'tcx> {
span: Span, span: Span,
warning_node_id: Option<ast::NodeId>,
predicate: ty::Predicate<'tcx> predicate: ty::Predicate<'tcx>
} }
impl<'a, 'gcx, 'tcx> TraitErrorKey<'tcx> { impl<'a, 'gcx, 'tcx> TraitErrorKey<'tcx> {
fn from_error(infcx: &InferCtxt<'a, 'gcx, 'tcx>, fn from_error(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
e: &FulfillmentError<'tcx>, e: &FulfillmentError<'tcx>) -> Self {
warning_node_id: Option<ast::NodeId>) -> Self {
let predicate = let predicate =
infcx.resolve_type_vars_if_possible(&e.obligation.predicate); infcx.resolve_type_vars_if_possible(&e.obligation.predicate);
TraitErrorKey { TraitErrorKey {
span: e.obligation.cause.span, span: e.obligation.cause.span,
predicate: infcx.tcx.erase_regions(&predicate), predicate: infcx.tcx.erase_regions(&predicate)
warning_node_id: warning_node_id
} }
} }
} }
@ -64,22 +60,13 @@ impl<'a, 'gcx, 'tcx> TraitErrorKey<'tcx> {
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn report_fulfillment_errors(&self, errors: &Vec<FulfillmentError<'tcx>>) { pub fn report_fulfillment_errors(&self, errors: &Vec<FulfillmentError<'tcx>>) {
for error in errors { for error in errors {
self.report_fulfillment_error(error, None); self.report_fulfillment_error(error);
}
}
pub fn report_fulfillment_errors_as_warnings(&self,
errors: &Vec<FulfillmentError<'tcx>>,
node_id: ast::NodeId) {
for error in errors {
self.report_fulfillment_error(error, Some(node_id));
} }
} }
fn report_fulfillment_error(&self, fn report_fulfillment_error(&self,
error: &FulfillmentError<'tcx>, error: &FulfillmentError<'tcx>) {
warning_node_id: Option<ast::NodeId>) { let error_key = TraitErrorKey::from_error(self, error);
let error_key = TraitErrorKey::from_error(self, error, warning_node_id);
debug!("report_fulfillment_errors({:?}) - key={:?}", debug!("report_fulfillment_errors({:?}) - key={:?}",
error, error_key); error, error_key);
if !self.reported_trait_errors.borrow_mut().insert(error_key) { if !self.reported_trait_errors.borrow_mut().insert(error_key) {
@ -88,10 +75,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} }
match error.code { match error.code {
FulfillmentErrorCode::CodeSelectionError(ref e) => { FulfillmentErrorCode::CodeSelectionError(ref e) => {
self.report_selection_error(&error.obligation, e, warning_node_id); self.report_selection_error(&error.obligation, e);
} }
FulfillmentErrorCode::CodeProjectionError(ref e) => { FulfillmentErrorCode::CodeProjectionError(ref e) => {
self.report_projection_error(&error.obligation, e, warning_node_id); self.report_projection_error(&error.obligation, e);
} }
FulfillmentErrorCode::CodeAmbiguity => { FulfillmentErrorCode::CodeAmbiguity => {
self.maybe_report_ambiguity(&error.obligation); self.maybe_report_ambiguity(&error.obligation);
@ -101,8 +88,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn report_projection_error(&self, fn report_projection_error(&self,
obligation: &PredicateObligation<'tcx>, obligation: &PredicateObligation<'tcx>,
error: &MismatchedProjectionTypes<'tcx>, error: &MismatchedProjectionTypes<'tcx>)
warning_node_id: Option<ast::NodeId>)
{ {
let predicate = let predicate =
self.resolve_type_vars_if_possible(&obligation.predicate); self.resolve_type_vars_if_possible(&obligation.predicate);
@ -110,16 +96,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if predicate.references_error() { if predicate.references_error() {
return return
} }
if let Some(warning_node_id) = warning_node_id {
self.tcx.sess.add_lint(
::lint::builtin::UNSIZED_IN_TUPLE,
warning_node_id,
obligation.cause.span,
format!("type mismatch resolving `{}`: {}",
predicate,
error.err));
return
}
self.probe(|_| { self.probe(|_| {
let origin = TypeOrigin::Misc(obligation.cause.span); let origin = TypeOrigin::Misc(obligation.cause.span);
let err_buf; let err_buf;
@ -442,8 +419,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn report_selection_error(&self, pub fn report_selection_error(&self,
obligation: &PredicateObligation<'tcx>, obligation: &PredicateObligation<'tcx>,
error: &SelectionError<'tcx>, error: &SelectionError<'tcx>)
warning_node_id: Option<ast::NodeId>)
{ {
let span = obligation.cause.span; let span = obligation.cause.span;
let mut err = match *error { let mut err = match *error {
@ -466,16 +442,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
} else { } else {
let trait_ref = trait_predicate.to_poly_trait_ref(); let trait_ref = trait_predicate.to_poly_trait_ref();
if let Some(warning_node_id) = warning_node_id {
self.tcx.sess.add_lint(
::lint::builtin::UNSIZED_IN_TUPLE,
warning_node_id,
obligation.cause.span,
format!("the trait bound `{}` is not satisfied",
trait_ref.to_predicate()));
return;
}
let mut err = struct_span_err!(self.tcx.sess, span, E0277, let mut err = struct_span_err!(self.tcx.sess, span, E0277,
"the trait bound `{}` is not satisfied", "the trait bound `{}` is not satisfied",
trait_ref.to_predicate()); trait_ref.to_predicate());
@ -541,15 +507,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Predicate::ObjectSafe(trait_def_id) => { ty::Predicate::ObjectSafe(trait_def_id) => {
let violations = self.tcx.object_safety_violations(trait_def_id); let violations = self.tcx.object_safety_violations(trait_def_id);
let err = self.tcx.report_object_safety_error(span, self.tcx.report_object_safety_error(span,
trait_def_id, trait_def_id,
warning_node_id, violations)
violations);
if let Some(err) = err {
err
} else {
return;
}
} }
ty::Predicate::ClosureKind(closure_def_id, kind) => { ty::Predicate::ClosureKind(closure_def_id, kind) => {
@ -577,13 +537,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// (which may fail). // (which may fail).
span_bug!(span, "WF predicate not satisfied for {:?}", ty); span_bug!(span, "WF predicate not satisfied for {:?}", ty);
} }
ty::Predicate::Rfc1592(ref data) => {
span_bug!(
obligation.cause.span,
"RFC1592 predicate not satisfied for {:?}",
data);
}
} }
} }
} }
@ -605,14 +558,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
TraitNotObjectSafe(did) => { TraitNotObjectSafe(did) => {
let violations = self.tcx.object_safety_violations(did); let violations = self.tcx.object_safety_violations(did);
let err = self.tcx.report_object_safety_error(span, did, self.tcx.report_object_safety_error(span, did,
warning_node_id, violations)
violations);
if let Some(err) = err {
err
} else {
return;
}
} }
}; };
self.note_obligation_cause(&mut err, obligation); self.note_obligation_cause(&mut err, obligation);
@ -640,24 +587,17 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn report_object_safety_error(self, pub fn report_object_safety_error(self,
span: Span, span: Span,
trait_def_id: DefId, trait_def_id: DefId,
warning_node_id: Option<ast::NodeId>,
violations: Vec<ObjectSafetyViolation>) violations: Vec<ObjectSafetyViolation>)
-> Option<DiagnosticBuilder<'tcx>> -> DiagnosticBuilder<'tcx>
{ {
let mut err = match warning_node_id { let trait_str = self.item_path_str(trait_def_id);
Some(_) => None, let mut err = struct_span_err!(
None => { self.sess, span, E0038,
let trait_str = self.item_path_str(trait_def_id); "the trait `{}` cannot be made into an object",
let mut db = struct_span_err!( trait_str);
self.sess, span, E0038, err.span_label(span, &format!(
"the trait `{}` cannot be made into an object", "the trait `{}` cannot be made into an object", trait_str
trait_str); ));
db.span_label(span,
&format!("the trait `{}` cannot be made \
into an object", trait_str));
Some(db)
}
};
let mut reported_violations = FnvHashSet(); let mut reported_violations = FnvHashSet();
for violation in violations { for violation in violations {
@ -697,19 +637,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
&buf &buf
} }
}; };
match (warning_node_id, &mut err) { err.note(note);
(Some(node_id), &mut None) => {
self.sess.add_lint(
::lint::builtin::OBJECT_UNSAFE_FRAGMENT,
node_id,
span,
note.to_string());
}
(None, &mut Some(ref mut err)) => {
err.note(note);
}
_ => unreachable!()
}
} }
err err
} }

View File

@ -57,9 +57,6 @@ pub struct FulfillmentContext<'tcx> {
// fulfillment context. // fulfillment context.
predicates: ObligationForest<PendingPredicateObligation<'tcx>>, predicates: ObligationForest<PendingPredicateObligation<'tcx>>,
// A list of new obligations due to RFC1592.
rfc1592_obligations: Vec<PredicateObligation<'tcx>>,
// A set of constraints that regionck must validate. Each // A set of constraints that regionck must validate. Each
// constraint has the form `T:'a`, meaning "some type `T` must // constraint has the form `T:'a`, meaning "some type `T` must
// outlive the lifetime 'a". These constraints derive from // outlive the lifetime 'a". These constraints derive from
@ -192,7 +189,6 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
pub fn new() -> FulfillmentContext<'tcx> { pub fn new() -> FulfillmentContext<'tcx> {
FulfillmentContext { FulfillmentContext {
predicates: ObligationForest::new(), predicates: ObligationForest::new(),
rfc1592_obligations: Vec::new(),
region_obligations: NodeMap(), region_obligations: NodeMap(),
deferred_obligations: vec![], deferred_obligations: vec![],
} }
@ -275,13 +271,6 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
}); });
} }
pub fn register_rfc1592_obligation(&mut self,
_infcx: &InferCtxt<'a, 'gcx, 'tcx>,
obligation: PredicateObligation<'tcx>)
{
self.rfc1592_obligations.push(obligation);
}
pub fn region_obligations(&self, pub fn region_obligations(&self,
body_id: ast::NodeId) body_id: ast::NodeId)
-> &[RegionObligation<'tcx>] -> &[RegionObligation<'tcx>]
@ -292,21 +281,6 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
} }
} }
pub fn select_rfc1592_obligations(&mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>>
{
while !self.rfc1592_obligations.is_empty() {
for obligation in mem::replace(&mut self.rfc1592_obligations, Vec::new()) {
self.register_predicate_obligation(infcx, obligation);
}
self.select_all_or_error(infcx)?;
}
Ok(())
}
pub fn select_all_or_error(&mut self, pub fn select_all_or_error(&mut self,
infcx: &InferCtxt<'a, 'gcx, 'tcx>) infcx: &InferCtxt<'a, 'gcx, 'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>> -> Result<(),Vec<FulfillmentError<'tcx>>>
@ -362,7 +336,6 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
let outcome = self.predicates.process_obligations(&mut FulfillProcessor { let outcome = self.predicates.process_obligations(&mut FulfillProcessor {
selcx: selcx, selcx: selcx,
region_obligations: &mut self.region_obligations, region_obligations: &mut self.region_obligations,
rfc1592_obligations: &mut self.rfc1592_obligations,
deferred_obligations: &mut self.deferred_obligations deferred_obligations: &mut self.deferred_obligations
}); });
debug!("select: outcome={:?}", outcome); debug!("select: outcome={:?}", outcome);
@ -398,7 +371,6 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
struct FulfillProcessor<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> { struct FulfillProcessor<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> {
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>,
region_obligations: &'a mut NodeMap<Vec<RegionObligation<'tcx>>>, region_obligations: &'a mut NodeMap<Vec<RegionObligation<'tcx>>>,
rfc1592_obligations: &'a mut Vec<PredicateObligation<'tcx>>,
deferred_obligations: &'a mut Vec<DeferredObligation<'tcx>> deferred_obligations: &'a mut Vec<DeferredObligation<'tcx>>
} }
@ -413,7 +385,6 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
process_predicate(self.selcx, process_predicate(self.selcx,
obligation, obligation,
self.region_obligations, self.region_obligations,
self.rfc1592_obligations,
self.deferred_obligations) self.deferred_obligations)
.map(|os| os.map(|os| os.into_iter().map(|o| PendingPredicateObligation { .map(|os| os.map(|os| os.into_iter().map(|o| PendingPredicateObligation {
obligation: o, obligation: o,
@ -455,7 +426,6 @@ fn process_predicate<'a, 'gcx, 'tcx>(
selcx: &mut SelectionContext<'a, 'gcx, 'tcx>, selcx: &mut SelectionContext<'a, 'gcx, 'tcx>,
pending_obligation: &mut PendingPredicateObligation<'tcx>, pending_obligation: &mut PendingPredicateObligation<'tcx>,
region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>, region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>,
rfc1592_obligations: &mut Vec<PredicateObligation<'tcx>>,
deferred_obligations: &mut Vec<DeferredObligation<'tcx>>) deferred_obligations: &mut Vec<DeferredObligation<'tcx>>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>, -> Result<Option<Vec<PredicateObligation<'tcx>>>,
FulfillmentErrorCode<'tcx>> FulfillmentErrorCode<'tcx>>
@ -644,14 +614,6 @@ fn process_predicate<'a, 'gcx, 'tcx>(
s => Ok(s) s => Ok(s)
} }
} }
ty::Predicate::Rfc1592(ref inner) => {
rfc1592_obligations.push(PredicateObligation {
predicate: ty::Predicate::clone(inner),
..obligation.clone()
});
Ok(Some(vec![]))
}
} }
} }

View File

@ -153,7 +153,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
ty::Predicate::TypeOutlives(..) | ty::Predicate::TypeOutlives(..) |
ty::Predicate::RegionOutlives(..) | ty::Predicate::RegionOutlives(..) |
ty::Predicate::ClosureKind(..) | ty::Predicate::ClosureKind(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) => { ty::Predicate::Equate(..) => {
false false
} }
@ -184,7 +183,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
ty::Predicate::Projection(..) | ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) | ty::Predicate::Trait(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) | ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) | ty::Predicate::RegionOutlives(..) |
ty::Predicate::WellFormed(..) | ty::Predicate::WellFormed(..) |

View File

@ -513,8 +513,6 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
} }
match obligation.predicate { match obligation.predicate {
ty::Predicate::Rfc1592(..) => EvaluatedToOk,
ty::Predicate::Trait(ref t) => { ty::Predicate::Trait(ref t) => {
assert!(!t.has_escaping_regions()); assert!(!t.has_escaping_regions());
let obligation = obligation.with(t.clone()); let obligation = obligation.with(t.clone());
@ -1779,8 +1777,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::TyStr | ty::TySlice(_) | ty::TyTrait(..) => Never, ty::TyStr | ty::TySlice(_) | ty::TyTrait(..) => Never,
ty::TyTuple(tys) => { ty::TyTuple(tys) => {
// FIXME(#33242) we only need to constrain the last field Where(ty::Binder(tys.last().into_iter().cloned().collect()))
Where(ty::Binder(tys.to_vec()))
} }
ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => { ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => {
@ -2508,12 +2505,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
// T -> Trait. // T -> Trait.
(_, &ty::TyTrait(ref data)) => { (_, &ty::TyTrait(ref data)) => {
let mut object_dids = Some(data.principal.def_id()).into_iter(); let mut object_dids =
// FIXME(#33243) data.builtin_bounds.iter().flat_map(|bound| {
// data.builtin_bounds.iter().flat_map(|bound| { tcx.lang_items.from_builtin_kind(bound).ok()
// tcx.lang_items.from_builtin_kind(bound).ok() })
// }) .chain(Some(data.principal.def_id()));
// .chain(Some(data.principal.def_id()));
if let Some(did) = object_dids.find(|did| { if let Some(did) = object_dids.find(|did| {
!tcx.is_object_safe(*did) !tcx.is_object_safe(*did)
}) { }) {

View File

@ -23,9 +23,6 @@ fn anonymize_predicate<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
ty::Predicate::Trait(ref data) => ty::Predicate::Trait(ref data) =>
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)), ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
ty::Predicate::Rfc1592(ref data) =>
ty::Predicate::Rfc1592(Box::new(anonymize_predicate(tcx, data))),
ty::Predicate::Equate(ref data) => ty::Predicate::Equate(ref data) =>
ty::Predicate::Equate(tcx.anonymize_late_bound_regions(data)), ty::Predicate::Equate(tcx.anonymize_late_bound_regions(data)),
@ -150,9 +147,6 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
self.stack.extend(predicates); self.stack.extend(predicates);
} }
ty::Predicate::Rfc1592(..) => {
// Nothing to elaborate.
}
ty::Predicate::WellFormed(..) => { ty::Predicate::WellFormed(..) => {
// Currently, we do not elaborate WF predicates, // Currently, we do not elaborate WF predicates,
// although we easily could. // although we easily could.

View File

@ -804,9 +804,6 @@ pub enum Predicate<'tcx> {
/// would be the type parameters. /// would be the type parameters.
Trait(PolyTraitPredicate<'tcx>), Trait(PolyTraitPredicate<'tcx>),
/// A predicate created by RFC1592
Rfc1592(Box<Predicate<'tcx>>),
/// where `T1 == T2`. /// where `T1 == T2`.
Equate(PolyEquatePredicate<'tcx>), Equate(PolyEquatePredicate<'tcx>),
@ -906,8 +903,6 @@ impl<'a, 'gcx, 'tcx> Predicate<'tcx> {
match *self { match *self {
Predicate::Trait(ty::Binder(ref data)) => Predicate::Trait(ty::Binder(ref data)) =>
Predicate::Trait(ty::Binder(data.subst(tcx, substs))), Predicate::Trait(ty::Binder(data.subst(tcx, substs))),
Predicate::Rfc1592(ref pi) =>
Predicate::Rfc1592(Box::new(pi.subst_supertrait(tcx, trait_ref))),
Predicate::Equate(ty::Binder(ref data)) => Predicate::Equate(ty::Binder(ref data)) =>
Predicate::Equate(ty::Binder(data.subst(tcx, substs))), Predicate::Equate(ty::Binder(data.subst(tcx, substs))),
Predicate::RegionOutlives(ty::Binder(ref data)) => Predicate::RegionOutlives(ty::Binder(ref data)) =>
@ -1108,9 +1103,6 @@ impl<'tcx> Predicate<'tcx> {
ty::Predicate::Trait(ref data) => { ty::Predicate::Trait(ref data) => {
data.skip_binder().input_types().collect() data.skip_binder().input_types().collect()
} }
ty::Predicate::Rfc1592(ref data) => {
return data.walk_tys()
}
ty::Predicate::Equate(ty::Binder(ref data)) => { ty::Predicate::Equate(ty::Binder(ref data)) => {
vec![data.0, data.1] vec![data.0, data.1]
} }
@ -1148,7 +1140,6 @@ impl<'tcx> Predicate<'tcx> {
Predicate::Trait(ref t) => { Predicate::Trait(ref t) => {
Some(t.to_poly_trait_ref()) Some(t.to_poly_trait_ref())
} }
Predicate::Rfc1592(..) |
Predicate::Projection(..) | Predicate::Projection(..) |
Predicate::Equate(..) | Predicate::Equate(..) |
Predicate::RegionOutlives(..) | Predicate::RegionOutlives(..) |
@ -1820,10 +1811,10 @@ impl<'a, 'tcx> AdtDefData<'tcx, 'tcx> {
} }
TyTuple(ref tys) => { TyTuple(ref tys) => {
// FIXME(#33242) we only need to constrain the last field match tys.last() {
tys.iter().flat_map(|ty| { None => vec![],
self.sized_constraint_for_ty(tcx, stack, ty) Some(ty) => self.sized_constraint_for_ty(tcx, stack, ty)
}).collect() }
} }
TyEnum(adt, substs) | TyStruct(adt, substs) => { TyEnum(adt, substs) | TyStruct(adt, substs) => {

View File

@ -178,9 +178,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::Predicate<'a> {
ty::Predicate::WellFormed(ty) => { ty::Predicate::WellFormed(ty) => {
tcx.lift(&ty).map(ty::Predicate::WellFormed) tcx.lift(&ty).map(ty::Predicate::WellFormed)
} }
ty::Predicate::Rfc1592(box ref a) => {
tcx.lift(a).map(|a| ty::Predicate::Rfc1592(Box::new(a)))
}
ty::Predicate::ClosureKind(closure_def_id, kind) => { ty::Predicate::ClosureKind(closure_def_id, kind) => {
Some(ty::Predicate::ClosureKind(closure_def_id, kind)) Some(ty::Predicate::ClosureKind(closure_def_id, kind))
} }
@ -790,8 +787,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
match *self { match *self {
ty::Predicate::Trait(ref a) => ty::Predicate::Trait(ref a) =>
ty::Predicate::Trait(a.fold_with(folder)), ty::Predicate::Trait(a.fold_with(folder)),
ty::Predicate::Rfc1592(ref a) =>
ty::Predicate::Rfc1592(a.fold_with(folder)),
ty::Predicate::Equate(ref binder) => ty::Predicate::Equate(ref binder) =>
ty::Predicate::Equate(binder.fold_with(folder)), ty::Predicate::Equate(binder.fold_with(folder)),
ty::Predicate::RegionOutlives(ref binder) => ty::Predicate::RegionOutlives(ref binder) =>
@ -812,7 +807,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self { match *self {
ty::Predicate::Trait(ref a) => a.visit_with(visitor), ty::Predicate::Trait(ref a) => a.visit_with(visitor),
ty::Predicate::Rfc1592(ref a) => a.visit_with(visitor),
ty::Predicate::Equate(ref binder) => binder.visit_with(visitor), ty::Predicate::Equate(ref binder) => binder.visit_with(visitor),
ty::Predicate::RegionOutlives(ref binder) => binder.visit_with(visitor), ty::Predicate::RegionOutlives(ref binder) => binder.visit_with(visitor),
ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor), ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor),

View File

@ -318,7 +318,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
match predicate { match predicate {
ty::Predicate::Projection(..) | ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) | ty::Predicate::Trait(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) | ty::Predicate::Equate(..) |
ty::Predicate::WellFormed(..) | ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) | ty::Predicate::ObjectSafe(..) |

View File

@ -94,9 +94,6 @@ pub fn predicate_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
} }
ty::Predicate::ClosureKind(..) => { ty::Predicate::ClosureKind(..) => {
} }
ty::Predicate::Rfc1592(ref data) => {
bug!("RFC1592 predicate `{:?}` in predicate_obligations", data);
}
} }
wf.normalize() wf.normalize()
@ -158,7 +155,6 @@ pub fn implied_bounds<'a, 'gcx, 'tcx>(
assert!(!obligation.has_escaping_regions()); assert!(!obligation.has_escaping_regions());
match obligation.predicate { match obligation.predicate {
ty::Predicate::Trait(..) | ty::Predicate::Trait(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) | ty::Predicate::Equate(..) |
ty::Predicate::Projection(..) | ty::Predicate::Projection(..) |
ty::Predicate::ClosureKind(..) | ty::Predicate::ClosureKind(..) |
@ -282,21 +278,14 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
} }
} }
fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>, fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) {
rfc1592: bool) {
if !subty.has_escaping_regions() { if !subty.has_escaping_regions() {
let cause = self.cause(cause); let cause = self.cause(cause);
match self.infcx.tcx.trait_ref_for_builtin_bound(ty::BoundSized, subty) { match self.infcx.tcx.trait_ref_for_builtin_bound(ty::BoundSized, subty) {
Ok(trait_ref) => { Ok(trait_ref) => {
let predicate = trait_ref.to_predicate();
let predicate = if rfc1592 {
ty::Predicate::Rfc1592(box predicate)
} else {
predicate
};
self.out.push( self.out.push(
traits::Obligation::new(cause, traits::Obligation::new(cause,
predicate)); trait_ref.to_predicate()));
} }
Err(ErrorReported) => { } Err(ErrorReported) => { }
} }
@ -326,13 +315,13 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
ty::TySlice(subty) | ty::TySlice(subty) |
ty::TyArray(subty, _) => { ty::TyArray(subty, _) => {
self.require_sized(subty, traits::SliceOrArrayElem, false); self.require_sized(subty, traits::SliceOrArrayElem);
} }
ty::TyTuple(ref tys) => { ty::TyTuple(ref tys) => {
if let Some((_last, rest)) = tys.split_last() { if let Some((_last, rest)) = tys.split_last() {
for elem in rest { for elem in rest {
self.require_sized(elem, traits::TupleElem, true); self.require_sized(elem, traits::TupleElem);
} }
} }
} }
@ -401,22 +390,15 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
let cause = self.cause(traits::MiscObligation); let cause = self.cause(traits::MiscObligation);
// FIXME(#33243): remove RFC1592
self.out.push(traits::Obligation::new(
cause.clone(),
ty::Predicate::ObjectSafe(data.principal.def_id())
));
let component_traits = let component_traits =
data.builtin_bounds.iter().flat_map(|bound| { data.builtin_bounds.iter().flat_map(|bound| {
tcx.lang_items.from_builtin_kind(bound).ok() tcx.lang_items.from_builtin_kind(bound).ok()
}); })
// .chain(Some(data.principal.def_id())); .chain(Some(data.principal.def_id()));
self.out.extend( self.out.extend(
component_traits.map(|did| { traits::Obligation::new( component_traits.map(|did| { traits::Obligation::new(
cause.clone(), cause.clone(),
ty::Predicate::Rfc1592( ty::Predicate::ObjectSafe(did)
box ty::Predicate::ObjectSafe(did)
)
)}) )})
); );
} }

View File

@ -487,9 +487,6 @@ impl<'tcx> fmt::Debug for ty::Predicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
ty::Predicate::Trait(ref a) => write!(f, "{:?}", a), ty::Predicate::Trait(ref a) => write!(f, "{:?}", a),
ty::Predicate::Rfc1592(ref a) => {
write!(f, "RFC1592({:?})", a)
}
ty::Predicate::Equate(ref pair) => write!(f, "{:?}", pair), ty::Predicate::Equate(ref pair) => write!(f, "{:?}", pair),
ty::Predicate::RegionOutlives(ref pair) => write!(f, "{:?}", pair), ty::Predicate::RegionOutlives(ref pair) => write!(f, "{:?}", pair),
ty::Predicate::TypeOutlives(ref pair) => write!(f, "{:?}", pair), ty::Predicate::TypeOutlives(ref pair) => write!(f, "{:?}", pair),
@ -1083,7 +1080,6 @@ impl<'tcx> fmt::Display for ty::Predicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
ty::Predicate::Trait(ref data) => write!(f, "{}", data), ty::Predicate::Trait(ref data) => write!(f, "{}", data),
ty::Predicate::Rfc1592(ref data) => write!(f, "{}", data),
ty::Predicate::Equate(ref predicate) => write!(f, "{}", predicate), ty::Predicate::Equate(ref predicate) => write!(f, "{}", predicate),
ty::Predicate::RegionOutlives(ref predicate) => write!(f, "{}", predicate), ty::Predicate::RegionOutlives(ref predicate) => write!(f, "{}", predicate),
ty::Predicate::TypeOutlives(ref predicate) => write!(f, "{}", predicate), ty::Predicate::TypeOutlives(ref predicate) => write!(f, "{}", predicate),

View File

@ -191,14 +191,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
id: LintId::of(ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN), id: LintId::of(ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN),
reference: "RFC 1445 <https://github.com/rust-lang/rfcs/pull/1445>", reference: "RFC 1445 <https://github.com/rust-lang/rfcs/pull/1445>",
}, },
FutureIncompatibleInfo {
id: LintId::of(UNSIZED_IN_TUPLE),
reference: "issue #33242 <https://github.com/rust-lang/rust/issues/33242>",
},
FutureIncompatibleInfo {
id: LintId::of(OBJECT_UNSAFE_FRAGMENT),
reference: "issue #33243 <https://github.com/rust-lang/rust/issues/33243>",
},
FutureIncompatibleInfo { FutureIncompatibleInfo {
id: LintId::of(HR_LIFETIME_IN_ASSOC_TYPE), id: LintId::of(HR_LIFETIME_IN_ASSOC_TYPE),
reference: "issue #33685 <https://github.com/rust-lang/rust/issues/33685>", reference: "issue #33685 <https://github.com/rust-lang/rust/issues/33685>",

View File

@ -479,9 +479,6 @@ pub fn enc_predicate<'a, 'tcx>(w: &mut Cursor<Vec<u8>>,
p: &ty::Predicate<'tcx>) p: &ty::Predicate<'tcx>)
{ {
match *p { match *p {
ty::Predicate::Rfc1592(..) => {
bug!("RFC1592 predicate in metadata `{:?}`", p);
}
ty::Predicate::Trait(ref trait_ref) => { ty::Predicate::Trait(ref trait_ref) => {
write!(w, "t"); write!(w, "t");
enc_trait_ref(w, cx, trait_ref.0.trait_ref); enc_trait_ref(w, cx, trait_ref.0.trait_ref);

View File

@ -1019,10 +1019,6 @@ impl<'tcx> MirMapPass<'tcx> for QualifyAndPromoteConstants {
if let Err(err) = fulfillment_cx.select_all_or_error(&infcx) { if let Err(err) = fulfillment_cx.select_all_or_error(&infcx) {
infcx.report_fulfillment_errors(&err); infcx.report_fulfillment_errors(&err);
} }
if let Err(errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
infcx.report_fulfillment_errors_as_warnings(&errors, id);
}
}); });
} }
} }

View File

@ -1128,8 +1128,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
tcx.astconv_object_safety_violations(principal.def_id()); tcx.astconv_object_safety_violations(principal.def_id());
if !object_safety_violations.is_empty() { if !object_safety_violations.is_empty() {
tcx.report_object_safety_error( tcx.report_object_safety_error(
span, principal.def_id(), None, object_safety_violations) span, principal.def_id(), object_safety_violations)
.unwrap().emit(); .emit();
return tcx.types.err; return tcx.types.err;
} }

View File

@ -165,7 +165,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty::Predicate::TypeOutlives(..) => None, ty::Predicate::TypeOutlives(..) => None,
ty::Predicate::WellFormed(..) => None, ty::Predicate::WellFormed(..) => None,
ty::Predicate::ObjectSafe(..) => None, ty::Predicate::ObjectSafe(..) => None,
ty::Predicate::Rfc1592(..) => None,
// NB: This predicate is created by breaking down a // NB: This predicate is created by breaking down a
// `ClosureType: FnFoo()` predicate, where // `ClosureType: FnFoo()` predicate, where

View File

@ -484,7 +484,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
// Object safety violations or miscellaneous. // Object safety violations or miscellaneous.
Err(err) => { Err(err) => {
self.report_selection_error(&obligation, &err, None); self.report_selection_error(&obligation, &err);
// Treat this like an obligation and follow through // Treat this like an obligation and follow through
// with the unsizing - the lack of a coercion should // with the unsizing - the lack of a coercion should
// be silent, as it causes a type mismatch later. // be silent, as it causes a type mismatch later.

View File

@ -111,10 +111,6 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
return Err(()); return Err(());
} }
if let Err(ref errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
infcx.report_fulfillment_errors_as_warnings(errors, drop_impl_node_id);
}
let free_regions = FreeRegionMap::new(); let free_regions = FreeRegionMap::new();
infcx.resolve_regions_and_report_errors(&free_regions, drop_impl_node_id); infcx.resolve_regions_and_report_errors(&free_regions, drop_impl_node_id);
Ok(()) Ok(())

View File

@ -496,7 +496,6 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
ty::Predicate::WellFormed(..) | ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) | ty::Predicate::ObjectSafe(..) |
ty::Predicate::ClosureKind(..) | ty::Predicate::ClosureKind(..) |
ty::Predicate::Rfc1592(..) |
ty::Predicate::TypeOutlives(..) => { ty::Predicate::TypeOutlives(..) => {
None None
} }

View File

@ -505,10 +505,6 @@ pub fn check_item_bodies(ccx: &CrateCtxt) -> CompileResult {
if let Err(errors) = fulfillment_cx.select_all_or_error(&infcx) { if let Err(errors) = fulfillment_cx.select_all_or_error(&infcx) {
infcx.report_fulfillment_errors(&errors); infcx.report_fulfillment_errors(&errors);
} }
if let Err(errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
infcx.report_fulfillment_errors_as_warnings(&errors, item_id);
}
}); });
} }
}) })
@ -2245,10 +2241,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Ok(()) => { } Ok(()) => { }
Err(errors) => { self.report_fulfillment_errors(&errors); } Err(errors) => { self.report_fulfillment_errors(&errors); }
} }
if let Err(ref errors) = fulfillment_cx.select_rfc1592_obligations(self) {
self.report_fulfillment_errors_as_warnings(errors, self.body_id);
}
} }
/// Select as many obligations as we can at present. /// Select as many obligations as we can at present.

View File

@ -477,7 +477,6 @@ impl<'tcx> GetTypeParameterBounds<'tcx> for ty::GenericPredicates<'tcx> {
ty::Predicate::TypeOutlives(ref data) => { ty::Predicate::TypeOutlives(ref data) => {
data.skip_binder().0.is_param(def.index) data.skip_binder().0.is_param(def.index)
} }
ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) | ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) | ty::Predicate::RegionOutlives(..) |
ty::Predicate::WellFormed(..) | ty::Predicate::WellFormed(..) |

View File

@ -858,7 +858,6 @@ impl<'a> Clean<WherePredicate> for ty::Predicate<'a> {
Predicate::WellFormed(_) => panic!("not user writable"), Predicate::WellFormed(_) => panic!("not user writable"),
Predicate::ObjectSafe(_) => panic!("not user writable"), Predicate::ObjectSafe(_) => panic!("not user writable"),
Predicate::ClosureKind(..) => panic!("not user writable"), Predicate::ClosureKind(..) => panic!("not user writable"),
Predicate::Rfc1592(..) => panic!("not user writable"),
} }
} }
} }

View File

@ -13,5 +13,7 @@ trait Trait {}
pub fn main() { pub fn main() {
let x: Vec<Trait + Sized> = Vec::new(); let x: Vec<Trait + Sized> = Vec::new();
//~^ ERROR `Trait + Sized: std::marker::Sized` is not satisfied //~^ ERROR `Trait + Sized: std::marker::Sized` is not satisfied
//~| ERROR the trait `std::marker::Sized` cannot be made into an object
//~| ERROR `Trait + Sized: std::marker::Sized` is not satisfied //~| ERROR `Trait + Sized: std::marker::Sized` is not satisfied
//~| ERROR the trait `std::marker::Sized` cannot be made into an object
} }

View File

@ -17,4 +17,5 @@ fn size_of_copy<T: Copy+?Sized>() -> usize { mem::size_of::<T>() }
fn main() { fn main() {
size_of_copy::<Misc+Copy>(); size_of_copy::<Misc+Copy>();
//~^ ERROR `Misc + Copy: std::marker::Copy` is not satisfied //~^ ERROR `Misc + Copy: std::marker::Copy` is not satisfied
//~| ERROR the trait `std::marker::Copy` cannot be made into an object
} }

View File

@ -1,32 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt;
#[deny(warnings)] trait Foo { fn foo(&self) -> (Self, Self); }
//~^ ERROR the trait bound `Self: std::marker::Sized` is not satisfied
//~| WARNING hard error
impl<T: Copy> Foo for T {
fn foo(&self) -> (Self, Self) {
(*self, *self)
}
}
#[deny(warnings)]
fn main() {
assert_eq!((11).foo(), (11, 11));
let junk: Box<fmt::Debug+Sized> = Box::new(42);
//~^ ERROR the trait cannot require that `Self : Sized`
//~| WARNING hard error
let f = format!("{:?}", junk);
assert_eq!(f, "42");
}

View File

@ -14,9 +14,9 @@ trait T {}
fn f1<X: ?Sized>(x: &X) { fn f1<X: ?Sized>(x: &X) {
let _: X; // <-- this is OK, no bindings created, no initializer. let _: X; // <-- this is OK, no bindings created, no initializer.
let _: (isize, (X, isize)); let _: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfie
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
let y: (isize, (X, usize)); //~ERROR `X: std::marker::Sized` is not satisfied let y: (isize, (X, usize));
} }
fn f2<X: ?Sized + T>(x: &X) { fn f2<X: ?Sized + T>(x: &X) {
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied let y: X; //~ERROR `X: std::marker::Sized` is not satisfied

View File

@ -1,29 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt;
trait Foo {
fn foo(&self) -> (Self, Self);
}
impl<T: Copy> Foo for T {
fn foo(&self) -> (Self, Self) {
(*self, *self)
}
}
fn main() {
assert_eq!((11).foo(), (11, 11));
let junk: Box<fmt::Debug+Sized> = Box::new(42);
let f = format!("{:?}", junk);
assert_eq!(f, "42");
}