1
Fork 0

Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis

fix for late-bound regions

Fix for https://github.com/rust-lang/rust/issues/53419

r? @nikomatsakis
This commit is contained in:
bors 2018-08-27 17:42:45 +00:00
commit 70a21e89f1
51 changed files with 94 additions and 23 deletions

View file

@ -77,6 +77,7 @@
#![cfg_attr(not(test), feature(fn_traits))]
#![cfg_attr(not(test), feature(generator_trait))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![cfg_attr(test, feature(test))]
#![feature(allocator_api)]

View file

@ -17,6 +17,7 @@
#![feature(libc)]
#![feature(linkage)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))]

View file

@ -18,6 +18,7 @@
#![feature(allocator_api)]
#![feature(core_intrinsics)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)]
#![feature(rustc_attrs)]
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]

View file

@ -27,6 +27,7 @@
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(raw_vec_internals)]
#![cfg_attr(test, feature(test))]

View file

@ -92,6 +92,7 @@
#![feature(link_llvm_intrinsics)]
#![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(exhaustive_patterns)]
#![feature(macro_at_most_once_rep)]
#![feature(no_core)]

View file

@ -21,6 +21,7 @@
test(attr(deny(warnings))))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
pub use self::Piece::*;
pub use self::Position::*;

View file

@ -289,6 +289,7 @@
test(attr(allow(unused_variables), deny(warnings))))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(str_escape)]
use self::LabelText::*;

View file

@ -25,6 +25,7 @@
#![feature(core_intrinsics)]
#![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(panic_runtime)]
#![feature(staged_api)]
#![feature(rustc_attrs)]

View file

@ -35,6 +35,7 @@
#![feature(lang_items)]
#![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(panic_unwind)]
#![feature(raw)]
#![feature(staged_api)]

View file

@ -32,6 +32,7 @@
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(lang_items)]

View file

@ -16,4 +16,5 @@
issue = "0")]
#![allow(unused_features)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)]

View file

@ -51,6 +51,7 @@
#![feature(exhaustive_patterns)]
#![feature(extern_types)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(non_exhaustive)]
#![feature(proc_macro_internals)]
#![feature(quote)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_private)]
#[macro_use] extern crate log;

View file

@ -46,6 +46,7 @@
#![forbid(unsafe_code)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(try_from)]
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#[allow(unused_extern_crates)]

View file

@ -11,6 +11,7 @@
#![sanitizer_runtime]
#![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]

View file

@ -15,6 +15,7 @@
#![allow(non_camel_case_types)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)]
#![recursion_limit="256"]

View file

@ -27,6 +27,7 @@
#![allow(unused_attributes)]
#![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]

View file

@ -20,6 +20,7 @@
#![feature(box_syntax)]
#![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]

View file

@ -12,6 +12,7 @@
#![allow(unused_extern_crates)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
extern crate bitflags;
extern crate log;

View file

@ -27,6 +27,7 @@
#![feature(optin_builtin_traits)]
#![cfg_attr(stage0, feature(macro_vis_matcher))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(allow_internal_unstable)]
#![feature(vec_resize_with)]

View file

@ -21,6 +21,7 @@
#![feature(box_syntax)]
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(option_replace)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]

View file

@ -17,6 +17,7 @@
#![feature(range_contains)]
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(optin_builtin_traits)]
extern crate atty;

View file

@ -15,6 +15,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(specialization)]
#![recursion_limit="256"]

View file

@ -28,6 +28,7 @@
#![feature(box_syntax)]
#![cfg_attr(stage0, feature(macro_vis_matcher))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(macro_at_most_once_rep)]

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(static_nobundle)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",

View file

@ -11,6 +11,7 @@
#![sanitizer_runtime]
#![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]

View file

@ -16,6 +16,7 @@
#![feature(libc)]
#![feature(macro_at_most_once_rep)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![feature(quote)]

View file

@ -15,7 +15,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
*/
#![cfg_attr(not(stage0), feature(nll))]
#![feature(infer_outlives_requirements)]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(in_band_lifetimes)]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]

View file

@ -11,6 +11,7 @@
#![sanitizer_runtime]
#![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]

View file

@ -19,6 +19,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)]
#[macro_use]

View file

@ -11,6 +11,7 @@
#![allow(bad_style)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
pub struct Intrinsic {
pub inputs: &'static [&'static Type],

View file

@ -65,6 +65,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)]
#[macro_use] extern crate syntax;

View file

@ -13,6 +13,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)]
#![recursion_limit="256"]

View file

@ -14,6 +14,7 @@
#![feature(crate_visibility_modifier)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]

View file

@ -13,6 +13,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)]
#![recursion_limit="256"]

View file

@ -24,6 +24,7 @@
#![feature(box_syntax)]
#![feature(const_fn)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(slice_patterns)]
#[macro_use]

View file

@ -16,6 +16,7 @@
#![feature(extern_prelude)]
#![feature(in_band_lifetimes)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![recursion_limit="256"]

View file

@ -11,6 +11,7 @@
#![sanitizer_runtime]
#![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]

View file

@ -76,6 +76,7 @@ This API is completely unstable and subject to change.
#![feature(crate_visibility_modifier)]
#![feature(exhaustive_patterns)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]

View file

