mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 03:27:44 +00:00
addressed comments
This commit is contained in:
parent
038aa0e8e9
commit
aa642b3486
@ -2231,17 +2231,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
fn all_impls(&self, trait_def_id: ast::DefId) -> Vec<ast::DefId> {
|
fn all_impls(&self, trait_def_id: ast::DefId) -> Vec<ast::DefId> {
|
||||||
ty::populate_implementations_for_trait_if_necessary(self.tcx(), trait_def_id);
|
ty::populate_implementations_for_trait_if_necessary(self.tcx(), trait_def_id);
|
||||||
|
|
||||||
let mut trait_impls = match self.tcx().trait_impls.borrow().get(&trait_def_id) {
|
match self.tcx().trait_impls.borrow().get(&trait_def_id) {
|
||||||
None => Vec::new(),
|
None => Vec::new(),
|
||||||
Some(impls) => impls.borrow().clone()
|
Some(impls) => impls.borrow().clone()
|
||||||
};
|
}
|
||||||
|
|
||||||
match self.tcx().trait_negative_impls.borrow().get(&trait_def_id) {
|
|
||||||
None => {},
|
|
||||||
Some(impls) => trait_impls.push_all(impls.borrow().as_slice()),
|
|
||||||
};
|
|
||||||
|
|
||||||
trait_impls
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn impl_obligations(&mut self,
|
fn impl_obligations(&mut self,
|
||||||
|
@ -750,9 +750,6 @@ pub struct ctxt<'tcx> {
|
|||||||
/// Maps a trait onto a list of impls of that trait.
|
/// Maps a trait onto a list of impls of that trait.
|
||||||
pub trait_impls: RefCell<DefIdMap<Rc<RefCell<Vec<ast::DefId>>>>>,
|
pub trait_impls: RefCell<DefIdMap<Rc<RefCell<Vec<ast::DefId>>>>>,
|
||||||
|
|
||||||
/// Maps a trait onto a list of negative impls of that trait.
|
|
||||||
pub trait_negative_impls: RefCell<DefIdMap<Rc<RefCell<Vec<ast::DefId>>>>>,
|
|
||||||
|
|
||||||
/// Maps a DefId of a type to a list of its inherent impls.
|
/// Maps a DefId of a type to a list of its inherent impls.
|
||||||
/// Contains implementations of methods that are inherent to a type.
|
/// Contains implementations of methods that are inherent to a type.
|
||||||
/// Methods in these implementations don't need to be exported.
|
/// Methods in these implementations don't need to be exported.
|
||||||
@ -1894,7 +1891,7 @@ pub type PolyTypeOutlivesPredicate<'tcx> = PolyOutlivesPredicate<Ty<'tcx>, ty::R
|
|||||||
/// normal trait predicate (`T : TraitRef<...>`) and one of these
|
/// normal trait predicate (`T : TraitRef<...>`) and one of these
|
||||||
/// predicates. Form #2 is a broader form in that it also permits
|
/// predicates. Form #2 is a broader form in that it also permits
|
||||||
/// equality between arbitrary types. Processing an instance of Form
|
/// equality between arbitrary types. Processing an instance of Form
|
||||||
/// \#2 eventually yields one of these `ProjectionPredicate`
|
/// #2 eventually yields one of these `ProjectionPredicate`
|
||||||
/// instances to normalize the LHS.
|
/// instances to normalize the LHS.
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, Show)]
|
#[derive(Clone, PartialEq, Eq, Hash, Show)]
|
||||||
pub struct ProjectionPredicate<'tcx> {
|
pub struct ProjectionPredicate<'tcx> {
|
||||||
@ -2415,7 +2412,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||||||
destructor_for_type: RefCell::new(DefIdMap::new()),
|
destructor_for_type: RefCell::new(DefIdMap::new()),
|
||||||
destructors: RefCell::new(DefIdSet::new()),
|
destructors: RefCell::new(DefIdSet::new()),
|
||||||
trait_impls: RefCell::new(DefIdMap::new()),
|
trait_impls: RefCell::new(DefIdMap::new()),
|
||||||
trait_negative_impls: RefCell::new(DefIdMap::new()),
|
|
||||||
inherent_impls: RefCell::new(DefIdMap::new()),
|
inherent_impls: RefCell::new(DefIdMap::new()),
|
||||||
impl_items: RefCell::new(DefIdMap::new()),
|
impl_items: RefCell::new(DefIdMap::new()),
|
||||||
used_unsafe: RefCell::new(NodeSet::new()),
|
used_unsafe: RefCell::new(NodeSet::new()),
|
||||||
@ -6006,14 +6002,7 @@ pub fn record_trait_implementation(tcx: &ctxt,
|
|||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
impl_def_id: DefId) {
|
impl_def_id: DefId) {
|
||||||
|
|
||||||
let trait_impls = match trait_impl_polarity(tcx, impl_def_id) {
|
match tcx.trait_impls.borrow().get(&trait_def_id) {
|
||||||
Some(ast::ImplPolarity::Positive) => &tcx.trait_impls,
|
|
||||||
Some(ast::ImplPolarity::Negative) => &tcx.trait_negative_impls,
|
|
||||||
_ => tcx.sess.bug(&format!("tried to record a non-impl item with id {:?}",
|
|
||||||
impl_def_id)[])
|
|
||||||
};
|
|
||||||
|
|
||||||
match trait_impls.borrow().get(&trait_def_id) {
|
|
||||||
Some(impls_for_trait) => {
|
Some(impls_for_trait) => {
|
||||||
impls_for_trait.borrow_mut().push(impl_def_id);
|
impls_for_trait.borrow_mut().push(impl_def_id);
|
||||||
return;
|
return;
|
||||||
@ -6021,7 +6010,7 @@ pub fn record_trait_implementation(tcx: &ctxt,
|
|||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait_impls.borrow_mut().insert(trait_def_id, Rc::new(RefCell::new(vec!(impl_def_id))));
|
tcx.trait_impls.borrow_mut().insert(trait_def_id, Rc::new(RefCell::new(vec!(impl_def_id))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Populates the type context with all the implementations for the given type
|
/// Populates the type context with all the implementations for the given type
|
||||||
|
@ -39,13 +39,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
|||||||
// check can populate this table further with impls from other
|
// check can populate this table further with impls from other
|
||||||
// crates.
|
// crates.
|
||||||
let trait_def_ids: Vec<(ast::DefId, Vec<ast::DefId>)> =
|
let trait_def_ids: Vec<(ast::DefId, Vec<ast::DefId>)> =
|
||||||
self.tcx.trait_impls.borrow().iter().map(|(&k, v)| {
|
self.tcx.trait_impls.borrow().iter().map(|(&k, v)| (k, v.borrow().clone())).collect();
|
||||||
let mut impls = v.borrow().clone();
|
|
||||||
if let Some(neg_impls) = self.tcx.trait_negative_impls.borrow().get(&k) {
|
|
||||||
impls.push_all(neg_impls.borrow().as_slice());
|
|
||||||
}
|
|
||||||
(k, impls)
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
for &(trait_def_id, ref impls) in trait_def_ids.iter() {
|
for &(trait_def_id, ref impls) in trait_def_ids.iter() {
|
||||||
self.check_for_overlapping_impls_of_trait(trait_def_id, impls);
|
self.check_for_overlapping_impls_of_trait(trait_def_id, impls);
|
||||||
|
@ -10,11 +10,20 @@
|
|||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
struct TestType;
|
trait MyTrait {}
|
||||||
|
|
||||||
unsafe impl Send for TestType {}
|
struct TestType<T>;
|
||||||
|
|
||||||
|
unsafe impl<T: MyTrait> Send for TestType<T> {}
|
||||||
|
//~^ ERROR conflicting implementations for trait `core::marker::Send`
|
||||||
|
//~^^ ERROR conflicting implementations for trait `core::marker::Send`
|
||||||
|
|
||||||
|
impl<T: MyTrait> !Send for TestType<T> {}
|
||||||
//~^ ERROR conflicting implementations for trait `core::marker::Send`
|
//~^ ERROR conflicting implementations for trait `core::marker::Send`
|
||||||
|
|
||||||
impl !Send for TestType {}
|
unsafe impl<T> Send for TestType<T> {}
|
||||||
|
//~^ ERROR error: conflicting implementations for trait `core::marker::Send`
|
||||||
|
|
||||||
|
impl !Send for TestType<i32> {}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -8,8 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// ignore-tidy-linelength
|
||||||
// aux-build:coherence-orphan-lib.rs
|
// aux-build:coherence-orphan-lib.rs
|
||||||
|
|
||||||
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
extern crate "coherence-orphan-lib" as lib;
|
extern crate "coherence-orphan-lib" as lib;
|
||||||
|
|
||||||
use lib::TheTrait;
|
use lib::TheTrait;
|
||||||
@ -22,4 +25,7 @@ impl TheTrait<TheType> for isize { } //~ ERROR E0117
|
|||||||
|
|
||||||
impl TheTrait<isize> for TheType { }
|
impl TheTrait<isize> for TheType { }
|
||||||
|
|
||||||
|
impl !Send for Vec<isize> { } //~ ERROR E0117
|
||||||
|
//~^ ERROR conflicting
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright 2013 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.
|
|
||||||
|
|
||||||
// ignore-stage1
|
|
||||||
// ignore-stage2
|
|
||||||
// ignore-stage3
|
|
||||||
|
|
||||||
use std::marker;
|
|
||||||
|
|
||||||
fn foo<P:Send>(p: P) { }
|
|
||||||
|
|
||||||
fn main()
|
|
||||||
{
|
|
||||||
foo(marker::NoSend); //~ ERROR the trait `core::marker::Send` is not implemented
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright 2013 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.
|
|
||||||
|
|
||||||
// ignore-stage1
|
|
||||||
// ignore-stage2
|
|
||||||
// ignore-stage3
|
|
||||||
|
|
||||||
use std::marker;
|
|
||||||
|
|
||||||
fn foo<P: Sync>(p: P) { }
|
|
||||||
|
|
||||||
fn main()
|
|
||||||
{
|
|
||||||
foo(marker::NoSync); //~ ERROR the trait `core::marker::Sync` is not implemented
|
|
||||||
}
|
|
@ -8,6 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// The dummy functions are used to avoid adding new cfail files.
|
||||||
|
// What happens is that the compiler attempts to squash duplicates and some
|
||||||
|
// errors are not reported. This way, we make sure that, for each function, different
|
||||||
|
// typeck phases are involved and all errors are reported.
|
||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
use std::marker::Send;
|
use std::marker::Send;
|
||||||
@ -24,13 +29,28 @@ unsafe impl<T: Send> Sync for Outer2<T> {}
|
|||||||
fn is_send<T: Send>(_: T) {}
|
fn is_send<T: Send>(_: T) {}
|
||||||
fn is_sync<T: Sync>(_: T) {}
|
fn is_sync<T: Sync>(_: T) {}
|
||||||
|
|
||||||
fn main() {
|
fn dummy() {
|
||||||
Outer(TestType);
|
Outer(TestType);
|
||||||
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
||||||
|
|
||||||
is_send(TestType);
|
is_send(TestType);
|
||||||
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
||||||
|
|
||||||
|
is_send((8, TestType));
|
||||||
|
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dummy2() {
|
||||||
|
is_send(Box::new(TestType));
|
||||||
|
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dummy3() {
|
||||||
|
is_send(Box::new(Outer2(TestType)));
|
||||||
|
//~^ ERROR the trait `core::marker::Send` is not implemented for the type `TestType`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
// This will complain about a missing Send impl because `Sync` is implement *just*
|
// This will complain about a missing Send impl because `Sync` is implement *just*
|
||||||
// for T that are `Send`. Look at #20366 and #19950
|
// for T that are `Send`. Look at #20366 and #19950
|
||||||
is_sync(Outer2(TestType));
|
is_sync(Outer2(TestType));
|
||||||
|
Loading…
Reference in New Issue
Block a user