jiebi/CodeConvo huggingface dataset:
<ins> // Copyright 2017 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(closure_to_fn_coercion)] fn main() { let bar: fn(&mut u32) = |_| {}; //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter fn foo(x: Box<Fn(&i32)>) {} let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>; foo(bar); //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter } </ins>
- [abi_sysv64](abi-sysv64.md) - [abi_unadjusted](abi-unadjusted.md) - [abi_vectorcall](abi-vectorcall.md) <ins> - [abi_x86_interrupt](abi-x86-interrupt.md) </ins> - [advanced_slice_patterns](advanced-slice-patterns.md) - [alloc_jemalloc](alloc-jemalloc.md) - [alloc_system](alloc-system.md)
/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// assert_ne!((1f32).to_bits(), 1f32 as u32); // to_bits() is not casting! /// assert_eq!((12.5f32).to_bits(), 0x41480000); /// /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn to_bits(self) -> u32 { unsafe { ::mem::transmute(self) }
/// let snan = 0x7F800001; /// assert_ne!(f32::from_bits(snan).to_bits(), snan); /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn from_bits(mut v: u32) -> Self { const EXP_MASK: u32   = 0x7F800000;
/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting! /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000); /// /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn to_bits(self) -> u64 { unsafe { ::mem::transmute(self) }
/// let snan = 0x7FF0000000000001; /// assert_ne!(f64::from_bits(snan).to_bits(), snan); /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn from_bits(mut v: u64) -> Self { const EXP_MASK: u64   = 0x7FF0000000000000;
} impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedMut { <del> fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprMatch(_, ref arms, _) = e.node { for a in arms { self.check_unused_mut_pat(cx, &a.pats) } } </del> <ins> fn check_arm(&mut self, cx: &LateContext, a: &hir::Arm) { self.check_unused_mut_pat(cx, &a.pats) </ins> } <del> fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { if let hir::StmtDecl(ref d, _) = s.node { if let hir::DeclLocal(ref l) = d.node { self.check_unused_mut_pat(cx, slice::ref_slice(&l.pat)); } } </del> <ins> fn check_local(&mut self, cx: &LateContext, l: &hir::Local) { self.check_unused_mut_pat(cx, slice::ref_slice(&l.pat)); </ins> } fn check_fn(&mut self,
This flag will set which lints should be set to the [forbid level](lints/levels.html#forbid). <ins> ## `-Z`: set unstable options This flag will allow you to set unstable options of rustc. In order to set multiple options, the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`. Specifying options with -Z is only available on nightly. To view all available options run: `rustc -Z help`. </ins> ## `--cap-lints`: set the most restrictive lint level This flag lets you 'cap' lints, for more, [see here](lints/levels.html#capping-lints).
impl NonCamelCaseTypes { fn check_case(&self, cx: &LateContext, sort: &str, name: ast::Name, span: Span) { <ins> fn char_has_case(c: char) -> bool { c.is_lowercase() || c.is_uppercase() } </ins> fn is_camel_case(name: ast::Name) -> bool { let name = name.as_str(); if name.is_empty() {
// start with a non-lowercase letter rather than non-uppercase // ones (some scripts don't have a concept of upper/lowercase) <del> !name.is_empty() && !name.chars().next().unwrap().is_lowercase() && !name.contains('_') </del> <ins> !name.is_empty() && !name.chars().next().unwrap().is_lowercase() && !name.contains("__") && !name.chars().collect::<Vec<_>>().windows(2).any(|pair| { // contains a capitalisable character followed by, or preceded by, an underscore char_has_case(pair[0]) && pair[1] == '_' || char_has_case(pair[1]) && pair[0] == '_' }) </ins> } fn to_camel_case(s: &str) -> String { <del> s.split('_') .flat_map(|word| { </del> <ins> s.trim_matches('_') .split('_') .map(|word| { </ins> word.chars().enumerate().map(|(i, c)| if i == 0 { c.to_uppercase().collect::<String>() } else { c.to_lowercase().collect() }) <ins> .collect::<Vec<_>>() .concat() </ins> }) <ins> .filter(|x| !x.is_empty()) </ins> .collect::<Vec<_>>() <del> .concat() </del> <ins> .iter().fold((String::new(), None), |(acc, prev): (String, Option<&String>), next| { // separate two components with an underscore if their boundary cannot // be distinguished using a uppercase/lowercase case distinction let join = if let Some(prev) = prev { let l = prev.chars().last().unwrap(); let f = next.chars().next().unwrap(); !char_has_case(l) && !char_has_case(f) } else { false }; (acc + if join { "_" } else { "" } + next, Some(next)) }).0 </ins> } if !is_camel_case(name) {
type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` <ins> struct X86_64; struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` </ins> fn main() { }
} #[stable(feature = "collection_debug", since = "1.17.0")] <del> impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> { </del> <ins> impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for Keys<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> f.debug_list().entries(self.inner.clone()).finish() </del> <ins> f.debug_list().entries(self.clone()).finish() </ins> } }
} #[stable(feature = "collection_debug", since = "1.17.0")] <del> impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { </del> <ins> impl<'a, K: 'a, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> f.debug_list().entries(self.inner.clone()).finish() </del> <ins> f.debug_list().entries(self.clone()).finish() </ins> } }
} #[stable(feature = "std_debug", since = "1.16.0")] <del> impl<'a, K: Debug, V: Debug> fmt::Debug for Keys<'a, K, V> { </del> <ins> impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone())
} #[stable(feature = "std_debug", since = "1.16.0")] <del> impl<'a, K: Debug, V: Debug> fmt::Debug for Values<'a, K, V> { </del> <ins> impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone())
} } <ins> fn trace_macros_note(cx: &mut ExtCtxt, sp: Span, message: String) { let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp); let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert_with(Vec::new); values.push(message); } </ins> /// Given `lhses` and `rhses`, this is the new macro we create fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, sp: Span,
rhses: &[quoted::TokenTree]) -> Box<MacResult+'cx> { if cx.trace_macros() { <del> let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp); let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert_with(Vec::new); values.push(format!("expands to `{}! {{ {} }}`", name, arg)); </del> <ins> trace_macros_note(cx, sp, format!("expanding `{}! {{ {} }}`", name, arg)); </ins> } // Which arm's failure should we report? (the one furthest along)
}; // rhs has holes ( `$id` and `$(...)` that need filled) let tts = transcribe(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); <ins> if cx.trace_macros() { trace_macros_note(cx, sp, format!("to `{}`", tts)); } </ins> let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership,
14 |     println!("Hello, World!"); |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ | <del> = note: expands to `println! { "Hello, World!" }` = note: expands to `print! { concat ! ( "Hello, World!" , "/n" ) }` </del> <ins> = note: expanding `println! { "Hello, World!" }` = note: to `print ! ( concat ! ( "Hello, World!" , "/n" ) )` = note: expanding `print! { concat ! ( "Hello, World!" , "/n" ) }` = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, World!" , "/n" ) ) )` </ins>
<ins> // Copyright 2017 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. fn main() { let value = 1; match SomeStruct(value) { StructConst1(_) => { }, //~^ ERROR expected tuple struct/variant, found constant `StructConst1` _ => { }, } struct SomeStruct(u8); const StructConst1 : SomeStruct = SomeStruct(1); const StructConst2 : SomeStruct = SomeStruct(2); } </ins>
<ins> // Copyright 2017 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(associated_consts)] trait Foo { const BAR: i32; fn foo(self) -> &'static i32 { //~^ ERROR the trait bound `Self: std::marker::Sized` is not satisfied &<Self>::BAR } } fn main() {} </ins>
<ins> // Copyright 2017 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. macro_rules! get_opt { ($tgt:expr, $field:ident) => { if $tgt.has_$field() {} } } fn main() { get_opt!(bar, foo); //~^ ERROR expected `{`, found `foo` } </ins>
<ins> // Copyright 2017 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. fn main() { let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; //~^ ERROR expected function, found `{float}` } </ins>
<ins> // Copyright 2017 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. // #45662 #![feature(repr_align)] #![feature(attr_literals)] #[repr(align(16))] pub struct A { y: i64, } pub extern "C" fn foo(x: A) {} fn main() {} </ins>
<ins> // Copyright 2017 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(conservative_impl_trait)] use std::iter::once; struct Foo { x: i32, } impl Foo { fn inside(&self) -> impl Iterator<Item = &i32> { once(&self.x) } } fn main() { println!("hi"); } </ins>
<ins> // Copyright 2017 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(unsize, coerce_unsized)] #[repr(packed)] struct UnalignedPtr<'a, T: ?Sized> where T: 'a, { data: &'a T, } fn main() { impl<'a, T, U> std::ops::CoerceUnsized<UnalignedPtr<'a, U>> for UnalignedPtr<'a, T> where T: std::marker::Unsize<U> + ?Sized, U: ?Sized, { } let arr = [1, 2, 3]; let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr }; let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned; } </ins>
<ins> // Copyright 2017 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. // #42164 #![feature(decl_macro)] #![allow(dead_code)] pub macro m($inner_str:expr) { #[doc = $inner_str] struct S; } macro_rules! define_f { ($name:expr) => { #[export_name = $name] fn f() {} } } fn main() { define_f!(concat!("exported_", "f")); m!(stringify!(foo)); } </ins>
// option. This file may not be copied, modified, or distributed // except according to those terms. <del> use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; </del> use rustc_data_structures::stable_hasher; use std::mem; use std::slice; <del> #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] </del> <ins> #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)] </ins> pub struct Fingerprint(u64, u64); impl Fingerprint {
} } <del> impl Encodable for Fingerprint { #[inline] fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { s.emit_u64(self.0.to_le())?; s.emit_u64(self.1.to_le()) } } impl Decodable for Fingerprint { #[inline] fn decode<D: Decoder>(d: &mut D) -> Result<Fingerprint, D::Error> { let _0 = u64::from_le(d.read_u64()?); let _1 = u64::from_le(d.read_u64()?); Ok(Fingerprint(_0, _1)) } } </del> impl ::std::fmt::Display for Fingerprint { fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { write!(formatter, "{:x}-{:x}", self.0, self.1)
let ast::Path { ref segments, span } = *path; let path: Vec<_> = segments.iter().map(|seg| respan(seg.span, seg.identifier)).collect(); let invocation = self.invocations[&scope]; <del> self.current_module = invocation.module.get(); </del> <ins> let module = invocation.module.get(); self.current_module = if module.is_trait() { module.parent.unwrap() } else { module }; </ins> if path.len() > 1 { if !self.use_extern_macros && self.gated_errors.insert(span) {
<ins> // Copyright 2017 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. // aux-build:attr-on-trait.rs #![feature(proc_macro)] extern crate attr_on_trait; trait Foo { #[attr_on_trait::foo] fn foo() {} } impl Foo for i32 { fn foo(&self) {} } fn main() { 3i32.foo(); } </ins>
<ins> // Copyright 2017 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. // no-prefer-dynamic #![feature(proc_macro)] #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_attribute] pub fn foo(attr: TokenStream, item: TokenStream) -> TokenStream { drop(attr); assert_eq!(item.to_string(), "fn foo() { }"); "fn foo(&self);".parse().unwrap() } </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. // only-x86_64 #![allow(dead_code, non_upper_case_globals)] #![feature(asm)] #[repr(C)] pub struct D32x4(f32,f32,f32,f32); impl D32x4 { fn add(&self, vec: Self) -> Self { unsafe { let ret: Self; asm!(" movaps $1, %xmm1 movaps $2, %xmm2 addps %xmm1, %xmm2 movaps $xmm1, $0 " : "=r"(ret) : "1"(self), "2"(vec) : "xmm1", "xmm2" ); ret } } } fn main() { } </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. const C: *const u8 = &0; fn foo(x: *const u8) { match x { C => {} _ => {} } } const D: *const [u8; 4] = b"abcd"; fn main() { match D { D => {} _ => {} } } </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. pub trait Foo<'a> { type Bar; fn foo(&'a self) -> Self::Bar; } impl<'a, 'b, T: 'a> Foo<'a> for &'b T { type Bar = &'a T; fn foo(&'a self) -> &'a T { self } } pub fn uncallable<T, F>(x: T, f: F) where T: for<'a> Foo<'a>, F: for<'a> Fn(<T as Foo<'a>>::Bar) { f(x.foo()); } pub fn catalyst(x: &i32) { broken(x, |_| {}) } pub fn broken<F: Fn(&i32)>(x: &i32, f: F) { uncallable(x, |y| f(y)); } fn main() { } </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. fn main() { let thing = (); let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] } fn f(){ let q = 1; <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] } </ins>
<ins> error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:13:23 | LL |     let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant |                       ^^^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:19:13 | LL |     <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant |             ^ non-constant value error[E0516]: `typeof` is a reserved keyword but unimplemented --> $DIR/issue-42060.rs:13:16 | LL |     let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant |                ^^^^^^^^^^^^^ reserved keyword error[E0516]: `typeof` is a reserved keyword but unimplemented --> $DIR/issue-42060.rs:19:6 | LL |     <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant |      ^^^^^^^^^ reserved keyword error: aborting due to 4 previous errors Some errors occurred: E0435, E0516. For more information about an error, try `rustc --explain E0435`. </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. fn main() { | } //~^ ERROR expected `|`, found `}` | //~^ ERROR expected item, found `|` </ins>
} mir::Rvalue::Len(ref lvalue) => { <del> let tr_lvalue = self.trans_lvalue(&bcx, lvalue); </del> <ins> let size = self.evaluate_array_len(&bcx, lvalue); </ins> let operand = OperandRef { <del> val: OperandValue::Immediate(tr_lvalue.len(bcx.ccx)), </del> <ins> val: OperandValue::Immediate(size), </ins> ty: bcx.tcx().types.usize, }; (bcx, operand)
} } <ins> fn evaluate_array_len(&mut self, bcx: &Builder<'a, 'tcx>, lvalue: &mir::Lvalue<'tcx>) -> ValueRef { // ZST are passed as operands and require special handling // because trans_lvalue() panics if Local is operand. if let mir::Lvalue::Local(index) = *lvalue { if let LocalRef::Operand(Some(op)) = self.locals[index] { if common::type_is_zero_size(bcx.ccx, op.ty) { if let ty::TyArray(_, n) = op.ty.sty { return common::C_uint(bcx.ccx, n); } } } } // use common size calculation for non zero-sized types let tr_value = self.trans_lvalue(&bcx, lvalue); return tr_value.len(bcx.ccx); } </ins> pub fn trans_scalar_binop(&mut self, bcx: &Builder<'a, 'tcx>, op: mir::BinOp,
<ins> // 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. fn main() { &&[()][0]; println!("{:?}", &[(),()][1]); } </ins>