@ -65,8 +65,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
debug!("InferVisitor::visit_item(item={:?})", item_did);
let node_id = self
.tcx
let node_id = self.tcx
.hir
.as_local_node_id(item_did)
.expect("expected local def-id");
@ -108,8 +107,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
// Therefore mark `predicates_added` as true and which will ensure
// we walk the crates again and re-calculate predicates for all
// items.
let item_predicates_len: usize = self
.global_inferred_outlives
let item_predicates_len: usize = self.global_inferred_outlives
.get(&item_did)
.map(|p| p.len())
.unwrap_or(0);
@ -191,7 +189,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
substs,
required_predicates,
explicit_map,
false,
IgnoreSelfTy(false),
);
}
@ -199,22 +197,29 @@ fn insert_required_predicates_to_be_wf<'tcx>(
// This corresponds to `dyn Trait<..>`. In this case, we should
// use the explicit predicates as well.
// We are passing type `ty` as a placeholder value with the function
// `with_self_ty`, since there is no concrete type `Self` for a
// `dyn Trait` at this stage. Therefore when checking explicit
// predicates in `check_explicit_predicates` we need to ignore
// checking the explicit_map for Self type.
debug!("Dynamic");
debug!("field_ty = {}", &field_ty);
debug!("ty in field = {}", &ty);
if let Some(ex_trait_ref) = obj.principal() {
// Here, we are passing the type `usize` as a
// placeholder value with the function
// `with_self_ty`, since there is no concrete type
// `Self` for a `dyn Trait` at this
// stage. Therefore when checking explicit
// predicates in `check_explicit_predicates` we
// need to ignore checking the explicit_map for
// Self type.
let substs = ex_trait_ref
.with_self_ty(tcx, tcx.types.usize)
.skip_binder()
.substs;
check_explicit_predicates(
tcx,
&ex_trait_ref.skip_binder().def_id,
ex_trait_ref.with_self_ty(tcx, ty).skip_binder().substs,
substs,
required_predicates,
explicit_map,
true,
IgnoreSelfTy(true),
);
}
}
@ -229,7 +234,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
obj.substs,
required_predicates,
explicit_map,
false,
IgnoreSelfTy(false),
);
}
@ -238,6 +243,8 @@ fn insert_required_predicates_to_be_wf<'tcx>(
}
}
pub struct IgnoreSelfTy(bool);
/// We also have to check the explicit predicates
/// declared on the type.
///
@ -259,7 +266,7 @@ pub fn check_explicit_predicates<'tcx>(
substs: &[Kind<'tcx>],
required_predicates: &mut RequiredPredicates<'tcx>,
explicit_map: &mut ExplicitPredicatesMap<'tcx>,
ignore_self_ty: bool,
ignore_self_ty: IgnoreSelfTy,
) {
debug!("def_id = {:?}", &def_id);
debug!("substs = {:?}", &substs);
@ -297,7 +304,7 @@ pub fn check_explicit_predicates<'tcx>(
// to apply the substs, and not filter this predicate, we might then falsely
// conclude that e.g. `X: 'x` was a reasonable inferred requirement.
if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() {
if ty.is_self() && ignore_self_ty {
if ty.is_self() && ignore_self_ty.0 {
debug!("skipping self ty = {:?}", &ty);
continue;
}
@ -307,5 +314,4 @@ pub fn check_explicit_predicates<'tcx>(
debug!("predicate = {:?}", &predicate);
insert_outlives_predicate(tcx, predicate.0.into(), predicate.1, required_predicates);
}
// }
}

View file

@ -59,8 +59,7 @@ fn inferred_outlives_of<'a, 'tcx>(
ty::Predicate::TypeOutlives(p) => p.to_string(),
err => bug!("unexpected predicate {:?}", err),
})
.collect();
}).collect();
pred.sort();
let span = tcx.def_span(item_def_id);
@ -117,11 +116,9 @@ fn inferred_outlives_crate<'tcx>(
ty::Binder::bind(ty::OutlivesPredicate(region1, region2)),
),
},
)
.collect();
).collect();
(def_id, Lrc::new(vec))
})
.collect();
}).collect();
let empty_predicate = Lrc::new(Vec::new());

View file

@ -17,6 +17,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(set_stdio)]
#![feature(slice_sort_by_cached_key)]
#![feature(test)]

View file

@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
#![feature(specialization)]
#![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![cfg_attr(test, feature(test))]
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};

View file

@ -273,6 +273,7 @@
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(exhaustive_patterns)]
#![feature(on_unimplemented)]
#![feature(optin_builtin_traits)]

View file

@ -22,6 +22,7 @@
#![feature(crate_visibility_modifier)]
#![feature(macro_at_most_once_rep)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]

View file

@ -17,6 +17,7 @@
#![feature(proc_macro_internals)]
#![feature(decl_macro)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(str_escape)]
#![feature(rustc_diagnostic_macros)]

View file

@ -22,6 +22,7 @@
#![feature(crate_visibility_modifier)]
#![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(non_exhaustive)]
#![feature(optin_builtin_traits)]
#![feature(specialization)]

View file

@ -51,6 +51,7 @@
// Handle rustfmt skips
#![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)]
use std::io::prelude::*;

View file

@ -36,6 +36,7 @@
#![feature(fnbox)]
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(set_stdio)]
#![feature(panic_unwind)]
#![feature(staged_api)]

View file

@ -14,6 +14,7 @@
#![feature(cfg_target_vendor)]
#![feature(link_cfg)]
#![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)]
#![feature(unwind_attributes)]
#![feature(static_nobundle)]

View file

@ -0,0 +1,21 @@
// Copyright 2012 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.
//compile-pass
#![feature(infer_outlives_requirements)]
struct Foo {
bar: for<'r> Fn(usize, &'r FnMut())
}
fn main() {
}