jiebi/CodeConvo huggingface dataset:
Change:
In particular, . We can't use because it's in a const context.
whoops, on it
Please reopen.
hmm... that's a different issue. this looks like your new constant code

Discussion:
Float(f) => cast_const_float(tcx, f, ty), Char(c) => cast_const_int(tcx, Infer(c as u64), ty), Function(_) => Err(UnimplementedConstVal("casting fn pointers")), <ins> ByteStr(_) => match ty.sty { ty::TyRawPtr(_) => { Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr")) }, _ => Err(CannotCast), }, </ins> _ => Err(CannotCast), } }

#![deny(const_err)] <ins> const X: *const u8 = b"" as _; </ins> fn main() { let _ = ((-1 as i8) << 8 - 1) as f32;
Change:
Testcase currently relying on the most recent ncollide and nphysics3d from When I get some time later today I'll try to reduce it more. Code: Error:
I investigated this further and ended up with the following test case independent from ncollide/nphysics. It causes an ICE on both beta (rustc 1.9.0-beta.2 ( 2016-05-04)) and nigthly (rustc 1.10.0-nightly ( 2016-04-28))( and compiles fine on stable. The ICE will appear with and without . This might be related to . I can try to compile this on master but it will take some time before I can download the repo and compile rustc manually. This will compile fine, without any ICE if we do at least one of the following: Implement the method explicitly on :Remove the associated type in the impl, i.e., replace with (or anything else, including itself instead of ). Remove the cast to a trait-object at the end of the .
Fixed by .

Discussion:
let method_item = tcx.impl_or_trait_item(def_id); let trait_id = method_item.container().id(); let trait_ref = ty::Binder(substs.to_trait_ref(tcx, trait_id)); <ins> let trait_ref = infer::normalize_associated_type(tcx, &trait_ref); </ins> match common::fulfill_obligation(ccx, DUMMY_SP, trait_ref) { traits::VtableImpl(vtable_impl) => { let impl_did = vtable_impl.impl_def_id;

<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. use std::marker::PhantomData; struct TheType<T> { t: PhantomData<T> } pub trait TheTrait { type TheAssociatedType; } impl TheTrait for () { type TheAssociatedType = (); } pub trait Shape<P: TheTrait> { fn doit(&self) { } } impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> { } fn main() { let ball = TheType { t: PhantomData }; let handle: &Shape<()> = &ball; } </ins>
Change:
Testcase currently relying on the most recent ncollide and nphysics3d from When I get some time later today I'll try to reduce it more. Code: Error:
I investigated this further and ended up with the following test case independent from ncollide/nphysics. It causes an ICE on both beta (rustc 1.9.0-beta.2 ( 2016-05-04)) and nigthly (rustc 1.10.0-nightly ( 2016-04-28))( and compiles fine on stable. The ICE will appear with and without . This might be related to . I can try to compile this on master but it will take some time before I can download the repo and compile rustc manually. This will compile fine, without any ICE if we do at least one of the following: Implement the method explicitly on :Remove the associated type in the impl, i.e., replace with (or anything else, including itself instead of ). Remove the cast to a trait-object at the end of the .
Fixed by .

Discussion:
# An optional number to put after the label, e.g. '.2' -> '-beta.2' # NB Make sure it starts with a dot to conform to semver pre-release # versions (section 9) <del> CFG_PRERELEASE_VERSION=.2 </del> <ins> CFG_PRERELEASE_VERSION=.3 </ins> # Append a version-dependent hash to each library, so we can install different # versions in the same place

let method_item = tcx.impl_or_trait_item(def_id); let trait_id = method_item.container().id(); let trait_ref = ty::Binder(substs.to_trait_ref(tcx, trait_id)); <ins> let trait_ref = infer::normalize_associated_type(tcx, &trait_ref); </ins> match common::fulfill_obligation(ccx, DUMMY_SP, trait_ref) { traits::VtableImpl(vtable_impl) => { let impl_did = vtable_impl.impl_def_id;

<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. use std::marker::PhantomData; struct TheType<T> { t: PhantomData<T> } pub trait TheTrait { type TheAssociatedType; } impl TheTrait for () { type TheAssociatedType = (); } pub trait Shape<P: TheTrait> { fn doit(&self) { } } impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> { } fn main() { let ball = TheType { t: PhantomData }; let handle: &Shape<()> = &ball; } </ins>
Change:
an arbitrary import of the shape will give the following errors and spans: The span is always as long as the crate, but starts at the imported element This can also be used to create an unprintable span:

Discussion:
use syntax::ast::{self, FloatTy}; use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, IntTy, UintTy}; <del> use syntax::codemap::{self, Span, Pos}; </del> <ins> use syntax::codemap::{self, Span}; </ins> use syntax::errors::DiagnosticBuilder; use syntax::parse::token::{self, keywords}; use syntax::util::lev_distance::find_best_match_for_name;

Failed(None) => { let segment_name = name.as_str(); let module_name = module_to_string(search_module); <del> let mut span = span; </del> let msg = if "???" == &module_name { <del> span.hi = span.lo + Pos::from_usize(segment_name.len()); </del> match search_parent_externals(name, &self.current_module) { Some(module) => { let path_str = names_to_string(module_path);

<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. // Make sure that the spans of import errors are correct. use abc::one_el; //~^ ERROR 13:5: 13:16 use abc::{a, bbb, cccccc}; //~^ ERROR 15:11: 15:12 //~^^ ERROR 15:14: 15:17 //~^^^ ERROR 15:19: 15:25 use a_very_long_name::{el, el2}; //~^ ERROR 19:24: 19:26 //~^^ ERROR 19:28: 19:31 fn main() {} </ins>
Change:
Commit the bound to the function in the trait (). This bound doesn't seem necessary (it compiles fine without it), but it prevents using this method from a trait object. Is there any reason for its addition? If not, could we remove it?
That must be a leftover from me trying to make take a closure somehow work.. sorry.
I'm marking this as E-easy because all that needs to be done is to remove from [here], I believe. [here]:
I would like to take this issue.
Go ahead! Let us know what we can do to help you. You can reach out either here or on IRC ( on ).

Discussion:
} impl<'a> StringReader<'a> { <del> fn next_token(&mut self) -> TokenAndSpan where Self: Sized { </del> <ins> fn next_token(&mut self) -> TokenAndSpan { </ins> let res = self.try_next_token(); self.unwrap_or_abort(res) }
Change:
Right now rustbuild invokes cargo which wants to rebuild the world if it sees a different value, while my workflow involves changing just to test stage1+ with . It would be nice to have passing to the python script (or the environment variable `RUSTFLAGS1="-Z orbit") just work. Currently the Makefiles have something similar but it doesn't actually work for , just .
Did rustbuild ever get support for this? This appears to also be breaking builds that need to pass per-stage values.
I'm going to unassign from this; I think others should be able to implement this and as far as I know they don't have any particular concern with this specific bug.
We support this via and set in the environment today.
I wonder if we should switch to and .
That would make sense, I'll reopen to track that.

Discussion:
stage = compiler.stage; } <del> let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default(); </del> <ins> let mut extra_args = String::new(); </ins> if stage != 0 { <del> let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default(); if !extra_args.is_empty() { extra_args.push_str(" "); } </del> <ins> let s = env::var("RUSTFLAGS_NOT_BOOTSTRAP").unwrap_or_default(); extra_args.push_str(&s); } else { let s = env::var("RUSTFLAGS_BOOTSTRAP").unwrap_or_default(); </ins> extra_args.push_str(&s); }
Change:
Today, the HashMap docs say: While this is accurate, it's burying the lede: we should say much more clearly what the tradeoffs are, and point more directly toward the custom hashing infrastructure. E.g.:
part of
I would be happy to work with anyone who wants to work on this issue.
is relevant to this bug -- now the docs should say that Rust uses a slow hash function by default "for DoS protection", but does not actually provide DoS protection.
I'd like to take a crack at this issue with your help. I won't be able to work on it today but I could tomorrow.
great! Can you swing by IRC tomorrow? That'd be easiest
The docs IRC channel correct? I'll swing by around 7pm EST maybe even slightly earlier On Wed, Aug 3, 2016, 17:17 Steve Klabnik wrote:
Yeah, any of them. That's a little late for me, but I'm sure that one of us can be helpful :smile: (And I'm also happy to do it asynchronously through this issue too, just sometimes real-time is a bit easier.)
I'll pop in around that time and if you're around great if not I'll point the channel to this issue to ask for help if I need it. I could pop on during work lunch break tomorrow and at least get a starting point from you if that works as well. Steve Klabnik wrote:

Discussion:
/// A hash map implementation which uses linear probing with Robin /// Hood bucket stealing. /// <del> /// The hashes are all keyed by the thread-local random number generator /// on creation by default. This means that the ordering of the keys is /// randomized, but makes the tables more resistant to /// denial-of-service attacks (Hash DoS). No guarantees are made to the /// quality of the random data. The implementation uses the best available /// random data from your platform at the time of creation. This behavior /// can be overridden with one of the constructors. </del> <ins> /// By default, HashMap uses a somewhat slow hashing algorithm which can provide resistance /// to DoS attacks. Rust makes a best attempt at acquiring random numbers without IO /// blocking from your system. Because of this HashMap is not guaranteed to provide /// DoS resistance since the numbers generated might not be truly random. If you do /// require this behavior you can create your own hashing function using /// [BuildHasherDefault](../hash/struct.BuildHasherDefault.html). </ins> /// /// It is required that the keys implement the `Eq` and `Hash` traits, although /// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
Change:
It would be nice if the and implementations for were inlined. Consider this program: If the calls are inlined, then all the position computations are constant-folded and the writes compile to exactly what I'd hope for: I tested using , using rustc 1.10.0-nightly ( 2016-05-09). I think that LTO is a pretty close approximation here to the effect that would have, but I guess that assumption needs testing. (By the way: oddly, at opt-level=3 I got worse code.) Without LTO, I get about 84 instructions for this sequence, counting the ones in as well as the implementation of itself. That said, the implementation for is more complicated and maybe shouldn't be inlined. But I think this request at least applies to the implementations for and , and probably to the implementation for . Does this sound sensible?
The generic ones should in theory already be inlined due to the generics themselves, but feel free to send a PR to inline some of the others!
I didn't understand what you meant by "The generic ones should in theory already be inlined", but I guessed you meant the implementation since it's for ? So I tested that and discovered that sometimes optimizers are kind of hilariously good: The body of compiled (with ) down to: (where 5243 is the address of the unwind call). I'm a little surprised LLVM didn't constant-fold the comparison and reduce the whole thing to a single , but still, I'm impressed. So anyway I've submitted a pull request that only inlines for two of the three implementations for Cursors, and doesn't change since it apparently doesn't need it.
The PR was merged, but bors didn't close this issue.

Discussion:
#[stable(feature = "rust1", since = "1.0.0")] impl<'a> Write for Cursor<&'a mut [u8]> { <ins> #[inline] </ins> fn write(&mut self, data: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(data)?;

#[stable(feature = "cursor_box_slice", since = "1.5.0")] impl Write for Cursor<Box<[u8]>> { <ins> #[inline] </ins> fn write(&mut self, buf: &[u8]) -> io::Result<usize> { let pos = cmp::min(self.pos, self.inner.len() as u64); let amt = (&mut self.inner[(pos as usize)..]).write(buf)?;
Change:
no longer compiles on nightly due to what I think is a regression in macro hygiene: Here we have methods on a trait that are defined by hand, but implemented by macro. The function names are not generated by the macro - they're passed in, so I would not expect any hygiene shenanigans to apply. Possibly ? cc
Thanks for the report! I fixed this in -- it was caused by .

Discussion:
}; let item = match item { <del> ast::ItemKind::Impl(u, o, a, b, c, items) => { let items = items.into_iter().filter_map(|item| self.configure(item)).collect(); ast::ItemKind::Impl(u, o, a, b, c, items) } ast::ItemKind::Trait(u, a, b, items) => { let items = items.into_iter().filter_map(|item| self.configure(item)).collect(); ast::ItemKind::Trait(u, a, b, items) } </del> ast::ItemKind::Struct(def, generics) => { ast::ItemKind::Struct(fold_struct(self, def), generics) }

} fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> { <del> self.configure(item).map(|item| SmallVector::one(item.map(|i| self.fold_item_simple(i)))) </del> <ins> self.configure(item).map(|item| fold::noop_fold_item(item, self)) .unwrap_or(SmallVector::zero()) } fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVector<ast::ImplItem> { self.configure(item).map(|item| fold::noop_fold_impl_item(item, self)) .unwrap_or(SmallVector::zero()) } fn fold_trait_item(&mut self, item: ast::TraitItem) -> SmallVector<ast::TraitItem> { self.configure(item).map(|item| fold::noop_fold_trait_item(item, self)) </ins> .unwrap_or(SmallVector::zero()) } }

<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. #![feature(rustc_attrs)] macro_rules! m { () => { #[cfg(any())] fn f() {} } } trait T {} impl T for () { m!(); } #[rustc_error] fn main() {} //~ ERROR compilation successful </ins>
Change:
I have a small project that I've been learning rust with. Just now I've some code and the next time I run rustc exits with SIGSEV signal 11. I've previously not run into this issue while working on this project. Minimal Reproducible Code: I'm working on Mac (OSX 10.11.5), with rust installed through Homebrew Cargo & Rust Version: Details on homebrew install:
I played around with the code to make it actually more minimal, as well as pointing to the line which introduces the error during compilation
This seems to have been fixed on nightly ().
According to a quick git-bisect, contained the commit that fixed this.

Discussion:
<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. #![allow(dead_code)] struct A { a: &'static (), } static B: &'static A = &A { a: &() }; static C: &'static A = &B; //~^ ERROR cannot refer to other statics by value fn main() {} </ins>
Change:
Consider this code: which fails like this: Result::unwrap()Err The error occurs on the last line by the way. If you write , it works just fine (no panic). If i remember correctly, this worked on Linux, so it should be an os specific issue. Of course you can just use an ip for the source address, but this kind of error shouldn't occur nevertheless right? OS: Windows 7 Professional 64bit : rustc 1.9.0 ( 2016-05-18) binary: rustc commit-hash: commit-date: 2016-05-18 host: x8664-pc-windows-msvc release: 1.9.0 Backtrace:
Repo on Windows 10. Seems to crash on OS X as well. The is resolved to the IPv6 address and then the IPv4 address , and UdpSocket will only bind to the first address if successful. So the UDP socket is bound to an IPv6 address, and can only send data to IPv6 hosts. Meanwhile, is first resolved to the IPv4 address and then the IPv6 one (if the OS supports that). just send the data to the first address, regardless of if the result is Ok or Err. The is due to sending data from IPv6 socket to IPv4 host. So there are two problems shown from this issue: should use , or at least filter the address family? to have some way to prioritize IPv4 address for when using ToSocketAddrs. (IPv6 support is not good on internet, even if sendto picked it could still fail with )
diagnosis sounds like it'd do it. We can probably figure out the local address type by calling and inspecting it, and then we should probably just filter the addresses returned to only those of the same kind.

Discussion:
/// /// Address type can be any implementor of `ToSocketAddrs` trait. See its /// documentation for concrete examples. <ins> /// This will return an error when the IP version of the local socket /// does not match that returned from `ToSocketAddrs` /// See https://github.com/rust-lang/rust/issues/34202 for more details. </ins> #[stable(feature = "rust1", since = "1.0.0")] pub fn send_to<A: ToSocketAddrs>(&self, buf: &[u8], addr: A) -> io::Result<usize> {
Change:
attempts to derive in an invalid situation, and is rewarded with a barrage of duplicate errors: The error only appears once. However, the error (along with note ... gee, really?) appears eight times, four for and four for . I assume this is because an error is generated at several points within the (invisible) generated implementation. But since they are all assigned the same span, maybe we can deduplicate.
Would the following be possible?: bound failure error true for the further compilation It doesn't address all cases, but it would significantly improve this one.
Should this be a UI or compile-fail test? I think cfail is out of favor these days, but a UI test will have to include a bug:
It should be a UI test, I'd say and we should fix that bug

Discussion:
<ins> #[derive(PartialEq)] struct Comparable; #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); fn main() {} </ins>

<ins> error[E0277]: can't compare `Comparable` with `Comparable` --> $DIR/issue-34229.rs:2:46 | LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); |                                              ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` | = help: the trait `std::cmp::PartialOrd` is not implemented for `Comparable` = note: required by `std::cmp::PartialOrd::partial_cmp` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>
Change:
fails with: Note that there is no directory in Creating that directory fixes this problem but leads to another problem: This is because there is no directory in , which the tool tries to (checked with ). Creating that directory fixes the problem. Note that for stage 2, all directories starting at needed to be created.
Oh dear yeah this isn't tested very well so I wouldn't be surprised if it breaks every now and then, thanks for the report!
oops
Yeah, I expected that (the not very well tested) so when I needed to build the compiler docs I decided to try using rust build by that. By the way, I'm a little confused by the following: The rustbuild configuration includes a key, which is also present in the struct as , however the field .
Oh there should probably be a line in which adds that target to a dependency of the target, probably just got lost along the way somewhere by accident :(

Discussion:
/// is largely just a wrapper around `cargo doc`. pub fn test(build: &Build, stage: u32, target: &str, out: &Path) { println!("Documenting stage{} test ({})", stage, target); <ins> t!(fs::create_dir_all(out)); </ins> let compiler = Compiler::new(stage, &build.config.build); let out_dir = build.stage_out(&compiler, Mode::Libtest) .join(target).join("doc");

/// dependencies. This is largely just a wrapper around `cargo doc`. pub fn rustc(build: &Build, stage: u32, target: &str, out: &Path) { println!("Documenting stage{} compiler ({})", stage, target); <ins> t!(fs::create_dir_all(out)); </ins> let compiler = Compiler::new(stage, &build.config.build); let out_dir = build.stage_out(&compiler, Mode::Librustc) .join(target).join("doc"); let rustdoc = build.rustdoc(&compiler); <del> if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) { </del> <ins> if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) && out_dir.exists() { </ins> t!(fs::remove_dir_all(&out_dir)); } let mut cargo = build.cargo(&compiler, Mode::Librustc, target, "doc");

vec![self.doc_test(stage)] } Source::Doc { stage } => { <del> vec![self.doc_book(stage), self.doc_nomicon(stage), self.doc_style(stage), self.doc_standalone(stage), self.doc_std(stage), self.doc_error_index(stage)] </del> <ins> let mut deps = vec![ self.doc_book(stage), self.doc_nomicon(stage), self.doc_style(stage), self.doc_standalone(stage), self.doc_std(stage), self.doc_error_index(stage), ]; if build.config.compiler_docs { deps.push(self.doc_rustc(stage)); } deps </ins> } Source::Check { stage, compiler } => { // Check is just a pseudo step which means check all targets,