"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! {
pub LIFETIME_UNDERSCORE,
Warn,
OVERLAPPING_INHERENT_IMPLS,
RENAMED_AND_REMOVED_LINTS,
SUPER_OR_SELF_IN_GLOBAL_PATH,
- UNSIZED_IN_TUPLE,
- OBJECT_UNSAFE_FRAGMENT,
HR_LIFETIME_IN_ASSOC_TYPE,
LIFETIME_UNDERSCORE
)
match *predicate {
ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) |
ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) |
use std::cmp;
use std::fmt;
-use syntax::ast;
use syntax_pos::Span;
use errors::DiagnosticBuilder;
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct TraitErrorKey<'tcx> {
span: Span,
- warning_node_id: Option<ast::NodeId>,
predicate: ty::Predicate<'tcx>
}
impl<'a, 'gcx, 'tcx> TraitErrorKey<'tcx> {
fn from_error(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
- e: &FulfillmentError<'tcx>,
- warning_node_id: Option<ast::NodeId>) -> Self {
+ e: &FulfillmentError<'tcx>) -> Self {
let predicate =
infcx.resolve_type_vars_if_possible(&e.obligation.predicate);
TraitErrorKey {
span: e.obligation.cause.span,
- predicate: infcx.tcx.erase_regions(&predicate),
- warning_node_id: warning_node_id
+ predicate: infcx.tcx.erase_regions(&predicate)
}
}
}
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn report_fulfillment_errors(&self, errors: &Vec<FulfillmentError<'tcx>>) {
for error in errors {
- self.report_fulfillment_error(error, None);
- }
- }
-
- 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));
+ self.report_fulfillment_error(error);
}
}
fn report_fulfillment_error(&self,
- error: &FulfillmentError<'tcx>,
- warning_node_id: Option<ast::NodeId>) {
- let error_key = TraitErrorKey::from_error(self, error, warning_node_id);
+ error: &FulfillmentError<'tcx>) {
+ let error_key = TraitErrorKey::from_error(self, error);
debug!("report_fulfillment_errors({:?}) - key={:?}",
error, error_key);
if !self.reported_trait_errors.borrow_mut().insert(error_key) {
}
match error.code {
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) => {
- self.report_projection_error(&error.obligation, e, warning_node_id);
+ self.report_projection_error(&error.obligation, e);
}
FulfillmentErrorCode::CodeAmbiguity => {
self.maybe_report_ambiguity(&error.obligation);
fn report_projection_error(&self,
obligation: &PredicateObligation<'tcx>,
- error: &MismatchedProjectionTypes<'tcx>,
- warning_node_id: Option<ast::NodeId>)
+ error: &MismatchedProjectionTypes<'tcx>)
{
let predicate =
self.resolve_type_vars_if_possible(&obligation.predicate);
if predicate.references_error() {
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(|_| {
let origin = TypeOrigin::Misc(obligation.cause.span);
let err_buf;
pub fn report_selection_error(&self,
obligation: &PredicateObligation<'tcx>,
- error: &SelectionError<'tcx>,
- warning_node_id: Option<ast::NodeId>)
+ error: &SelectionError<'tcx>)
{
let span = obligation.cause.span;
let mut err = match *error {
} else {
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,
"the trait bound `{}` is not satisfied",
trait_ref.to_predicate());
ty::Predicate::ObjectSafe(trait_def_id) => {
let violations = self.tcx.object_safety_violations(trait_def_id);
- let err = self.tcx.report_object_safety_error(span,
- trait_def_id,
- warning_node_id,
- violations);
- if let Some(err) = err {
- err
- } else {
- return;
- }
+ self.tcx.report_object_safety_error(span,
+ trait_def_id,
+ violations)
}
ty::Predicate::ClosureKind(closure_def_id, kind) => {
// (which may fail).
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);
- }
}
}
}
TraitNotObjectSafe(did) => {
let violations = self.tcx.object_safety_violations(did);
- let err = self.tcx.report_object_safety_error(span, did,
- warning_node_id,
- violations);
- if let Some(err) = err {
- err
- } else {
- return;
- }
+ self.tcx.report_object_safety_error(span, did,
+ violations)
}
};
self.note_obligation_cause(&mut err, obligation);
pub fn report_object_safety_error(self,
span: Span,
trait_def_id: DefId,
- warning_node_id: Option<ast::NodeId>,
violations: Vec<ObjectSafetyViolation>)
- -> Option<DiagnosticBuilder<'tcx>>
+ -> DiagnosticBuilder<'tcx>
{
- let mut err = match warning_node_id {
- Some(_) => None,
- None => {
- let trait_str = self.item_path_str(trait_def_id);
- let mut db = struct_span_err!(
- self.sess, span, E0038,
- "the trait `{}` cannot be made into an object",
- trait_str);
- db.span_label(span,
- &format!("the trait `{}` cannot be made \
- into an object", trait_str));
- Some(db)
- }
- };
+ let trait_str = self.item_path_str(trait_def_id);
+ let mut err = struct_span_err!(
+ self.sess, span, E0038,
+ "the trait `{}` cannot be made into an object",
+ trait_str);
+ err.span_label(span, &format!(
+ "the trait `{}` cannot be made into an object", trait_str
+ ));
let mut reported_violations = FnvHashSet();
for violation in violations {
&buf
}
};
- match (warning_node_id, &mut err) {
- (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.note(note);
}
err
}
// fulfillment context.
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
// constraint has the form `T:'a`, meaning "some type `T` must
// outlive the lifetime 'a". These constraints derive from
pub fn new() -> FulfillmentContext<'tcx> {
FulfillmentContext {
predicates: ObligationForest::new(),
- rfc1592_obligations: Vec::new(),
region_obligations: NodeMap(),
deferred_obligations: vec![],
}
});
}
- 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,
body_id: ast::NodeId)
-> &[RegionObligation<'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,
infcx: &InferCtxt<'a, 'gcx, 'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>>
let outcome = self.predicates.process_obligations(&mut FulfillProcessor {
selcx: selcx,
region_obligations: &mut self.region_obligations,
- rfc1592_obligations: &mut self.rfc1592_obligations,
deferred_obligations: &mut self.deferred_obligations
});
debug!("select: outcome={:?}", outcome);
struct FulfillProcessor<'a, 'b: 'a, 'gcx: 'tcx, 'tcx: 'b> {
selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>,
region_obligations: &'a mut NodeMap<Vec<RegionObligation<'tcx>>>,
- rfc1592_obligations: &'a mut Vec<PredicateObligation<'tcx>>,
deferred_obligations: &'a mut Vec<DeferredObligation<'tcx>>
}
process_predicate(self.selcx,
obligation,
self.region_obligations,
- self.rfc1592_obligations,
self.deferred_obligations)
.map(|os| os.map(|os| os.into_iter().map(|o| PendingPredicateObligation {
obligation: o,
selcx: &mut SelectionContext<'a, 'gcx, 'tcx>,
pending_obligation: &mut PendingPredicateObligation<'tcx>,
region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>,
- rfc1592_obligations: &mut Vec<PredicateObligation<'tcx>>,
deferred_obligations: &mut Vec<DeferredObligation<'tcx>>)
-> Result<Option<Vec<PredicateObligation<'tcx>>>,
FulfillmentErrorCode<'tcx>>
s => Ok(s)
}
}
-
- ty::Predicate::Rfc1592(ref inner) => {
- rfc1592_obligations.push(PredicateObligation {
- predicate: ty::Predicate::clone(inner),
- ..obligation.clone()
- });
- Ok(Some(vec![]))
- }
}
}
ty::Predicate::TypeOutlives(..) |
ty::Predicate::RegionOutlives(..) |
ty::Predicate::ClosureKind(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) => {
false
}
}
ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) |
ty::Predicate::WellFormed(..) |
}
match obligation.predicate {
- ty::Predicate::Rfc1592(..) => EvaluatedToOk,
-
ty::Predicate::Trait(ref t) => {
assert!(!t.has_escaping_regions());
let obligation = obligation.with(t.clone());
ty::TyStr | ty::TySlice(_) | ty::TyTrait(..) => Never,
ty::TyTuple(tys) => {
- // FIXME(#33242) we only need to constrain the last field
- Where(ty::Binder(tys.to_vec()))
+ Where(ty::Binder(tys.last().into_iter().cloned().collect()))
}
ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => {
// T -> Trait.
(_, &ty::TyTrait(ref data)) => {
- let mut object_dids = Some(data.principal.def_id()).into_iter();
- // FIXME(#33243)
-// data.builtin_bounds.iter().flat_map(|bound| {
-// tcx.lang_items.from_builtin_kind(bound).ok()
-// })
-// .chain(Some(data.principal.def_id()));
+ let mut object_dids =
+ data.builtin_bounds.iter().flat_map(|bound| {
+ tcx.lang_items.from_builtin_kind(bound).ok()
+ })
+ .chain(Some(data.principal.def_id()));
if let Some(did) = object_dids.find(|did| {
!tcx.is_object_safe(*did)
}) {
ty::Predicate::Trait(ref 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(tcx.anonymize_late_bound_regions(data)),
self.stack.extend(predicates);
}
- ty::Predicate::Rfc1592(..) => {
- // Nothing to elaborate.
- }
ty::Predicate::WellFormed(..) => {
// Currently, we do not elaborate WF predicates,
// although we easily could.
/// would be the type parameters.
Trait(PolyTraitPredicate<'tcx>),
- /// A predicate created by RFC1592
- Rfc1592(Box<Predicate<'tcx>>),
-
/// where `T1 == T2`.
Equate(PolyEquatePredicate<'tcx>),
match *self {
Predicate::Trait(ty::Binder(ref data)) =>
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(data.subst(tcx, substs))),
Predicate::RegionOutlives(ty::Binder(ref data)) =>
ty::Predicate::Trait(ref data) => {
data.skip_binder().input_types().collect()
}
- ty::Predicate::Rfc1592(ref data) => {
- return data.walk_tys()
- }
ty::Predicate::Equate(ty::Binder(ref data)) => {
vec![data.0, data.1]
}
Predicate::Trait(ref t) => {
Some(t.to_poly_trait_ref())
}
- Predicate::Rfc1592(..) |
Predicate::Projection(..) |
Predicate::Equate(..) |
Predicate::RegionOutlives(..) |
}
TyTuple(ref tys) => {
- // FIXME(#33242) we only need to constrain the last field
- tys.iter().flat_map(|ty| {
- self.sized_constraint_for_ty(tcx, stack, ty)
- }).collect()
+ match tys.last() {
+ None => vec![],
+ Some(ty) => self.sized_constraint_for_ty(tcx, stack, ty)
+ }
}
TyEnum(adt, substs) | TyStruct(adt, substs) => {
ty::Predicate::WellFormed(ty) => {
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) => {
Some(ty::Predicate::ClosureKind(closure_def_id, kind))
}
match *self {
ty::Predicate::Trait(ref a) =>
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(binder.fold_with(folder)),
ty::Predicate::RegionOutlives(ref binder) =>
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match *self {
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::RegionOutlives(ref binder) => binder.visit_with(visitor),
ty::Predicate::TypeOutlives(ref binder) => binder.visit_with(visitor),
match predicate {
ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) |
ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) |
}
ty::Predicate::ClosureKind(..) => {
}
- ty::Predicate::Rfc1592(ref data) => {
- bug!("RFC1592 predicate `{:?}` in predicate_obligations", data);
- }
}
wf.normalize()
assert!(!obligation.has_escaping_regions());
match obligation.predicate {
ty::Predicate::Trait(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) |
ty::Predicate::Projection(..) |
ty::Predicate::ClosureKind(..) |
}
}
- fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>,
- rfc1592: bool) {
+ fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) {
if !subty.has_escaping_regions() {
let cause = self.cause(cause);
match self.infcx.tcx.trait_ref_for_builtin_bound(ty::BoundSized, subty) {
Ok(trait_ref) => {
- let predicate = trait_ref.to_predicate();
- let predicate = if rfc1592 {
- ty::Predicate::Rfc1592(box predicate)
- } else {
- predicate
- };
self.out.push(
traits::Obligation::new(cause,
- predicate));
+ trait_ref.to_predicate()));
}
Err(ErrorReported) => { }
}
ty::TySlice(subty) |
ty::TyArray(subty, _) => {
- self.require_sized(subty, traits::SliceOrArrayElem, false);
+ self.require_sized(subty, traits::SliceOrArrayElem);
}
ty::TyTuple(ref tys) => {
if let Some((_last, rest)) = tys.split_last() {
for elem in rest {
- self.require_sized(elem, traits::TupleElem, true);
+ self.require_sized(elem, traits::TupleElem);
}
}
}
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 =
data.builtin_bounds.iter().flat_map(|bound| {
tcx.lang_items.from_builtin_kind(bound).ok()
- });
-// .chain(Some(data.principal.def_id()));
+ })
+ .chain(Some(data.principal.def_id()));
self.out.extend(
component_traits.map(|did| { traits::Obligation::new(
cause.clone(),
- ty::Predicate::Rfc1592(
- box ty::Predicate::ObjectSafe(did)
- )
+ ty::Predicate::ObjectSafe(did)
)})
);
}
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
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::RegionOutlives(ref pair) => write!(f, "{:?}", pair),
ty::Predicate::TypeOutlives(ref pair) => write!(f, "{:?}", pair),
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
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::RegionOutlives(ref predicate) => write!(f, "{}", predicate),
ty::Predicate::TypeOutlives(ref predicate) => write!(f, "{}", predicate),
id: LintId::of(ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN),
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 {
id: LintId::of(HR_LIFETIME_IN_ASSOC_TYPE),
reference: "issue #33685 <https://github.com/rust-lang/rust/issues/33685>",
p: &ty::Predicate<'tcx>)
{
match *p {
- ty::Predicate::Rfc1592(..) => {
- bug!("RFC1592 predicate in metadata `{:?}`", p);
- }
ty::Predicate::Trait(ref trait_ref) => {
write!(w, "t");
enc_trait_ref(w, cx, trait_ref.0.trait_ref);
if let Err(err) = fulfillment_cx.select_all_or_error(&infcx) {
infcx.report_fulfillment_errors(&err);
}
-
- if let Err(errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
- infcx.report_fulfillment_errors_as_warnings(&errors, id);
- }
});
}
}
tcx.astconv_object_safety_violations(principal.def_id());
if !object_safety_violations.is_empty() {
tcx.report_object_safety_error(
- span, principal.def_id(), None, object_safety_violations)
- .unwrap().emit();
+ span, principal.def_id(), object_safety_violations)
+ .emit();
return tcx.types.err;
}
ty::Predicate::TypeOutlives(..) => None,
ty::Predicate::WellFormed(..) => None,
ty::Predicate::ObjectSafe(..) => None,
- ty::Predicate::Rfc1592(..) => None,
// NB: This predicate is created by breaking down a
// `ClosureType: FnFoo()` predicate, where
// Object safety violations or miscellaneous.
Err(err) => {
- self.report_selection_error(&obligation, &err, None);
+ self.report_selection_error(&obligation, &err);
// Treat this like an obligation and follow through
// with the unsizing - the lack of a coercion should
// be silent, as it causes a type mismatch later.
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();
infcx.resolve_regions_and_report_errors(&free_regions, drop_impl_node_id);
Ok(())
ty::Predicate::WellFormed(..) |
ty::Predicate::ObjectSafe(..) |
ty::Predicate::ClosureKind(..) |
- ty::Predicate::Rfc1592(..) |
ty::Predicate::TypeOutlives(..) => {
None
}
if let Err(errors) = fulfillment_cx.select_all_or_error(&infcx) {
infcx.report_fulfillment_errors(&errors);
}
-
- if let Err(errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
- infcx.report_fulfillment_errors_as_warnings(&errors, item_id);
- }
});
}
})
Ok(()) => { }
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.
ty::Predicate::TypeOutlives(ref data) => {
data.skip_binder().0.is_param(def.index)
}
- ty::Predicate::Rfc1592(..) |
ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) |
ty::Predicate::WellFormed(..) |
Predicate::WellFormed(_) => panic!("not user writable"),
Predicate::ObjectSafe(_) => panic!("not user writable"),
Predicate::ClosureKind(..) => panic!("not user writable"),
- Predicate::Rfc1592(..) => panic!("not user writable"),
}
}
}
pub fn main() {
let x: Vec<Trait + Sized> = Vec::new();
//~^ 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 the trait `std::marker::Sized` cannot be made into an object
}
fn main() {
size_of_copy::<Misc+Copy>();
//~^ ERROR `Misc + Copy: std::marker::Copy` is not satisfied
+ //~| ERROR the trait `std::marker::Copy` cannot be made into an object
}
+++ /dev/null
-// 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");
-}
fn f1<X: ?Sized>(x: &X) {
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: (isize, (X, usize)); //~ERROR `X: std::marker::Sized` is not satisfied
+ let y: (isize, (X, usize));
}
fn f2<X: ?Sized + T>(x: &X) {
let y: X; //~ERROR `X: std::marker::Sized` is not satisfied
+++ /dev/null
-// 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");
-}