Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4afe423
fulfill: remove dead code
nikomatsakis Nov 1, 2017
64206b4
move region constraints into inference context
nikomatsakis Nov 1, 2017
0d78e40
convert EXTRA_REQUIREMENT_IN_IMPL into a hard error
nikomatsakis Nov 1, 2017
c925008
assert that we are consuming all of the region obligations
nikomatsakis Nov 1, 2017
d73be85
extract `regionck_outlives` into a separate helper function
nikomatsakis Nov 2, 2017
22cd041
move the `region_obligations` processing code into `InferCtxt`
nikomatsakis Nov 3, 2017
e0630e8
refactor how we extract outlives bounds from trait definitions
nikomatsakis Nov 3, 2017
3cc44a5
do not invoke `required_region_bounds` in `region_obligations`
nikomatsakis Nov 4, 2017
b587c1a
regionck: only add implied bounds from root fn to `free_region_map`
nikomatsakis Nov 4, 2017
0c81d01
extract out the implied bounds code from `regionck`
nikomatsakis Nov 4, 2017
56e5eb5
rename mod `region_obligations` to `outlives::obligations`
nikomatsakis Nov 4, 2017
15a2dfa
move the `OutlivesEnvironment` into `infer` so that `nll` can use it
nikomatsakis Nov 4, 2017
6d67296
thread location info through mir typeck (but do not use)
nikomatsakis Nov 4, 2017
9e8abd7
apply rustfmt to `type_check`
nikomatsakis Nov 4, 2017
efa09db
modify MIR type-checker to process obligations as they are incurred
nikomatsakis Nov 5, 2017
467f2ea
extract lexical region resolution into its own sub-module
nikomatsakis Nov 5, 2017
58c7760
move region resolution to be a sibling of `region_inference`
nikomatsakis Nov 15, 2017
ef5de07
fix rename to block_data in type_check.rs
nikomatsakis Nov 15, 2017
9d63330
region_inference: tighten up `pub`, stop re-exporting enum variants
nikomatsakis Nov 5, 2017
8e9e154
region_inference: extract taint into a sub-module
nikomatsakis Nov 5, 2017
b769785
move `RegionResolutionError` into `lexical_region_resolve`
nikomatsakis Nov 5, 2017
ec48b01
extract storage of region values from `RegionVarBindings`
nikomatsakis Nov 5, 2017
daceedf
region_inference: rustfmt
nikomatsakis Nov 5, 2017
63d658d
extract the `tcx` out from `RegionVarBindings`
nikomatsakis Nov 5, 2017
cff191d
move refcells out from `RegionVarBindings` and up into `InferCtxt`
nikomatsakis Nov 5, 2017
23abd85
rename `region_inference` module to `region_constraints`
nikomatsakis Nov 5, 2017
48d8f72
infer: rename `region_vars` field to `region_constraints`
nikomatsakis Nov 5, 2017
326ec52
rename RegionVarBindings to RegionConstraintCollector
nikomatsakis Nov 5, 2017
adf1519
make the `region_constraints` field an `Option`
nikomatsakis Nov 5, 2017
f6037f2
separate the `Collector` from the `Data` it is collecting
nikomatsakis Nov 5, 2017
bea6b94
fix error messages relating to removing lint for E0276
nikomatsakis Nov 5, 2017
524e23a
make `RegionVid` implement `Idx` and use `IndexVec`
nikomatsakis Nov 5, 2017
a8daa37
region_constraints: only push givens into undo-log if in a snapshot
nikomatsakis Nov 5, 2017
1efcf1a
split the `var_origins` from the `RegionConstraintData`
nikomatsakis Nov 5, 2017
1430a60
add method `take_and_reset_region_constraints` to `InferCtxt`
nikomatsakis Nov 5, 2017
034018c
rustfmt `lexical_region_resolve`
nikomatsakis Nov 5, 2017
37945fe
MIR typeck: rustfmt
nikomatsakis Nov 7, 2017
ad93b69
MIR typeck: refactor to track region constraints
nikomatsakis Nov 5, 2017
89c1b60
replace `usize` with `RegionIndex` in indices map
nikomatsakis Nov 6, 2017
72675d8
replace `RegionIndex` with `RegionVid` (which now impls Idx)
nikomatsakis Nov 6, 2017
09b44bb
IndexVec: add `'_` to make clear where borrowing is happening
nikomatsakis Nov 6, 2017
a87d1bb
infer: give access to region variable origins
nikomatsakis Nov 6, 2017
109c9a7
infer: extract total number of region variables from infcx
nikomatsakis Nov 6, 2017
51ce1f9
formalize giving ownership of region vars to region inf. context
nikomatsakis Nov 6, 2017
ef392bc
simplify lifetime annotations for `MirBorrowckCtxt`
nikomatsakis Nov 7, 2017
8d3219e
erase regions in MIR borrowck when checking if type moves by default
nikomatsakis Nov 6, 2017
5592bb7
MIR-dump: print return type from local_decls for `_0`
nikomatsakis Nov 7, 2017
12534e9
renumber: handle ReturnTy better
nikomatsakis Nov 7, 2017
32f964c
renumber: debug logs, use `visit_region` rather than `visit_rvalue`
nikomatsakis Nov 7, 2017
d9e841e
region_infer: improved debug logging
nikomatsakis Nov 7, 2017
4b743da
integrate NLL with MIR type-checker
nikomatsakis Nov 6, 2017
b383ab7
update READMEs to describe the new situation
nikomatsakis Nov 7, 2017
013f88b
infer/outlives: add license
nikomatsakis Nov 7, 2017
267574c
convert TODO in traits into a FIXME
nikomatsakis Nov 7, 2017
9da54c1
add FIXME for converting RegionVid to use `newtype_index!`
nikomatsakis Nov 7, 2017
8cea053
fix mir-opt NLL tests -- variable `'_#0r` is now `'static`
nikomatsakis Nov 7, 2017
c7c2603
factor out `free_region_binding_scope` helper
nikomatsakis Nov 7, 2017
5a8c1eb
leak the affects of closures on the free-region-map, like we used to
nikomatsakis Nov 7, 2017
f722591
Nit: fix wording in README
nikomatsakis Nov 14, 2017
15739b8
Nit: rework region obligations to a snapshotted vector
nikomatsakis Nov 14, 2017
11c84c6
Nit: improve comment to explain why we wait until regionck
nikomatsakis Nov 14, 2017
a73d620
Nit: reset more state after `take_and_reset_data`
nikomatsakis Nov 14, 2017
a94d2a6
Nit: fix typo
nikomatsakis Nov 15, 2017
9e29662
obligations.rs: rustfmt
nikomatsakis Nov 16, 2017
8c109f5
infer/outlives/obligations.rs: wrap some long lines
nikomatsakis Nov 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
convert EXTRA_REQUIREMENT_IN_IMPL into a hard error
  • Loading branch information
