jiebi/CodeConvo huggingface dataset:
Change:
This would be useful in cases where we mostly want to enforce guarantees but need to break the rules in one place. (e.g. the Servo interface to html5ever which needs to GC-trace a mutably-borrowed parser)
Similarly, this would be useful for RAII classes that need to be fail-proof in the face of task failure while there are outstanding RefCell borrows.
I don't think that case should be an issue; the / destructors have to run before their 's. They don't right now in some cases due to some unsoundness problems but that will be fixed: .
Same for , please, for
Does the accessor itself need to be ? I don't think so, because the relevant ops are and we're only handing out shared references to it.

Discussion:
*self.value.get() = value; } } <ins> /// Get a reference to the underlying `UnsafeCell`. /// /// This can be used to circumvent `Cell`'s safety checks. /// /// This function is `unsafe` because `UnsafeCell`'s field is public. #[inline] #[experimental] pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> { &self.value } </ins> } #[unstable = "waiting for `Clone` trait to become stable"]

None => fail!("RefCell<T> already borrowed") } } <ins> /// Get a reference to the underlying `UnsafeCell`. /// /// This can be used to circumvent `RefCell`'s safety checks. /// /// This function is `unsafe` because `UnsafeCell`'s field is public. #[inline] #[experimental] pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> { &self.value } </ins> } #[unstable = "waiting for `Clone` to become stable"]

} assert!(x.try_borrow_mut().is_some()); } <ins> #[test] fn as_unsafe_cell() { let c1: Cell<uint> = Cell::new(0u); c1.set(1u); assert_eq!(1u, unsafe { *c1.as_unsafe_cell().get() }); let c2: Cell<uint> = Cell::new(0u); unsafe { *c2.as_unsafe_cell().get() = 1u; } assert_eq!(1u, c2.get()); let r1: RefCell<uint> = RefCell::new(0u); *r1.borrow_mut() = 1u; assert_eq!(1u, unsafe { *r1.as_unsafe_cell().get() }); let r2: RefCell<uint> = RefCell::new(0u); unsafe { *r2.as_unsafe_cell().get() = 1u; } assert_eq!(1u, *r2.borrow()); } </ins>
Change:
Consider the following benchmark: Which produces the following output: test _range ... bench: ns/iter (+/- 1033) test assembly ... bench: ns/iter (+/- 248) test enumerate ... bench: ns/iter (+/- 566) test iter ... bench: ns/iter (+/- 465) test position ... bench: ns/iter (+/- 384) is the correct abstraction for this but its code is 50% slower than the naive assembly implementation and 40% slower than .
I'm getting different results: $ rustc --opt-level=3 --test $ ./slowposition --bench running 4 tests test _range ... bench: ns/iter (+/- 8183) test enumerate ... bench: ns/iter (+/- 1615) test iter ... bench: ns/iter (+/- 4164) test position ... bench: ns/iter (+/- ) test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured (the assembly version segfaulted on me).
wow. What platform?
On a macbook. Here's another run without a bunch of stuff in the background screwing up the variance: $ rustc --opt-level=3 --test $ ./slowposition --bench running 4 tests test _range ... bench: ns/iter (+/- 2331) test enumerate ... bench: ns/iter (+/- 2851) test iter ... bench: ns/iter (+/- 3995) test position ... bench: ns/iter (+/- 978)
The IL for -s inner loop is (de-gensymmed) Which looks sane, except for the spurious null check (which remains in the assembly). Benchmarks on my machine:
The spurious null check is the issue – writing a over it in the object code gives ±385 ns/iter on my laptop.
New code: New results: Unacceptable performance.

Discussion:
use core::default::Default; use core::fmt; use core::hash::{self, Hash}; <ins> use core::intrinsics::assume; </ins> use core::iter::{repeat, FromIterator, IntoIterator}; use core::marker::{self, ContravariantLifetime, InvariantType}; use core::mem;

