jiebi/CodeConvo huggingface dataset:
Change:
Hi, first time contributor here. This might be a bug. I think every factor mentioned in the title is required to trigger this. (I'm trying to do horrible things to the runtime, but I don't think this is significant here.) Source: Backtrace (rustc 0.13.0-nightly ( 2015-01-04 00:50:59 +0000) installed via rustup on Ubuntu LTS):
This happened to me as well, with an almost identical program. More info:
Following the backtrace, it looks like assumes that the 'ownedbox' lang item is always defined and calls unwrap(), triggering the panic.
Triage: still ICEs:

Discussion:
} ty::TyBox(_) => { // treat like we would treat `Box` <del> let def_id = tcx.lang_items.owned_box().unwrap(); Some(StructSimplifiedType(def_id)) </del> <ins> match tcx.lang_items.require_owned_box() { Ok(def_id) => Some(StructSimplifiedType(def_id)), Err(msg) => tcx.sess.fatal(&msg), } </ins> } ty::TyClosure(def_id, _) => { Some(ClosureSimplifiedType(def_id))

} } <ins> pub fn require_owned_box(&self) -> Result<ast::DefId, String> { self.require(OwnedBoxLangItem) } </ins> pub fn from_builtin_kind(&self, bound: ty::BuiltinBound) -> Result<ast::DefId, String> {

self.check_def_id(item, data.principal_def_id()); } ty::TyBox(..) => { <del> self.check_def_id(item, self.tcx.lang_items.owned_box().unwrap()); </del> <ins> match self.tcx.lang_items.require_owned_box() { Ok(trait_id) => self.check_def_id(item, trait_id), Err(msg) => self.tcx.sess.span_fatal(item.span, &msg), } </ins> } ty::TyChar => { self.check_primitive_impl(def_id,

<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 don't ICE when we are missing the owned_box lang item. // error-pattern: requires `owned_box` lang_item #![no_std] #![feature(lang_items, no_std, box_syntax)] extern crate core; fn main() { let x = box 1i32; } #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } </ins>
Change:
Macro definitions encoded to the metadata do not preserve the identifier style, thus certain paths break down.
Nice catch. I was afraid something like this would happen... Really a bug in pretty printing, as it doesn't preserve the ident style. This is what we get for hacking contextual lexer information into the token stream...
The original example now compiles fine, but then I'm not sure about tomaka/android-rs-glue. is this issue still relevant?
I didn't test myself, but reported that it's fixed.
Yeah it looks like this has been fixed, yay!

Discussion:
pub fn print_tts(&mut self, tts: &[ast::TokenTree]) -> IoResult<()> { try!(self.ibox(0)); <ins> let mut suppress_space = false; </ins> for (i, tt) in tts.iter().enumerate() { <del> if i != 0 { </del> <ins> if i != 0 && !suppress_space { </ins> try!(space(&mut self.s)); } try!(self.print_tt(tt)); <ins> // There should be no space between the module name and the following `::` in paths, // otherwise imported macros get re-parsed from crate metadata incorrectly (#20701) suppress_space = match tt { &ast::TtToken(_, token::Ident(_, token::ModName)) | &ast::TtToken(_, token::MatchNt(_, _, _, token::ModName)) | &ast::TtToken(_, token::SubstNt(_, token::ModName)) => true, _ => false } </ins> } self.end() }

<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. #![crate_type = "lib"] #[macro_export] macro_rules! declare { () => ( pub fn aaa() {} pub mod bbb { use super::aaa; pub fn ccc() { aaa(); } } ) } </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. // aux-build:macro_with_super_1.rs #[macro_use] extern crate macro_with_super_1; declare!(); fn main() { bbb::ccc(); } </ins>
Change:
For example, the code snippet for with suspicious muffin-related content. This seems to be the snippet for the  function (which is also the first function on the page with example code). All other code snippets on the page lead to the same muffin code. This is on Chrome 39.0.2171.95 (64-bit) on Mac OS X 10.10.1. !
It looks like this is caused by rustdoc rendering all of the examples with the same id. If you look at the playpen js code in rustdoc: you see that it depends on all the same ids being different. However, if you look at the source of the StrExt example you linked, you see they all have "rust-example-rendered-0" as the id. I think the error comes from somewhere in here, but it's not obvious to me how to fix it. I'll look into the issue, but this is my first little bit of work on rust so it may take a second/I'd appreciate insight as to what the problem might be.
nominating for I-muffins

Discussion:
use libc; use std::ascii::AsciiExt; use std::ffi::CString; <del> use std::cell::{RefCell, Cell}; </del> <ins> use std::cell::RefCell; </ins> use std::collections::HashMap; use std::fmt; use std::slice;

thread_local!(static USED_HEADER_MAP: RefCell<HashMap<String, uint>> = { RefCell::new(HashMap::new()) }); <del> thread_local!(static TEST_IDX: Cell<uint> = Cell::new(0)); </del> thread_local!(pub static PLAYGROUND_KRATE: RefCell<Option<Option<String>>> = { RefCell::new(None)

if rendered { return } PLAYGROUND_KRATE.with(|krate| { let mut s = String::new(); <del> let id = krate.borrow().as_ref().map(|krate| { let idx = TEST_IDX.with(|slot| { let i = slot.get(); slot.set(i + 1); i }); </del> <ins> krate.borrow().as_ref().map(|krate| { </ins> let test = origtext.lines().map(|l| { stripped_filtered_line(l).unwrap_or(l) }).collect::<Vec<&str>>().connect("n"); let krate = krate.as_ref().map(|s| s.as_slice()); let test = test::maketest(test.as_slice(), krate, false, false); <del> s.push_str(format!("<span id='rust-example-raw-{}'  class='rusttest'>{}</span>", idx, Escape(test.as_slice())).as_slice()); format!("rust-example-rendered-{}", idx) </del> <ins> s.push_str(format!("<span class='rusttest'>{}</span>", Escape(test.as_slice())).as_slice()); </ins> }); <del> let id = id.as_ref().map(|a| a.as_slice()); s.push_str(highlight::highlight(text.as_slice(), None, id) .as_slice()); </del> <ins> s.push_str(highlight::highlight(text.as_slice(), None, Some("rust-example-rendered")) .as_slice()); </ins> let output = CString::from_vec(s.into_bytes()); hoedown_buffer_puts(ob, output.as_ptr()); })

/// previous state (if any). pub fn reset_headers() { USED_HEADER_MAP.with(|s| s.borrow_mut().clear()); <del> TEST_IDX.with(|s| s.set(0)); </del> } impl<'a> fmt::String for Markdown<'a> {

(function() { if (window.playgroundUrl) { $('pre.rust').hover(function() { <del> if (!$(this).attr('id')) { return; } var id = '#' + $(this).attr('id').replace('rendered', 'raw'); </del> var a = $('<a>').text('⇱').attr('class', 'test-arrow'); <del> var code = $(id).text(); </del> <ins> var code = $(this).siblings(".rusttest").text(); </ins> a.attr('href', window.playgroundUrl + '?code=' + encodeURIComponent(code)); a.attr('target', '_blank');
Change:
This fails to compile:
probably related, this: fails to compile with: error: binary operation cannot be applied to type this used to compile but not sure if it's a bug or the syntax has changed
This works: It should be the intended behavior.
thanks!
This now works after Niko's refactoring work. (Adding needstest, since I can't find a test that tests this exactly, although I wasn't looking very hard.)

Discussion:
<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. use std::ops::Add; fn foo<T>(x: T) -> <i32 as Add<T>>::Output where i32: Add<T> { 42i32 + x } fn main() { println!("{}", foo(0i32)); } </ins>
Change:
With a file like: And then running , these warnings are inserted: cc
I believe was working on this.
Nominating though, when we deny warnings in beta I've gotta be able to test my code still!
I've been using , and this blocks me from testing. For now, I have to comment out that line...

Discussion:
let item_ = ast::ItemMod(testmod); let mod_ident = token::gensym_ident("__test"); <ins> let allow_unstable = { let unstable = P(nospan(ast::MetaWord(InternedString::new("unstable")))); let allow = P(nospan(ast::MetaList(InternedString::new("allow"), vec![unstable]))); attr::mk_attr_inner(attr::mk_attr_id(), allow) }; </ins> let item = ast::Item { ident: mod_ident, <del> attrs: Vec::new(), </del> id: ast::DUMMY_NODE_ID, node: item_, vis: ast::Public, span: DUMMY_SP, <ins> attrs: vec![allow_unstable], </ins> }; let reexport = cx.reexport_test_harness_main.as_ref().map(|s| { // building `use <ident> = __test::main`

<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. // compile-flags: --test #![deny(unstable)] #[test] fn foo() {} </ins>
Change:
Example (reduced by from something reported on IRC):
Is that allowed syntax? As RFC 195 states . I tried to express something like but thought I have to wait until where clauses on associated type definitions land.
Nevermind, got it. Only is not in scope for the trait header, but is a path to it, so it is valid syntax. Keep up your excellent work :)
The code snippet above now causes the following error: Changing the trait to: yields
I'd like to nominate this, I don't think we can remove oldimplcheck without it.
This currently reports . The cycle can be broken by explicit UFCS notation:

Discussion:
<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 trait Subscriber { type Input; } pub trait Processor: Subscriber<Input = Self::Input> { //~^ ERROR unsupported cyclic reference between types/traits detected [E0391] type Input; } 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. pub trait Subscriber { type Input; } pub trait Processor: Subscriber<Input = <Self as Processor>::Input> { type Input; } fn main() {} </ins>
Change:
Found another bug in the compiler: This is the output from :
Do you have an example of code that produces this crash?
I managed to reproduce the error in the Rust play-pen: I will copy the snippet here anyway:
A simpler repro:

Discussion:
pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> { match self.inh.node_types.borrow().get(&id) { Some(&t) => t, <ins> None if self.err_count_since_creation() != 0 => self.tcx().types.err, </ins> None => { self.tcx().sess.bug( &format!("no type for node {}: {} in fcx {}",

<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. // Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886 fn main() { "".homura[""]; //~ ERROR no field with that name was found } </ins>
Change:
The following program: dies with a false ambiguity report. The problem is that the builtin bound rules kick and identify that , but there is also a where-clause for that same thing. We should treat builtin-bounds expansions in the same was an explicit impl and resolve in favor of the where-clause.

Discussion:
.is_ok() }) } <ins> (&BuiltinCandidate(_), &ParamCandidate(_)) => { // If we have a where-clause like `Option<K> : Send`, // then we wind up in a situation where there is a // default rule (`Option<K>:Send if K:Send) and the // where-clause that both seem applicable. Just take // the where-clause in that case. true } </ins> (&ProjectionCandidate, &ParamCandidate(_)) => { // FIXME(#20297) -- this gives where clauses precedent // over projections. Really these are just two means

<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 do not error out because of a (False) ambiguity // between the builtin rules for Sized and the where clause. Issue // #20959. fn foo<K>(x: Option<K>) where Option<K> : Sized { let _y = x; } fn main() { foo(Some(22)); } </ins>
Change:
The distinguishes between and but makes no mention of a third type people will come across: . is defined as the type which you refer to? Perhaps define as the type and mention that in most cases it must be borrowed... This honestly threw me the first time I saw it. I thought, "what is 's only and ...". : Error:
Note: is an unsized type, and is simply a pointer to the unsized type (like or ). But I agree that the docs could be clearer.
The error messages can be quite unfriendly for new users. I recently saw someone attempt: The error: Doesn't mean much to a new user. What does that mean to users? Is there a valid reason to ever use in code? The doc says So it's not a valid type? But the error message you gave me said "for the type " ... If it's not valid why doesn't the compiler say so in the error message above, instead of complaining that it's unsized?
Today, this is the string chapter of the book.

Discussion:
Rust has two main types of strings: `&str` and `String`. <del> # &str </del> <ins> # `&str` </ins> The first kind is a `&str`. This is pronounced a 'string slice'. String literals are of the type `&str`:

means that they're a 'view' into an already-allocated string, such as a string literal or a `String`. <del> # String </del> <ins> ## `str` You may occasionally see references to a `str` type, without the `&`. While this type does exist, it’s not something you want to use yourself. Sometimes, people confuse `str` for `String`, and write this: ```rust struct S { s: str, } ``` This leads to ugly errors: ```text error: the trait `core::marker::Sized` is not implemented for the type `str` [E0277] note: `str` does not have a constant size known at compile-time ``` Instead, this `struct` should be ```rust struct S { s: String, } ``` So let’s talk about `String`s. # `String` </ins> A `String` is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. `String`s are commonly created by
Change:
I work on Windows 8.1 64-bit, rustc version: BTW, the same ICE occurred for my but it did not print backtrace with and I don't know why.

Discussion:
use ast; use ast::{TokenTree, Ident}; use ast::{TtDelimited, TtSequence, TtToken}; <del> use codemap::{BytePos, mk_sp}; </del> <ins> use codemap::{BytePos, mk_sp, Span}; </ins> use codemap; use parse::lexer::*; //resolve bug? use parse::ParseSess;

let mut ei = bb_eis.pop().unwrap(); match ei.top_elts.get_tt(ei.idx) { <del> TtToken(_, MatchNt(_, name, _, _)) => { </del> <ins> TtToken(span, MatchNt(_, name, _, _)) => { </ins> let name_string = token::get_ident(name); let match_cur = ei.match_cur; (&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal( <del> parse_nt(&mut rust_parser, name_string.get())))); </del> <ins> parse_nt(&mut rust_parser, span, name_string.get())))); </ins> ei.idx += 1us; ei.match_cur += 1; }

} } <del> pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { </del> <ins> pub fn parse_nt(p: &mut Parser, sp: Span, name: &str) -> Nonterminal { </ins> match name { "tt" => { p.quote_depth += 1us; //but in theory, non-quoted tts might be useful

} "meta" => token::NtMeta(p.parse_meta_item()), _ => { <del> p.fatal(&format!("unsupported builtin nonterminal parser: {}", name)[]) </del> <ins> p.span_fatal_help(sp, &format!("invalid fragment specifier `{}`", name)[], "valid fragment specifiers are `ident`, `block`,  `stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`  and `item`") </ins> } } }

// harmless Ok(true) }, <del> _ => Err(format!("unrecognized builtin nonterminal `{}`", frag)) </del> <ins> _ => Err(format!("invalid fragment specifier `{}`", frag)) </ins> } } }

// except according to those terms. macro_rules! test { ($wrong:t_ty ..) => () } <del> //~^ ERROR: unrecognized builtin nonterminal `t_ty` </del> <ins> //~^ ERROR: invalid fragment specifier `t_ty` </ins> fn main() {}
Change:
Testcase: : : Output: Should output, instead, the parse errors from . Probably misplacing the diagnostic emitter somehow, when creating the nested parser for the included source, and doesn't have an .
(I suspect this is an easy fix, but am not quite sure)

Discussion:
fn make_items(mut self: Box<ExpandResult<'a>>) -> Option<SmallVector<P<ast::Item>>> { let mut ret = SmallVector::zero(); <del> loop { </del> <ins> while self.p.token != token::Eof { </ins> match self.p.parse_item_with_outer_attributes() { Some(item) => ret.push(item), <del> None => break </del> <ins> None => self.p.span_fatal( self.p.span, &format!("expected item, found `{}`", self.p.this_token_to_string())[] ) </ins> } } Some(ret)

<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. // include file for issue-21146.rs parse_error </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: expected item, found `parse_error` include!("../auxiliary/issue-21146-inc.rs"); fn main() {} </ins>
Change:
This seems like an obvious use case for operator overloading. Probably export them from core by default.
What operators did you have in mind? Things like for ?
yes, and
Not going to work right now, because operators can't be unsafe. Not sure how to change that either. Going to close for now.
At least for , the operator could be "safe" with an unsafe block inside of it. You aren't going to have problems if you do pointer arithmetic until you dereference it, which would be unsafe anyway. In other words, if is safe (which is is), then it seems like pointer arithmetic is also safe.
Yeah, that's true. We consider arithmetic safe, but indexing and dereferencing unsafe. Just having would be convenient.
I'm going to try on work on this. I'll add overloaded and . I'll use as dbaupp suggested on IRC so that it will work with any primitive integer type.
Looks like and for unsafe pointers, can this be closed?

Discussion:
use sys; use unstable::intrinsics; use util::swap; <ins> use ops::{Add,Sub}; use num::Int; </ins> #[cfg(not(test))] use cmp::{Eq, Ord}; use uint;

} } <ins> #[cfg(not(test))] impl<T, I: Int> Add<I, *T> for *T { /// Add an integer value to a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] pub fn add(&self, rhs: &I) -> *T { self.offset(rhs.to_int() as uint) } } #[cfg(not(test))] impl<T, I: Int> Sub<I, *T> for *T { /// Subtract an integer value from a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] pub fn sub(&self, rhs: &I) -> *T { self.offset(-rhs.to_int() as uint) } } #[cfg(not(test))] impl<T, I: Int> Add<I, *mut T> for *mut T { /// Add an integer value to a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] pub fn add(&self, rhs: &I) -> *mut T { self.offset(rhs.to_int() as uint) } } #[cfg(not(test))] impl<T, I: Int> Sub<I, *mut T> for *mut T { /// Subtract an integer value from a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] pub fn sub(&self, rhs: &I) -> *mut T { self.offset(-rhs.to_int() as uint) } } </ins> #[cfg(test)] pub mod ptr_tests { use super::*;

} #[test] <ins> fn test_ptr_addition() { use vec::raw::*; unsafe { let xs = ~[5, ..16]; let mut ptr = to_ptr(xs); let end = ptr + 16; while ptr < end { assert_eq!(*ptr, 5); ptr = ptr + 1u; } let mut xs_mut = xs.clone(); let mut m_ptr = to_mut_ptr(xs_mut); let m_end = m_ptr + 16i16; while m_ptr < m_end { *m_ptr += 5; m_ptr = m_ptr + 1u8; } assert_eq!(xs_mut, ~[10, ..16]); } } #[test] fn test_ptr_subtraction() { use vec::raw::*; unsafe { let xs = ~[0,1,2,3,4,5,6,7,8,9]; let mut idx = 9i8; let ptr = to_ptr(xs); while idx >= 0i8 { assert_eq!(*(ptr + idx), idx as int); idx = idx - 1i8; } let mut xs_mut = xs.clone(); let mut m_start = to_mut_ptr(xs_mut); let mut m_ptr = m_start + 9u32; while m_ptr >= m_start { *m_ptr += *m_ptr; m_ptr = m_ptr - 1i8; } assert_eq!(xs_mut, ~[0,2,4,6,8,10,12,14,16,18]); } } #[test] </ins> fn test_ptr_array_each_with_len() { unsafe { let one = ~"oneOne";