nikomatsakis committed Nov 15, 2017
commit 0d78e40e88dbd53619cd5ec04b0f53cea871c07d
5 changes: 2 additions & 3 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions src/librustc/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
},
}

Expand Down Expand Up @@ -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(),
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 7 additions & 25 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
id: LintId::of(INVALID_TYPE_PARAM_DEFAULT),
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
},
FutureIncompatibleInfo {
id: LintId::of(EXTRA_REQUIREMENT_IN_IMPL),
reference: "issue #37166 <https://github.com/rust-lang/rust/issues/37166>",
},
FutureIncompatibleInfo {
id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP),
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
Expand Down Expand Up @@ -276,4 +272,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
"converted into hard error, see https://github.com/rust-lang/rust/issues/36891");
store.register_removed("lifetime_underscore",
"converted into hard error, see https://github.com/rust-lang/rust/issues/36892");
store.register_removed("extra_requirement_in_impl",
"converted into hard error, see https://github.com/rust-lang/rust/issues/37166");
}
30 changes: 5 additions & 25 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

use rustc::hir::{self, ImplItemKind, TraitItemKind};
use rustc::infer::{self, InferOk};
use rustc::middle::free_region::FreeRegionMap;
use rustc::middle::region;
use rustc::ty::{self, TyCtxt};
use rustc::ty::util::ExplicitSelf;
use rustc::traits::{self, ObligationCause, ObligationCauseCode, Reveal};
Expand All @@ -38,8 +36,7 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
impl_trait_ref: ty::TraitRef<'tcx>,
trait_item_span: Option<Span>,
old_broken_mode: bool) {
trait_item_span: Option<Span>) {
debug!("compare_impl_method(impl_trait_ref={:?})",
impl_trait_ref);

Expand Down Expand Up @@ -71,8 +68,7 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m,
impl_m_span,
trait_m,
impl_trait_ref,
old_broken_mode) {
impl_trait_ref) {
return;
}
}
Expand All @@ -81,8 +77,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
impl_trait_ref: ty::TraitRef<'tcx>,
old_broken_mode: bool)
impl_trait_ref: ty::TraitRef<'tcx>)
-> Result<(), ErrorReported> {
let trait_to_impl_substs = impl_trait_ref.substs;

Expand All @@ -98,7 +93,6 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
item_name: impl_m.name,
impl_item_def_id: impl_m.def_id,
trait_item_def_id: trait_m.def_id,
lint_id: if !old_broken_mode { Some(impl_m_node_id) } else { None },
},
};

Expand Down Expand Up @@ -334,22 +328,8 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

// Finally, resolve all regions. This catches wily misuses of
// lifetime parameters.
if old_broken_mode {
// FIXME(#18937) -- this is how the code used to
// work. This is buggy because the fulfillment cx creates
// region obligations that get overlooked. The right
// thing to do is the code below. But we keep this old
// pass around temporarily.
let region_scope_tree = region::ScopeTree::default();
let mut free_regions = FreeRegionMap::new();
free_regions.relate_free_regions_from_predicates(&param_env.caller_bounds);
infcx.resolve_regions_and_report_errors(impl_m.def_id,
&region_scope_tree,
&free_regions);
} else {
let fcx = FnCtxt::new(&inh, param_env, impl_m_node_id);
fcx.regionck_item(impl_m_node_id, impl_m_span, &[]);
}
let fcx = FnCtxt::new(&inh, param_env, impl_m_node_id);
fcx.regionck_item(impl_m_node_id, impl_m_span, &[]);

Ok(())
})
Expand Down
14 changes: 1 addition & 13 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,24 +1339,12 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
hir::ImplItemKind::Method(..) => {
let trait_span = tcx.hir.span_if_local(ty_trait_item.def_id);
if ty_trait_item.kind == ty::AssociatedKind::Method {
let err_count = tcx.sess.err_count();
compare_impl_method(tcx,
&ty_impl_item,
impl_item.span,
&ty_trait_item,
impl_trait_ref,
trait_span,
true); // start with old-broken-mode
if err_count == tcx.sess.err_count() {
// old broken mode did not report an error. Try with the new mode.
compare_impl_method(tcx,
&ty_impl_item,
impl_item.span,
&ty_trait_item,
impl_trait_ref,
trait_span,
false); // use the new mode
}
trait_span);
} else {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
"item `{}` is an associated method, \
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-18937.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ trait A<'a> {

impl<'a> A<'a> for B {
fn foo<F>(&mut self, f: F) //~ ERROR impl has stricter
//~^ WARNING future release
where F: fmt::Debug + 'static,
{
self.list.push(Box::new(f));
Expand Down