#[stable(feature = "rust1", since = "1.0.0")] fn as_slice(&self) -> &[T] { unsafe { <ins> let p = *self.ptr; if cfg!(not(stage0)) { // NOTE remove cfg after next snapshot assume(p != 0 as *mut T); } </ins> mem::transmute(RawSlice { <del> data: *self.ptr, </del> <ins> data: p, </ins> len: self.len }) }

#[inline] #[stable(feature = "rust1", since = "1.0.0")] <del> fn is_null(self) -> bool { self as usize == 0 } </del> <ins> fn is_null(self) -> bool { self == 0 as *const T } </ins> #[inline] #[stable(feature = "rust1", since = "1.0.0")]

#[inline] #[stable(feature = "rust1", since = "1.0.0")] <del> fn is_null(self) -> bool { self as usize == 0 } </del> <ins> fn is_null(self) -> bool { self == 0 as *mut T } </ins> #[inline] #[stable(feature = "rust1", since = "1.0.0")]
Change:
I tried to do this: And I got the error: S It seems to try to look for a member function and ignore the member variable. One person(alexchandel) in the rust irc channel said this was a bug and should work, another(p1start) said the error message should be improved.
To get this working, you need to write . The problem is that Rust will search only for methods named and not for fields. I don't know if there are plans of changing this behavior. If not, then I guess it would be nice to get a clearer error message which explains this.
I've tagged the bug so that it covers improving the error message by adding something like (s.func)(...)func.
I guess we would need to check if the type has a field with the same name as the method.
I got it working with the nice people in the channel but thanks anyway. Alright, sounds good.

Discussion:
{ match error { NoMatch(static_sources) => { <ins> let cx = fcx.tcx(); let method_ustring = method_name.user_string(cx); // True if the type is a struct and contains a field with // the same name as the not-found method let is_field = match ty::get(rcvr_ty).sty { ty_struct(did, _) => ty::lookup_struct_fields(cx, did) .iter() .any(|f| f.name.user_string(cx) == method_ustring), _ => false }; </ins> fcx.type_error_message( span, |actual| { format!("type `{}` does not implement any  method in scope named `{}`", actual, <del> method_name.user_string(fcx.tcx())) </del> <ins> method_ustring) </ins> }, rcvr_ty, None); <ins> // If the method has the name of a field, give a help note if is_field { cx.sess.span_note(span, format!("use `(s.{0})(...)` if you meant to call the  function stored in the `{0}` field", method_ustring).as_slice()); } </ins> if static_sources.len() > 0 { fcx.tcx().sess.fileline_note( span,

<ins> // Copyright 2014 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. struct Obj<'a> { closure: ||: 'a -> u32 } fn main() { let o = Obj { closure: || 42 }; o.closure(); //~ ERROR type `Obj<'_>` does not implement any method in scope named `closure` //~^ NOTE use `(s.closure)(...)` if you meant to call the function stored in the `closure` field } </ins>
Change:
I just upgraded my to . But when I tried to rebuild my project, it failed with the following errors: , , etc... are constants of type . What does the error mean? I am confused.
Thanks . It seems that the bug is fixed, please merge it to upstream asap. :)
The same as

Discussion:
let const_did = tcx.def_map.borrow().get_copy(&pat.id).def_id(); let const_pty = ty::lookup_item_type(tcx, const_did); fcx.write_ty(pat.id, const_pty.ty); <del> demand::eqtype(fcx, pat.span, expected, const_pty.ty); </del> <ins> demand::suptype(fcx, pat.span, expected, const_pty.ty); </ins> } ast::PatIdent(bm, ref path, ref sub) if pat_is_binding(&tcx.def_map, pat) => { let typ = fcx.local_ty(pat.span, pat.id);

<ins> // Copyright 2014 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 X: &'static str = "12345"; fn test(s: String) -> bool { match s.as_slice() { X => true, _ => false } } fn main() { assert!(test("12345".to_string())); } </ins>
Change:
I was playing with DST by reimplementing the primitive as a , but hit an ICE while testing. The code is in this cc This seems similar to cc
Minimal test case:

Discussion:
<ins> // Copyright 2014 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 wrapping an unsized struct in an enum which gets optimised does // not ICE. struct Str { f: [u8] } fn main() { let str: Option<&Str> = None; str.is_some(); } </ins>
Change:
There should be one cross-crate implementation of this trait, but a JS error is thrown trying to load it:

Discussion:
var code = $('<code>').append(structs[j]); $.each(code.find('a'), function(idx, a) { var href = $(a).attr('href'); <del> if (!href.startsWith('http')) { $(a).attr('href', rootPath + $(a).attr('href')); </del> <ins> if (href && !href.startsWith('http')) { $(a).attr('href', rootPath + href); </ins> } }); var li = $('<li>').append(code);
Change:
This may be related to but here is some test code for this specific case: Which prints: Ideally this would not issue a warning.

Discussion:
tcx: &'a ty::ctxt<'tcx>, live_symbols: Box<HashSet<ast::NodeId>>, struct_has_extern_repr: bool, <del> ignore_paths: bool </del> <ins> ignore_non_const_paths: bool </ins> } impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {

tcx: tcx, live_symbols: box HashSet::new(), struct_has_extern_repr: false, <del> ignore_paths: false </del> <ins> ignore_non_const_paths: false </ins> } }

fn lookup_and_handle_definition(&mut self, id: &ast::NodeId) { self.tcx.def_map.borrow().find(id).map(|def| { match def { <ins> &def::DefConst(_) => { self.check_def_id(def.def_id()) } _ if self.ignore_non_const_paths => (), </ins> &def::DefPrimTy(_) => (), &def::DefVariant(enum_id, variant_id, _) => { self.check_def_id(enum_id);

self.handle_field_pattern_match(pat, fields.as_slice()); } _ if pat_util::pat_is_const(def_map, pat) => { <del> // it might be the only use of a static: </del> <ins> // it might be the only use of a const </ins> self.lookup_and_handle_definition(&pat.id) } _ => () } <del> self.ignore_paths = true; </del> <ins> self.ignore_non_const_paths = true; </ins> visit::walk_pat(self, pat); <del> self.ignore_paths = false; </del> <ins> self.ignore_non_const_paths = false; </ins> } fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId) { <del> if !self.ignore_paths { self.lookup_and_handle_definition(&id); } </del> <ins> self.lookup_and_handle_definition(&id); </ins> visit::walk_path(self, path); }

<ins> // Copyright 2014 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. #![deny(dead_code)] const LOW_RANGE: char = '0'; const HIGH_RANGE: char = '9'; fn main() { match '5' { LOW_RANGE...HIGH_RANGE => (), _ => () }; } </ins>
Change:
While trying to replace the "secret" functions (e.g. ) used for with their UFCS versions (e.g. ), I ran into the following ICE: I couldn't get a backtrace with nor with cc
I have similar ICE without inlining: But i can't reproduce it in simple code example for now.
Caught it! Main body: Test body:
I guess this the related, since I'm actually trying to use UFCS to inline a function and the function is not defined in my crate, Using rustc 0.13.0-dev ( 2014-10-24 03:22:29 +0000) as well as master from playpen, By the way, it might be nice if playpen was able to automatically display (and/or send) that information when ICEs are found.
Some of these look similar to , but the fix for that went in recently...
your issue is , and the fix for it just landed. I think the others still occur.
your ICE does not appear to be UFCS-related. Can you open a separate issue?
I can confirm that the original example still ICEs even with the fix for , so it is a different issue:
I'm seeing a def with the wrong crate ID. It looks like an AST decoding problem. Hopefully an easy fix.

Discussion:
<ins> // Copyright 2014 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"] struct Foo; trait Tr { fn tr(&self); } impl Tr for Foo { fn tr(&self) {} } fn take_method<T>(f: fn(&T), t: &T) {} #[inline] pub fn pass_method() { take_method(Tr::tr, &Foo); } </ins>

<ins> // Copyright 2014 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 don't ICE when inlining a function from another // crate that uses a trait method as a value due to incorrectly // translating the def ID of the trait during AST decoding. // aux-build:issue-18501.rs extern crate "issue-18501" as issue; fn main() { issue::pass_method(); } </ins>
Change:
Out:
It seems to occur even without UFCS:
The problem seems to be with zero-sized types. Since this works fine:
Ok, yea the problem is when we coerce a bare fn that returns a zero sized type to a closure. I'll put up a PR once I've tested this fix a bit.

Discussion:
let retval = Call(bcx, fn_ptr, llargs.as_slice(), None); match f.sig.output { ty::FnConverging(output_type) => { <del> if type_is_zero_size(ccx, output_type) || fcx.llretslotptr.get().is_some() { </del> <ins> if return_type_is_void(ccx, output_type) || fcx.llretslotptr.get().is_some() { </ins> RetVoid(bcx); } else { Ret(bcx, retval);

<ins> // Copyright 2014 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 coercing bare fn's that return a zero sized type to // a closure doesn't cause an LLVM ERROR struct Foo; fn uint_to_foo(_: uint) -> Foo { Foo } #[allow(unused_must_use)] fn main() { range(0u, 10).map(uint_to_foo); } </ins>
Change:
There are three versions of these layouts for functions, traits, and slices, but the compiler relies on these being the same. We should replace them with a single layout: and or something. While we're at it, we should probably find uses of len/length names in the DST code and replace it with something more generic.
I merged the constants. Could you elaborate on the length names? Are there more constants like these?
What still needs to be done here, if anything?
Looks done.

Discussion:
// option. This file may not be copied, modified, or distributed // except according to those terms. <del> #![allow(non_upper_case_globals)] pub const box_field_refcnt: uint = 0u; pub const box_field_drop_glue: uint = 1u; pub const box_field_body: uint = 4u; </del> <ins> pub const BOX_FIELD_DROP_GLUE: uint = 1u; pub const BOX_FIELD_BODY: uint = 4u; </ins> /// The first half of a fat pointer. /// - For a closure, this is the code address.

let ccx = bcx.ccx(); let ty = Type::at_box(ccx, type_of(ccx, body_t)); let boxptr = PointerCast(bcx, boxptr, ty.ptr_to()); <del> GEPi(bcx, boxptr, &[0u, abi::box_field_body]) </del> <ins> GEPi(bcx, boxptr, &[0u, abi::BOX_FIELD_BODY]) </ins> } fn require_alloc_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,

// Allocate space and store the destructor pointer: let Result {bcx, val: llbox} = malloc_raw_dyn(bcx, ptr_llty, t, size, llalign); <del> let dtor_ptr = GEPi(bcx, llbox, &[0u, abi::box_field_drop_glue]); </del> <ins> let dtor_ptr = GEPi(bcx, llbox, &[0u, abi::BOX_FIELD_DROP_GLUE]); </ins> let drop_glue_field_ty = type_of(ccx, ty::mk_nil_ptr(bcx.tcx())); let drop_glue = PointerCast(bcx, glue::get_drop_glue(ccx, ty::mk_uniq(bcx.tcx(), t)), drop_glue_field_ty);

bv.to_string(ccx)).as_slice()); } <del> let bound_data = GEPi(bcx, llbox, &[0u, abi::box_field_body, i]); </del> <ins> let bound_data = GEPi(bcx, llbox, &[0u, abi::BOX_FIELD_BODY, i]); </ins> match bv.action { ast::CaptureByValue => {

let env_ptr_ty = Type::at_box(bcx.ccx(), Type::i8(bcx.ccx())).ptr_to(); let env = PointerCast(bcx, env, env_ptr_ty); with_cond(bcx, IsNotNull(bcx, env), |bcx| { <del> let dtor_ptr = GEPi(bcx, env, &[0u, abi::box_field_drop_glue]); </del> <ins> let dtor_ptr = GEPi(bcx, env, &[0u, abi::BOX_FIELD_DROP_GLUE]); </ins> let dtor = Load(bcx, dtor_ptr); Call(bcx, dtor, &[PointerCast(bcx, box_cell_v, Type::i8p(bcx.ccx()))], None); bcx
Change:
Hi guys! Is there any reasons, why () can't be cloned? It is the only non-clonable part of , which makes the entire struct non-clonable either.
Looks like an oversight. CC
Hey! If this is confirmed as oversight, can I add trait to FileType and address this issue? Or should this be addressed as part of
Go for it! isn't something that'll be fixed in one commit, it's an ongoing effort.

Discussion:
} /// Different kinds of files which can be identified by a call to stat <del> #[deriving(PartialEq, Show, Hash)] </del> <ins> #[deriving(PartialEq, Show, Hash, Clone)] </ins> pub enum FileType { /// This is a normal file, corresponding to `S_IFREG` TypeFile,

<ins> // Copyright 2014 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::io::FileType; pub fn main() { let _ = FileType::TypeFile.clone(); } </ins>
Change:
As titled. Currently Box does not implement Deref: But Box should be able to implement Deref.
(Tagged E-easy in the hope that it's as simple as adding the impls gives in the issue. There is the chance that there is some compiler peculiarities that make this not-easy.)
has kindly volunteered to mentor; catch him here or as on IRC.
Can I have a go at this? Looks easy enough...
it's already been done/attempted in . :smile:
Oh well, never mind, I must've overlooked the cross-ref...
This issue seems resolved due to close and merge.
unfortunately it wasn't merged.

Discussion:
use core::raw::TraitObject; use core::result::Result; use core::result::Result::{Ok, Err}; <ins> use core::ops::{Deref, DerefMut}; </ins> /// A value that represents the global exchange heap. This is the default /// place that the `box` keyword allocates into when no place is supplied.

} } <ins> impl<Sized? T> Deref<T> for Box<T> { fn deref(&self) -> &T { &**self } } impl<Sized? T> DerefMut<T> for Box<T> { fn deref_mut(&mut self) -> &mut T { &mut **self } } </ins> #[cfg(test)] mod test { #[test]

let s = format!("{}", b); assert_eq!(s, "&Any"); } <ins> #[test] fn deref() { fn homura<T: Deref<i32>>(_: T) { } homura(box 765i32); } </ins> }
Change:
From time to time the LLDB test suite hangs on the build bots, which leads to the whole pipeline being blocked for an hour. One way to make this problem a bit less severe is to add a time-out to the LLDB test runner which just kills tests that take longer than a few seconds. This should at least reduce the time until the tests can be restarted. cc
cc

Discussion:
CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS) CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS) CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS) <del> CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) </del> <ins> CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS)  $(S)src/etc/lldb_batchmode.py  $(S)src/etc/lldb_rust_formatters.py </ins> CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS) endef

import os import sys import threading <ins> import thread </ins> import re import atexit <ins> import time </ins> # Set this to True for additional output DEBUG_OUTPUT = False

target.GetBroadcaster().AddListener(listener, lldb.SBTarget.eBroadcastBitBreakpointChanged) <ins> def start_watchdog(): "Starts a watchdog thread that will terminate the process after a certain period of time" watchdog_start_time = time.clock() watchdog_max_time = watchdog_start_time + 30 def watchdog(): while time.clock() < watchdog_max_time: time.sleep(1) print("TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!") thread.interrupt_main() # Start the listener and let it run as a daemon watchdog_thread = threading.Thread(target = watchdog) watchdog_thread.daemon = True watchdog_thread.start() </ins> #################################################################################################### # ~main ####################################################################################################

print("Target executable is '%s'." % target_path) print("Current working directory is '%s'" % os.getcwd()) <ins> # Start the timeout watchdog start_watchdog() </ins> # Create a new debugger instance debugger = lldb.SBDebugger.Create()

for line in script_file: command = line.strip() <ins> if command == "run" or command == "r" or re.match("^processs+launch.*", command): # Before starting to run the program, let the thread sleep a bit, so all # breakpoint added events can be processed time.sleep(0.5) </ins> if command != '': execute_command(command_interpreter, command)