parent
64206b44b9
commit
0d78e40e88
11 changed files with 21 additions and 93 deletions
|
|
@ -880,14 +880,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
|
||||
if let SubregionOrigin::CompareImplMethodObligation {
|
||||
span, item_name, impl_item_def_id, trait_item_def_id, lint_id
|
||||
span, item_name, impl_item_def_id, trait_item_def_id,
|
||||
} = origin {
|
||||
self.report_extra_impl_obligation(span,
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
&format!("`{}: {}`", bound_kind, sub),
|
||||
lint_id)
|
||||
&format!("`{}: {}`", bound_kind, sub))
|
||||
.emit();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,14 +445,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
infer::CompareImplMethodObligation { span,
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
lint_id } => {
|
||||
trait_item_def_id } => {
|
||||
self.report_extra_impl_obligation(span,
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
&format!("`{}: {}`", sup, sub),
|
||||
lint_id)
|
||||
&format!("`{}: {}`", sup, sub))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,10 +274,6 @@ pub enum SubregionOrigin<'tcx> {
|
|||
item_name: ast::Name,
|
||||
impl_item_def_id: DefId,
|
||||
trait_item_def_id: DefId,
|
||||
|
||||
// this is `Some(_)` if this error arises from the bug fix for
|
||||
// #18937. This is a temporary measure.
|
||||
lint_id: Option<ast::NodeId>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1532,14 +1528,12 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
|||
|
||||
traits::ObligationCauseCode::CompareImplMethodObligation { item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
lint_id } =>
|
||||
trait_item_def_id, } =>
|
||||
SubregionOrigin::CompareImplMethodObligation {
|
||||
span: cause.span,
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
lint_id,
|
||||
},
|
||||
|
||||
_ => default(),
|
||||
|
|
|
|||
|
|
@ -161,12 +161,6 @@ declare_lint! {
|
|||
"patterns in functions without body were erroneously allowed"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub EXTRA_REQUIREMENT_IN_IMPL,
|
||||
Deny,
|
||||
"detects extra requirements in impls that were erroneously allowed"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub LEGACY_DIRECTORY_OWNERSHIP,
|
||||
Deny,
|
||||
|
|
@ -254,7 +248,6 @@ impl LintPass for HardwiredLints {
|
|||
RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
|
||||
SAFE_EXTERN_STATICS,
|
||||
PATTERNS_IN_FNS_WITHOUT_BODY,
|
||||
EXTRA_REQUIREMENT_IN_IMPL,
|
||||
LEGACY_DIRECTORY_OWNERSHIP,
|
||||
LEGACY_IMPORTS,
|
||||
LEGACY_CONSTRUCTOR_VISIBILITY,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ use hir::def_id::DefId;
|
|||
use infer::{self, InferCtxt};
|
||||
use infer::type_variable::TypeVariableOrigin;
|
||||
use middle::const_val;
|
||||
use rustc::lint::builtin::EXTRA_REQUIREMENT_IN_IMPL;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use session::DiagnosticMessageId;
|
||||
|
|
@ -481,30 +480,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
item_name: ast::Name,
|
||||
_impl_item_def_id: DefId,
|
||||
trait_item_def_id: DefId,
|
||||
requirement: &fmt::Display,
|
||||
lint_id: Option<ast::NodeId>) // (*)
|
||||
requirement: &fmt::Display)
|
||||
-> DiagnosticBuilder<'tcx>
|
||||
{
|
||||
// (*) This parameter is temporary and used only for phasing
|
||||
// in the bug fix to #18937. If it is `Some`, it has a kind of
|
||||
// weird effect -- the diagnostic is reported as a lint, and
|
||||
// the builder which is returned is marked as canceled.
|
||||
|
||||
let msg = "impl has stricter requirements than trait";
|
||||
let mut err = match lint_id {
|
||||
Some(node_id) => {
|
||||
self.tcx.struct_span_lint_node(EXTRA_REQUIREMENT_IN_IMPL,
|
||||
node_id,
|
||||
error_span,
|
||||
msg)
|
||||
}
|
||||
None => {
|
||||
struct_span_err!(self.tcx.sess,
|
||||
error_span,
|
||||
E0276,
|
||||
"{}", msg)
|
||||
}
|
||||
};
|
||||
let mut err = struct_span_err!(self.tcx.sess,
|
||||
error_span,
|
||||
E0276,
|
||||
"{}", msg);
|
||||
|
||||
if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) {
|
||||
let span = self.tcx.sess.codemap().def_span(trait_item_span);
|
||||
|
|
@ -543,15 +526,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let mut err = match *error {
|
||||
SelectionError::Unimplemented => {
|
||||
if let ObligationCauseCode::CompareImplMethodObligation {
|
||||
item_name, impl_item_def_id, trait_item_def_id, lint_id
|
||||
item_name, impl_item_def_id, trait_item_def_id,
|
||||
} = obligation.cause.code {
|
||||
self.report_extra_impl_obligation(
|
||||
span,
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
&format!("`{}`", obligation.predicate),
|
||||
lint_id)
|
||||
&format!("`{}`", obligation.predicate))
|
||||
.emit();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||
item_name: ast::Name,
|
||||
impl_item_def_id: DefId,
|
||||
trait_item_def_id: DefId,
|
||||
lint_id: Option<ast::NodeId>,
|
||||
},
|
||||
|
||||
/// Checking that this expression can be assigned where it needs to be
|
||||
|
|
|
|||
|
|
@ -214,13 +214,11 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
|
|||
}
|
||||
super::CompareImplMethodObligation { item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
lint_id } => {
|
||||
trait_item_def_id } => {
|
||||
Some(super::CompareImplMethodObligation {
|
||||
item_name,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
lint_id,
|
||||
})
|
||||
}
|
||||
super::ExprAssignable => Some(super::ExprAssignable),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue