jiebi/CodeConvo huggingface dataset:
<ins> // Copyright 2018 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. #![crate_type = "rlib"] #![feature(linkage)] pub fn foo<T>() -> *const() { extern { #[linkage = "extern_weak"] static FOO: *const(); } unsafe { FOO } } </ins>
<ins> // Copyright 2018 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. // Test for issue #18804, #[linkage] does not propagate thorugh generic // functions. Failure results in a linker error. // ignore-asmjs no weak symbol support // ignore-emscripten no weak symbol support // aux-build:lib.rs extern crate lib; fn main() { lib::foo::<i32>(); } </ins>
<ins> // Copyright 2015 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. trait Tup { type T0; type T1; } impl Tup for isize { type T0 = f32; type T1 = (); } fn main() {} </ins>
clean::TypedefItem(ref t) => item_typedef(fmt, self.item, t), clean::MacroItem(ref m) => item_macro(fmt, self.item, m), clean::PrimitiveItem(ref p) => item_primitive(fmt, self.item, p), <ins> clean::StaticItem(ref i) => item_static(fmt, self.item, i), clean::ConstantItem(ref c) => item_constant(fmt, self.item, c), </ins> _ => Ok(()) } }
id = short, name = name)); } <del> struct Initializer<'a>(&'a str, Item<'a>); impl<'a> fmt::Show for Initializer<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Initializer(s, item) = *self; if s.len() == 0 { return Ok(()); } try!(write!(f, "<code> = </code>")); if s.contains("n") { match item.href() { Some(url) => { write!(f, "<a href='{}'>[definition]</a>", url) } None => Ok(()), } } else { write!(f, "<code>{}</code>", s.as_slice()) } } } </del> match myitem.inner { <del> clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => { try!(write!(w, " <tr> <td>{}<code>{}static {}{}: {}</code>{}</td> <td class='docblock'>{}&nbsp;</td> </tr> ", ConciseStability(&myitem.stability), VisSpace(myitem.visibility), MutableSpace(s.mutability), *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); } clean::ConstantItem(ref s) => { try!(write!(w, " <tr> <td>{}<code>{}const {}: {}</code>{}</td> <td class='docblock'>{}&nbsp;</td> </tr> ", ConciseStability(&myitem.stability), VisSpace(myitem.visibility), *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); } </del> clean::ViewItemItem(ref item) => { match item.inner { clean::ExternCrate(ref name, ref src, _) => {
write!(w, "</table>") } <ins> struct Initializer<'a>(&'a str); impl<'a> fmt::Show for Initializer<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Initializer(s) = *self; if s.len() == 0 { return Ok(()); } try!(write!(f, "<code> = </code>")); write!(f, "<code>{}</code>", s.as_slice()) } } fn item_constant(w: &mut fmt::Formatter, it: &clean::Item, c: &clean::Constant) -> fmt::Result { try!(write!(w, "<pre class='rust const'>{vis}const  {name}: {typ}{init}</pre>", vis = VisSpace(it.visibility), name = it.name.as_ref().unwrap().as_slice(), typ = c.type_, init = Initializer(c.expr.as_slice()))); document(w, it) } fn item_static(w: &mut fmt::Formatter, it: &clean::Item, s: &clean::Static) -> fmt::Result { try!(write!(w, "<pre class='rust static'>{vis}static {mutability} {name}: {typ}{init}</pre>", vis = VisSpace(it.visibility), mutability = MutableSpace(s.mutability), name = it.name.as_ref().unwrap().as_slice(), typ = s.type_, init = Initializer(s.expr.as_slice()))); document(w, it) } </ins> fn item_function(w: &mut fmt::Formatter, it: &clean::Item, f: &clean::Function) -> fmt::Result { try!(write!(w, "<pre class='rust fn'>{vis}{fn_style}fn
} } <del> /// Creates a `Vec<T>` directly from the raw constituents. </del> <ins> /// Creates a `Vec<T>` directly from the raw components of another vector. </ins> /// <del> /// This is highly unsafe: /// /// - if `ptr` is null, then `length` and `capacity` should be 0 /// - `ptr` must point to an allocation of size `capacity` /// - there must be `length` valid instances of type `T` at the ///   beginning of that allocation /// - `ptr` must be allocated by the default `Vec` allocator </del> <ins> /// This is highly unsafe, due to the number of invariants that aren't checked. </ins> /// /// # Example ///
} } <ins> fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, span: Span, generics: &ty::Generics<'tcx>) { let impl_params = generics.types.get_slice(subst::TypeSpace).iter() .map(|tp| tp.name).collect::<HashSet<_>>(); for method_param in generics.types.get_slice(subst::FnSpace).iter() { if impl_params.contains(&method_param.name) { tcx.sess.span_err( span, &*format!("type parameter `{}` shadows another type parameter of the same name", token::get_name(method_param.name))); } } } </ins> impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> { fn visit_item(&mut self, i: &ast::Item) { self.check_item_well_formed(i); visit::walk_item(self, i); } <ins> fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl, b: &'v ast::Block, span: Span, id: ast::NodeId) { match fk { visit::FkFnBlock | visit::FkItemFn(..) => {} visit::FkMethod(..) => { match ty::impl_or_trait_item(self.ccx.tcx, local_def(id)) { ty::ImplOrTraitItem::MethodTraitItem(ty_method) => { reject_shadowing_type_parameters(self.ccx.tcx, span, &ty_method.generics) } _ => {} } } } visit::walk_fn(self, fk, fd, b, span) } fn visit_trait_item(&mut self, t: &'v ast::TraitItem) { match t { &ast::TraitItem::ProvidedMethod(_) | &ast::TraitItem::TypeTraitItem(_) => {}, &ast::TraitItem::RequiredMethod(ref method) => { match ty::impl_or_trait_item(self.ccx.tcx, local_def(method.id)) { ty::ImplOrTraitItem::MethodTraitItem(ty_method) => { reject_shadowing_type_parameters( self.ccx.tcx, method.span, &ty_method.generics) } _ => {} } } } visit::walk_trait_item(self, t) } </ins> } pub struct BoundsChecker<'cx,'tcx:'cx> {
<ins> // 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. // Test that shadowed lifetimes generate an error. struct Foo<T>; impl<T> Foo<T> { fn shadow_in_method<T>(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_item<U>(&self) { struct Bar<T, U>; // not a shadow, separate item fn foo<T, U>() {} // same } } trait<T> Bar<T> { fn shadow_in_required<T>(&self); //~^ ERROR type parameter `T` shadows another type parameter fn shadow_in_provided<T>(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_required<U>(&self); fn not_shadow_in_provided<U>(&self) {} } fn main() {} </ins>
match probe.kind { InherentImplCandidate(impl_def_id, ref substs) | ExtensionImplCandidate(impl_def_id, _, ref substs, _) => { <ins> let selcx = &mut traits::SelectionContext::new(self.infcx(), self.fcx); let cause = traits::ObligationCause::misc(self.span, self.fcx.body_id); </ins> // Check whether the impl imposes obligations we have to worry about. let impl_generics = ty::lookup_item_type(self.tcx(), impl_def_id).generics; let impl_bounds = impl_generics.to_bounds(self.tcx(), substs); <del> // FIXME(#20378) assoc type normalization here? // Erase any late-bound regions bound in the impl // which appear in the bounds. let impl_bounds = self.erase_late_bound_regions(&ty::Binder(impl_bounds)); </del> <ins> let traits::Normalized { value: impl_bounds, obligations: norm_obligations } = traits::normalize(selcx, cause.clone(), &impl_bounds); </ins> // Convert the bounds into obligations. let obligations = <del> traits::predicates_for_generics( self.tcx(), traits::ObligationCause::misc(self.span, self.fcx.body_id), &impl_bounds); </del> <ins> traits::predicates_for_generics(self.tcx(), cause.clone(), &impl_bounds); </ins> debug!("impl_obligations={}", obligations.repr(self.tcx())); // Evaluate those obligations to see if they might possibly hold. <del> let mut selcx = traits::SelectionContext::new(self.infcx(), self.fcx); obligations.all(|o| selcx.evaluate_obligation(o)) </del> <ins> obligations.all(|o| selcx.evaluate_obligation(o)) && norm_obligations.iter().all(|o| selcx.evaluate_obligation(o)) </ins> } ObjectCandidate(..) |
<ins> // Copyright 2015 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. // Test that we handle projection types which wind up important for // resolving methods. This test was reduced from a larger example; the // call to `foo()` at the end was failing to resolve because the // winnowing stage of method resolution failed to handle an associated // type projection. #![feature(associated_types)] trait Hasher { type Output; fn finish(&self) -> Self::Output; } trait Hash<H: Hasher> { fn hash(&self, h: &mut H); } trait HashState { type Wut: Hasher; fn hasher(&self) -> Self::Wut; } struct SipHasher; impl Hasher for SipHasher { type Output = u64; fn finish(&self) -> u64 { 4 } } impl Hash<SipHasher> for int { fn hash(&self, h: &mut SipHasher) {} } struct SipState; impl HashState for SipState { type Wut = SipHasher; fn hasher(&self) -> SipHasher { SipHasher } } struct Map<S> { s: S, } impl<S> Map<S> where S: HashState, <S as HashState>::Wut: Hasher<Output=u64>, { fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {} } fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) { map.foo(22); } fn main() {} </ins>
(_, "size_of") => { let tp_ty = *substs.types.get(FnSpace, 0); let lltp_ty = type_of::type_of(ccx, tp_ty); <del> C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty)) </del> <ins> C_uint(ccx, machine::llsize_of_alloc(ccx, lltp_ty)) </ins> } (_, "min_align_of") => { let tp_ty = *substs.types.get(FnSpace, 0);
// Returns, as near as we can figure, the "real" size of a type. As in, the // bits in this number of bytes actually carry data related to the datum <del> // with the type. Not junk, padding, accidentally-damaged words, or // whatever. Rounds up to the nearest byte though, so if you have a 1-bit </del> <ins> // with the type. Not junk, accidentally-damaged words, or whatever. // Note that padding of the type will be included for structs, but not for the // other types (i.e. SIMD types). // Rounds up to the nearest byte though, so if you have a 1-bit </ins> // value, we return 1 here, not 0. Most of rustc works in bytes. Be warned // that LLVM *does* distinguish between e.g. a 1-bit value and an 8-bit value // at the codegen level! In general you should prefer `llbitsize_of_real`
<ins> // Copyright 2015 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. #![feature(simd)] #![allow(non_camel_case_types)] use std::mem; /// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec<T>` properly /// Please consult the issue #20460 fn check<T>() { assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0) } fn main() { check::<u8x2>(); check::<u8x3>(); check::<u8x4>(); check::<u8x5>(); check::<u8x6>(); check::<u8x7>(); check::<u8x8>(); check::<i16x2>(); check::<i16x3>(); check::<i16x4>(); check::<i16x5>(); check::<i16x6>(); check::<i16x7>(); check::<i16x8>(); check::<f32x2>(); check::<f32x3>(); check::<f32x4>(); check::<f32x5>(); check::<f32x6>(); check::<f32x7>(); check::<f32x8>(); } #[simd] struct u8x2(u8, u8); #[simd] struct u8x3(u8, u8, u8); #[simd] struct u8x4(u8, u8, u8, u8); #[simd] struct u8x5(u8, u8, u8, u8, u8); #[simd] struct u8x6(u8, u8, u8, u8, u8, u8); #[simd] struct u8x7(u8, u8, u8, u8, u8, u8, u8); #[simd] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); #[simd] struct i16x2(i16, i16); #[simd] struct i16x3(i16, i16, i16); #[simd] struct i16x4(i16, i16, i16, i16); #[simd] struct i16x5(i16, i16, i16, i16, i16); #[simd] struct i16x6(i16, i16, i16, i16, i16, i16); #[simd] struct i16x7(i16, i16, i16, i16, i16, i16, i16); #[simd] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); #[simd] struct f32x2(f32, f32); #[simd] struct f32x3(f32, f32, f32); #[simd] struct f32x4(f32, f32, f32, f32); #[simd] struct f32x5(f32, f32, f32, f32, f32); #[simd] struct f32x6(f32, f32, f32, f32, f32, f32); #[simd] struct f32x7(f32, f32, f32, f32, f32, f32, f32); #[simd] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); </ins>
<ins> // Copyright 2015 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. trait T : Iterator<Item=Self::Item> //~^ ERROR unsupported cyclic reference between types/traits detected {} fn main() {} </ins>
<ins> // Copyright 2015 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. trait Foo {} impl<'a> Foo for Foo+'a {} //~^ ERROR the object type `Foo + 'a` automatically implements the trait `Foo` fn main() {} </ins>
<ins> // Copyright 2015 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-tidy-linelength use std::ops::Add; fn main() { let x = &10 as //~^ ERROR the value of the associated type `Output` (from the trait `core::ops::Add`) must be specified &Add; //~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self` } </ins>
<ins> // Copyright 2015 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. extern crate libc; fn main() { let foo: *mut libc::c_void; let cb: &mut Fn() = unsafe { &mut *(foo as *mut Fn()) //~^ ERROR use of possibly uninitialized variable: `foo` }; } </ins>
"-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)] } <ins> fn target_cpu(arch: Arch) -> String { match arch { X86_64 => "x86-64", _ => "generic", }.to_string() } </ins> pub fn opts(arch: Arch) -> TargetOptions { TargetOptions { <ins> cpu: target_cpu(arch), </ins> dynamic_linking: false, executables: true, // Although there is an experimental implementation of LLVM which
pub mod generic; <ins> pub fn expand_deprecated_deriving(cx: &mut ExtCtxt, span: Span, _: &MetaItem, _: &Item, _: Box<FnMut(P<Item>)>) { cx.span_err(span, "`deriving` has been renamed to `derive`"); } </ins> pub fn expand_meta_derive(cx: &mut ExtCtxt, _span: Span, mitem: &MetaItem,
<ins> // Copyright 2015 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. #[deriving(Clone)] //~ ERROR `deriving` has been renamed to `derive` struct Foo; fn main() {} </ins>
use middle::infer::InferCtxt; use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef, Ty}; use middle::ty::fold::TypeFoldable; <del> use std::collections::HashMap; </del> <ins> use util::nodemap::{FnvHashMap, FnvHashSet}; </ins> use std::fmt; use syntax::codemap::Span; use syntax::attr::{AttributeMethods, AttrMetaMethods};
(gen.name.as_str().to_string(), trait_ref.substs.types.get(param, i) .to_string()) <del> }).collect::<HashMap<String, String>>(); </del> <ins> }).collect::<FnvHashMap<String, String>>(); </ins> generic_map.insert("Self".to_string(), trait_ref.self_ty().to_string()); let parser = Parser::new(&istring);
"the trait `{}` cannot be made into an object", tcx.item_path_str(trait_def_id)); <ins> let mut reported_violations = FnvHashSet(); </ins> for violation in violations { <ins> if !reported_violations.insert(violation.clone()) { continue; } </ins> match violation { ObjectSafetyViolation::SizedSelf => { tcx.sess.fileline_note(
} } <ins> impl<'tcx> PartialEq for Method<'tcx> { #[inline] fn eq(&self, other: &Self) -> bool { self.def_id == other.def_id } } impl<'tcx> Eq for Method<'tcx> {} impl<'tcx> Hash for Method<'tcx> { #[inline] fn hash<H: Hasher>(&self, s: &mut H) { self.def_id.hash(s) } } </ins> #[derive(Clone, Copy, Debug)] pub struct AssociatedConst<'tcx> { pub name: Name,
<ins> // Copyright 2015 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. trait Array: Sized {} fn f<T: Array>(x: &T) { let _ = x //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` as &Array; //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` } fn main() {} </ins>
obligations); if projected_ty.has_projection_types() { <del> let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); </del> <ins> let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth+1); </ins> let normalized_ty = normalizer.fold(&projected_ty); debug!("normalize_projection_type: normalized_ty={:?} depth={}",
obj)) } <ins> pub fn enter_type_of(&self, ty: Ty<'tcx>) -> TypeOfDepthLock<'b, 'tcx> { let current_depth = self.local.type_of_depth.get(); debug!("enter_type_of({:?}) at depth {:?}", ty, current_depth); if current_depth > self.sess().recursion_limit.get() { self.sess().fatal( &format!("overflow representing the type `{}`", ty)) } self.local.type_of_depth.set(current_depth + 1); TypeOfDepthLock(self.local) } </ins> pub fn check_overflow(&self) -> bool { self.shared.check_overflow }
} } <ins> pub struct TypeOfDepthLock<'a, 'tcx: 'a>(&'a LocalCrateContext<'tcx>); impl<'a, 'tcx> Drop for TypeOfDepthLock<'a, 'tcx> { fn drop(&mut self) { self.0.type_of_depth.set(self.0.type_of_depth.get() - 1); } } </ins> /// Declare any llvm intrinsics that you might need fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> { macro_rules! ifn {
<ins> // Copyright 2015 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. trait Foo { type A; } struct FooStruct; impl Foo for FooStruct { //~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A` type A = <FooStruct as Foo>::A; } fn main() {} </ins>
<ins> // Copyright 2015 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. // error-pattern: overflow representing the type `S` trait Mirror { type It; } impl<T> Mirror for T { type It = Self; } struct S(Option<<S as Mirror>::It>); fn main() { let _s = S(None); } </ins>
<ins> // Copyright 2015 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. pub struct Outer<T: Trait>(T); pub struct Inner<'a> { value: &'a bool } pub trait Trait { type Error; fn ready(self) -> Self::Error; } impl<'a> Trait for Inner<'a> { type Error = Outer<Inner<'a>>; fn ready(self) -> Outer<Inner<'a>> { Outer(self) } } fn main() { let value = true; let inner = Inner { value: &value }; assert_eq!(inner.ready().0.value, &value); } </ins>
/// /// ``` /// let a = [1, 2, 3, 4, 5]; <del> /// assert!(a.iter().fold(0, |a, &b| a + b) == 15); </del> <ins> /// assert!(a.iter().fold(0, |acc, &item| acc + item) == 15); </ins> /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")]