diff --git a/AUTHORS.txt b/AUTHORS.txt index bc8dbc878baa3..896731f02515b 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -581,7 +581,7 @@ Robert Knight Robert Millar Robin Gloster Robin Stocker -Rohit Joshi +Rohit Joshi Roland Tanglao Rolf Timmermans Rolf van de Krol diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b3609e28a6a0..9f2bd6dc30c5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ please do two things: Pull requests will be treated as "review requests", and we will give feedback we expect to see corrected on -[style](https://github.com/rust-lang/rust/wiki/Note-style-guide) and +[style](http://aturon.github.io/) and substance before pulling. Changes contributed via pull request should focus on a single issue at a time, like any other. We will not accept pull-requests that try to "sneak" unrelated changes in. diff --git a/Makefile.in b/Makefile.in index a2394101f3a72..63c5742a540d4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -97,10 +97,9 @@ # make check-stage1-std RUST_TEST_TASKS=1 # # This is hardly all there is to know of The Rust Build System's -# mysteries. The tale continues on the wiki[1][2]. +# mysteries. The tale continues on the wiki[1]. # -# [1]: https://github.com/rust-lang/rust/wiki/Note-getting-started-developing-Rust -# [2]: https://github.com/rust-lang/rust/wiki/Note-testsuite +# [1]: https://github.com/rust-lang/rust/wiki/Note-testsuite # # If you really feel like getting your hands dirty, then: # diff --git a/README.md b/README.md index e858e91773b92..147d2e9d2f44a 100644 --- a/README.md +++ b/README.md @@ -58,16 +58,23 @@ documentation. ### Building on Windows -To easily build on windows we can use [MSYS2](http://sourceforge.net/projects/msys2/): +To easily build on windows we can use [MSYS2](http://msys2.github.io/): 1. Grab the latest MSYS2 installer and go through the installer. 2. Now from the MSYS2 terminal we want to install the mingw64 toolchain and the other tools we need. - $ pacman -S mingw-w64-i686-toolchain - $ pacman -S base-devel +```bash +# choose one based on platform +$ pacman -S mingw-w64-i686-toolchain +$ pacman -S mingw-w64-x86_64-toolchain -3. With that now start `mingw32_shell.bat` from where you installed MSYS2 (i.e. `C:\msys`). +$ pacman -S base-devel +``` + +3. With that now start `mingw32_shell.bat` or `mingw64_shell.bat` + from where you installed MSYS2 (i.e. `C:\msys`). Which one you + choose depends on if you want 32 or 64 bit Rust. 4. From there just navigate to where you have Rust's source code, configure and build it: $ ./configure diff --git a/mk/cfg/aarch64-apple-ios.mk b/mk/cfg/aarch64-apple-ios.mk index cbd889669ab22..0219ab960579b 100644 --- a/mk/cfg/aarch64-apple-ios.mk +++ b/mk/cfg/aarch64-apple-ios.mk @@ -11,7 +11,7 @@ AR_aarch64-apple-ios = $(shell xcrun -find -sdk iphoneos ar) endif CFG_LIB_NAME_aarch64-apple-ios = lib$(1).a CFG_LIB_GLOB_aarch64-apple-ios = lib$(1)-*.a -CFG_LIB_SKIP_INSTALL_aarch64-apple-ios = 1 #lib$(1)-*.a +CFG_INSTALL_ONLY_RLIB_aarch64-apple-ios = 1 CFG_STATIC_LIB_NAME_aarch64-apple-ios=lib$(1).a CFG_LIB_DSYM_GLOB_aarch64-apple-ios = lib$(1)-*.a.dSYM CFG_CFLAGS_aarch64-apple-ios := $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios) diff --git a/mk/cfg/armv7-apple-ios.mk b/mk/cfg/armv7-apple-ios.mk index 23686c41f2b19..aee4e64addfc1 100644 --- a/mk/cfg/armv7-apple-ios.mk +++ b/mk/cfg/armv7-apple-ios.mk @@ -11,7 +11,7 @@ AR_armv7-apple-ios = $(shell xcrun -find -sdk iphoneos ar) endif CFG_LIB_NAME_armv7-apple-ios = lib$(1).a CFG_LIB_GLOB_armv7-apple-ios = lib$(1)-*.a -CFG_LIB_SKIP_INSTALL_armv7-apple-ios = 1 #lib$(1)-*.a +CFG_INSTALL_ONLY_RLIB_armv7-apple-ios = 1 CFG_STATIC_LIB_NAME_armv7-apple-ios=lib$(1).a CFG_LIB_DSYM_GLOB_armv7-apple-ios = lib$(1)-*.a.dSYM CFG_JEMALLOC_CFLAGS_armv7-apple-ios := -arch armv7 -mfpu=vfp3 $(CFG_IOS_SDK_FLAGS_armv7-apple-ios) diff --git a/mk/cfg/armv7s-apple-ios.mk b/mk/cfg/armv7s-apple-ios.mk index ccb7f014159ff..7540bd44de878 100644 --- a/mk/cfg/armv7s-apple-ios.mk +++ b/mk/cfg/armv7s-apple-ios.mk @@ -11,7 +11,7 @@ AR_armv7s-apple-ios = $(shell xcrun -find -sdk iphoneos ar) endif CFG_LIB_NAME_armv7s-apple-ios = lib$(1).a CFG_LIB_GLOB_armv7s-apple-ios = lib$(1)-*.a -CFG_LIB_SKIP_INSTALL_armv7s-apple-ios = 1 #lib$(1)-*.a +CFG_INSTALL_ONLY_RLIB_armv7s-apple-ios = 1 CFG_STATIC_LIB_NAME_armv7s-apple-ios=lib$(1).a CFG_LIB_DSYM_GLOB_armv7s-apple-ios = lib$(1)-*.a.dSYM CFG_JEMALLOC_CFLAGS_armv7s-apple-ios := -arch armv7s -mfpu=vfp4 $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) diff --git a/mk/cfg/i386-apple-ios.mk b/mk/cfg/i386-apple-ios.mk index 5007c0617c5a9..e84bf49d4079a 100644 --- a/mk/cfg/i386-apple-ios.mk +++ b/mk/cfg/i386-apple-ios.mk @@ -11,6 +11,7 @@ AR_i386-apple-ios = $(shell xcrun -find -sdk iphonesimulator ar) endif CFG_LIB_NAME_i386-apple-ios = lib$(1).a CFG_LIB_GLOB_i386-apple-ios = lib$(1)-*.dylib +CFG_INSTALL_ONLY_RLIB_i386-apple-ios = 1 CFG_STATIC_LIB_NAME_i386-apple-ios=lib$(1).a CFG_LIB_DSYM_GLOB_i386-apple-ios = lib$(1)-*.dylib.dSYM CFG_GCCISH_CFLAGS_i386-apple-ios := -Wall -Werror -g -fPIC -m32 $(CFG_IOSSIM_FLAGS_i386-apple-ios) diff --git a/mk/cfg/x86_64-apple-ios.mk b/mk/cfg/x86_64-apple-ios.mk index 69070ec4fad4d..b3f05a895a49f 100644 --- a/mk/cfg/x86_64-apple-ios.mk +++ b/mk/cfg/x86_64-apple-ios.mk @@ -11,7 +11,7 @@ AR_x86_64-apple-ios = $(shell xcrun -find -sdk iphonesimulator ar) endif CFG_LIB_NAME_x86_64-apple-ios = lib$(1).a CFG_LIB_GLOB_x86_64-apple-ios = lib$(1)-*.a -CFG_LIB_SKIP_INSTALL_x86_64-apple-ios = 1 #lib$(1)-*.a +CFG_INSTALL_ONLY_RLIB_x86_64-apple-ios = 1 CFG_STATIC_LIB_NAME_x86_64-apple-ios=lib$(1).a CFG_LIB_DSYM_GLOB_x86_64-apple-ios = lib$(1)-*.a.dSYM CFG_CFLAGS_x86_64-apple-ios := $(CFG_IOSSIM_FLAGS_x86_64-apple-ios) diff --git a/mk/main.mk b/mk/main.mk index 334647d04023f..46cbe34904dbc 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.0.0 # 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) -CFG_PRERELEASE_VERSION= +CFG_PRERELEASE_VERSION=.1 CFG_FILENAME_EXTRA=4e7c5e5c @@ -30,9 +30,8 @@ CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM) CFG_DISABLE_UNSTABLE_FEATURES=1 endif ifeq ($(CFG_RELEASE_CHANNEL),beta) -# The beta channel is temporarily called 'alpha' -CFG_RELEASE=$(CFG_RELEASE_NUM)-alpha$(CFG_PRERELEASE_VERSION) -CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-alpha$(CFG_PRERELEASE_VERSION) +CFG_RELEASE=$(CFG_RELEASE_NUM)-beta(CFG_PRERELEASE_VERSION) +CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-beta(CFG_PRERELEASE_VERSION) CFG_DISABLE_UNSTABLE_FEATURES=1 endif ifeq ($(CFG_RELEASE_CHANNEL),nightly) diff --git a/mk/prepare.mk b/mk/prepare.mk index 6a5daeb690941..f1c4aa65f5ffe 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -134,7 +134,7 @@ prepare-target-$(2)-host-$(3)-$(1)-$(4): prepare-maybe-clean-$(4) \ $$(if $$(findstring $(3), $$(PREPARE_HOST)), \ $$(call PREPARE_DIR,$$(PREPARE_WORKING_DEST_LIB_DIR)) \ $$(foreach crate,$$(TARGET_CRATES), \ - $$(if $$(findstring 1, $$(ONLY_RLIB_$$(crate))),, \ + $$(if $$(or $$(findstring 1, $$(ONLY_RLIB_$$(crate))),$$(findstring 1,$$(CFG_INSTALL_ONLY_RLIB_$(2)))),, \ $$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))) \ $$(call PREPARE_LIB,$$(call CFG_RLIB_GLOB,$$(crate)))) \ $$(if $$(findstring $(2),$$(CFG_HOST)), \ diff --git a/src/doc/complement-lang-faq.md b/src/doc/complement-lang-faq.md index a9a9e0858ec6b..8238dd3a5ba42 100644 --- a/src/doc/complement-lang-faq.md +++ b/src/doc/complement-lang-faq.md @@ -10,7 +10,7 @@ There aren't many large programs yet. The Rust [compiler][rustc], 60,000+ lines A research browser engine called [Servo][servo], currently 30,000+ lines across more than a dozen crates, will be exercising a lot of Rust's distinctive type-system and concurrency features, and integrating many native libraries. -[servo]: https://github.com/mozilla/servo +[servo]: https://github.com/servo/servo Some examples that demonstrate different aspects of the language: diff --git a/src/doc/complement-project-faq.md b/src/doc/complement-project-faq.md index 1b463d7769353..bb1805d694fd0 100644 --- a/src/doc/complement-project-faq.md +++ b/src/doc/complement-project-faq.md @@ -30,7 +30,7 @@ No. It started as a Graydon Hoare's part-time side project in 2006 and remained # What will Mozilla use Rust for? -Mozilla intends to use Rust as a platform for prototyping experimental browser architectures. Specifically, the hope is to develop a browser that is more amenable to parallelization than existing ones, while also being less prone to common C++ coding errors that result in security exploits. The name of that project is _[Servo](http://github.com/mozilla/servo)_. +Mozilla intends to use Rust as a platform for prototyping experimental browser architectures. Specifically, the hope is to develop a browser that is more amenable to parallelization than existing ones, while also being less prone to common C++ coding errors that result in security exploits. The name of that project is _[Servo](http://github.com/servo/servo)_. # Why a BSD-style permissive license rather than MPL or tri-license? diff --git a/src/doc/intro.md b/src/doc/intro.md index 0d5e547c82702..d93b680ae6de7 100644 --- a/src/doc/intro.md +++ b/src/doc/intro.md @@ -5,7 +5,7 @@ accomplishes these goals by being memory safe without using garbage collection. This introduction will give you a rough idea of what Rust is like, eliding many details. It does not require prior experience with systems programming, but you -may find the syntax easier if you've used a 'curly brace' programming language +may find the syntax easier if you've used a "curly brace" programming language before, like C or JavaScript. The concepts are more important than the syntax, so don't worry if you don't get every last detail: you can read [The Rust Programming Language](book/index.html) to get a more complete explanation. @@ -15,7 +15,7 @@ Rust to follow along. If you'd like to anyway, check out [the homepage](http://rust-lang.org) for explanation. To show off Rust, let's talk about how easy it is to get started with Rust. -Then, we'll talk about Rust's most interesting feature, **ownership**, and +Then, we'll talk about Rust's most interesting feature, *ownership*, and then discuss how it makes concurrency easier to reason about. Finally, we'll talk about how Rust breaks down the perceived dichotomy between speed and safety. @@ -57,7 +57,7 @@ version = "0.0.1" authors = ["Your Name "] ``` -This is called a **manifest**, and it contains all of the metadata that Cargo +This is called a *manifest*, and it contains all of the metadata that Cargo needs to compile your project. Here's what's in `src/main.rs`: @@ -68,7 +68,7 @@ fn main() { } ``` -Cargo generated a 'hello world' for us. We'll talk more about the syntax here +Cargo generated a "Hello World" for us. We'll talk more about the syntax here later, but that's what Rust code looks like! Let's compile and run it: ```{bash} @@ -146,8 +146,8 @@ Enough about tools, let's talk code! # Ownership -Rust's defining feature is 'memory safety without garbage collection.' Let's -take a moment to talk about what that means. **Memory safety** means that the +Rust's defining feature is "memory safety without garbage collection". Let's +take a moment to talk about what that means. *Memory safety* means that the programming language eliminates certain kinds of bugs, such as [buffer overflows](http://en.wikipedia.org/wiki/Buffer_overflow) and [dangling pointers](http://en.wikipedia.org/wiki/Dangling_pointer). These problems occur @@ -170,7 +170,7 @@ We make an array, `v`, and then call `push` on it. `push` is a method which adds an element to the end of an array. Next, we make a new variable, `x`, that's equal to the first element of -the array. Simple, but this is where the 'bug' will appear. +the array. Simple, but this is where the "bug" will appear. Let's keep going. We then call `push` again, pushing "world" onto the end of the array. `v` now is `["Hello", "world"]`. @@ -222,7 +222,7 @@ its length changes, we may need to allocate more memory. In Ruby, this happens as well, we just don't think about it very often. So why does the C++ version segfault when we allocate more memory? -The answer is that in the C++ version, `x` is a **reference** to the memory +The answer is that in the C++ version, `x` is a *reference* to the memory location where the first element of the array is stored. But in Ruby, `x` is a standalone value, not connected to the underyling array at all. Let's dig into the details for a moment. Your program has access to memory, provided to it by @@ -332,11 +332,11 @@ error: aborting due to previous error When we try to mutate the array by `push`ing it the second time, Rust throws an error. It says that we "cannot borrow v as mutable because it is also -borrowed as immutable." What's up with "borrowed"? +borrowed as immutable." What does it mean by "borrowed"? -In Rust, the type system encodes the notion of **ownership**. The variable `v` -is an "owner" of the vector. When we make a reference to `v`, we let that -variable (in this case, `x`) 'borrow' it for a while. Just like if you own a +In Rust, the type system encodes the notion of *ownership*. The variable `v` +is an *owner* of the vector. When we make a reference to `v`, we let that +variable (in this case, `x`) *borrow* it for a while. Just like if you own a book, and you lend it to me, I'm borrowing the book. So, when I try to modify the vector with the second call to `push`, I need @@ -392,22 +392,23 @@ Here's an example of a concurrent Rust program: use std::thread::Thread; fn main() { - for _ in range(0u, 10u) { - Thread::spawn(move || { + let guards: Vec<_> = (0..10).map(|_| { + Thread::scoped(|| { println!("Hello, world!"); - }); - } + }) + }).collect(); } ``` -This program creates ten threads, who all print `Hello, world!`. The -`spawn` function takes one argument, a closure, indicated by the -double bars `||`. (The `move` keyword indicates that the closure takes -ownership of any data it uses; we'll have more on the significance of -this shortly.) This closure is executed in a new thread created by -`spawn`. +This program creates ten threads, which all print `Hello, world!`. The `scoped` +function takes one argument, a closure, indicated by the double bars `||`. This +closure is executed in a new thread created by `scoped`. The method is called +`scoped` because it returns a 'join guard', which will automatically join the +child thread when it goes out of scope. Because we `collect` these guards into +a `Vec`, and that vector goes out of scope at the end of our program, our +program will wait for every thread to finish before finishing. -One common form of problem in concurrent programs is a 'data race.' +One common form of problem in concurrent programs is a *data race*. This occurs when two different threads attempt to access the same location in memory in a non-synchronized way, where at least one of them is a write. If one thread is attempting to read, and one thread @@ -460,9 +461,9 @@ code tries to make three owners. This may cause a safety problem, so Rust disallows it. What to do here? Rust has two types that helps us: `Arc` and `Mutex`. -"Arc" stands for "atomically reference counted." In other words, an Arc will +*Arc* stands for "atomically reference counted". In other words, an Arc will keep track of the number of references to something, and not free the -associated resource until the count is zero. The 'atomic' portion refers to an +associated resource until the count is zero. The *atomic* portion refers to an Arc's usage of concurrency primitives to atomically update the count, making it safe across threads. If we use an Arc, we can have our three references. But, an Arc does not allow mutable borrows of the data it holds, and we want to @@ -525,13 +526,13 @@ give us assurance _at compile time_ that we weren't doing something incorrect with regards to concurrency. In order to share ownership, we were forced to be explicit and use a mechanism to ensure that it would be properly handled. -# Safety _and_ speed +# Safety _and_ Speed -Safety and speed are always presented as a continuum. On one hand, you have -maximum speed, but no safety. On the other, you have absolute safety, with no -speed. Rust seeks to break out of this mode by introducing safety at compile -time, ensuring that you haven't done anything wrong, while compiling to the -same low-level code you'd expect without the safety. +Safety and speed are always presented as a continuum. At one end of the spectrum, +you have maximum speed, but no safety. On the other end, you have absolute safety +with no speed. Rust seeks to break out of this paradigm by introducing safety at +compile time, ensuring that you haven't done anything wrong, while compiling to +the same low-level code you'd expect without the safety. As an example, Rust's ownership system is _entirely_ at compile time. The safety check that makes this an error about moved values: diff --git a/src/doc/not_found.md b/src/doc/not_found.md index bd4d959109716..c746c5773dd09 100644 --- a/src/doc/not_found.md +++ b/src/doc/not_found.md @@ -12,6 +12,7 @@ Looks like you've taken a wrong turn. Some things that might be helpful to you though: ## Search + *
@@ -19,10 +20,12 @@ Some things that might be helpful to you though: * Rust doc search: ## Reference + * [The Rust official site](http://rust-lang.org) -* [The Rust reference](http://doc.rust-lang.org/reference.html) (* [PDF](http://doc.rust-lang.org/reference.pdf)) +* [The Rust reference](http://doc.rust-lang.org/reference.html) ## Docs + * [The standard library](http://doc.rust-lang.org/std/) +"#; diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 48dad14321a8d..85b9a7d79dbfe 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -39,6 +39,7 @@ mod serve; mod test; mod css; +mod javascript; #[cfg(not(test))] // thanks #12327 fn main() { diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 9eeb7ee88571e..e3e91e05f55e9 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -1,4 +1,4 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -16,7 +16,7 @@ extern crate syntax; extern crate rustc; -use syntax::ast::{TokenTree, Item, MetaItem}; +use syntax::ast::{TokenTree, Item, MetaItem, ImplItem, TraitItem, Method}; use syntax::codemap::Span; use syntax::ext::base::*; use syntax::parse::token; @@ -37,6 +37,9 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension( token::intern("into_foo"), Modifier(box expand_into_foo)); + reg.register_syntax_extension( + token::intern("into_multi_foo"), + MultiModifier(box expand_into_foo_multi)); } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) @@ -65,6 +68,30 @@ fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: &MetaItem, it: P) }) } +fn expand_into_foo_multi(cx: &mut ExtCtxt, + sp: Span, + attr: &MetaItem, + it: Annotatable) -> Annotatable { + match it { + Annotatable::Item(it) => { + Annotatable::Item(P(Item { + attrs: it.attrs.clone(), + ..(*quote_item!(cx, enum Foo2 { Bar2, Baz2 }).unwrap()).clone() + })) + } + Annotatable::ImplItem(it) => { + Annotatable::ImplItem(ImplItem::MethodImplItem( + quote_method!(cx, fn foo(&self) -> i32 { 42 }) + )) + } + Annotatable::TraitItem(it) => { + Annotatable::TraitItem(TraitItem::ProvidedMethod( + quote_method!(cx, fn foo(&self) -> i32 { 0 }) + )) + } + } +} + fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box { use syntax::ext::quote::rt::*; diff --git a/src/test/compile-fail/coherence-impls-builtin.rs b/src/test/compile-fail/coherence-impls-builtin.rs new file mode 100644 index 0000000000000..2ca288b60a33f --- /dev/null +++ b/src/test/compile-fail/coherence-impls-builtin.rs @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::Send; + +enum TestE { + A +} + +struct MyType; + +unsafe impl Send for TestE {} +unsafe impl Send for MyType {} +unsafe impl Send for (MyType, MyType) {} +//~^ ERROR builtin traits can only be implemented on structs or enums + +unsafe impl Send for &'static MyType {} +//~^ ERROR builtin traits can only be implemented on structs or enums + +unsafe impl Send for [MyType] {} +//~^ ERROR builtin traits can only be implemented on structs or enums + +unsafe impl Send for &'static [MyType] {} +//~^ ERROR builtin traits can only be implemented on structs or enums + +fn is_send() {} + +fn main() { + is_send::<(MyType, TestE)>(); +} diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs new file mode 100644 index 0000000000000..aaf45f2739891 --- /dev/null +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #20831: debruijn index account was thrown off +// by the (anonymous) lifetime in `::Output` +// below. Note that changing to a named lifetime made the problem go +// away. + +use std::ops::{Shl, Shr}; +use std::cell::RefCell; + +pub trait Subscriber { + type Input; +} + +pub trait Publisher<'a> { + type Output; + fn subscribe(&mut self, Box + 'a>); +} + +pub trait Processor<'a> : Subscriber + Publisher<'a> { } + +impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } + +struct MyStruct<'a> { + sub: Box + 'a> +} + +impl<'a> Publisher<'a> for MyStruct<'a> { + type Output = u64; + fn subscribe(&mut self, t : Box::Output> + 'a>) { + // Not obvious, but there is an implicit lifetime here -------^ + //~^^ ERROR cannot infer + // + // The fact that `Publisher` is using an implicit lifetime is + // what was causing the debruijn accounting to be off, so + // leave it that way! + self.sub = t; + } +} + +fn main() {} diff --git a/src/test/compile-fail/vec-matching-obsolete-syntax.rs b/src/test/compile-fail/issue-21045.rs similarity index 66% rename from src/test/compile-fail/vec-matching-obsolete-syntax.rs rename to src/test/compile-fail/issue-21045.rs index 2715b31d1960e..134240f8c8aa3 100644 --- a/src/test/compile-fail/vec-matching-obsolete-syntax.rs +++ b/src/test/compile-fail/issue-21045.rs @@ -7,16 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(asm)] fn main() { - let x = [1is, 2, 3]; - match x { - [a, b, ..c] => { //~ ERROR obsolete syntax - assert_eq!(a, 1); - assert_eq!(b, 2); - let expected: &[_] = &[3]; - assert_eq!(c, expected); - } - } + let a; + asm!("nop" "nop"); //~ ERROR malformed inline assembly + asm!("nop" "nop" : "=r"(a)); //~ ERROR malformed inline assembly } - diff --git a/src/test/compile-fail/obsolete-tuple-struct-deref.rs b/src/test/compile-fail/issue-21160.rs similarity index 61% rename from src/test/compile-fail/obsolete-tuple-struct-deref.rs rename to src/test/compile-fail/issue-21160.rs index ad5fac3e21e88..0ee381669351a 100644 --- a/src/test/compile-fail/obsolete-tuple-struct-deref.rs +++ b/src/test/compile-fail/issue-21160.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,8 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { - struct S(isize); - let s = S(0); - let x = *s; //~ ERROR single-field tuple-structs can no longer be dereferenced +struct Bar; + +impl Bar { + fn hash(&self, _: T) {} } + +#[derive(Hash)] +struct Foo(Bar); +//~^ error: the trait `core::hash::Hash<__S>` is not implemented for the type `Bar` + +fn main() {} diff --git a/src/test/compile-fail/obsolete-tilde.rs b/src/test/compile-fail/obsolete-tilde.rs deleted file mode 100644 index d290d5536a4a2..0000000000000 --- a/src/test/compile-fail/obsolete-tilde.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that ~ pointers give an obsolescence message. - -fn foo(x: ~isize) {} //~ ERROR obsolete syntax: `~` notation for owned pointers -fn bar(x: ~str) {} //~ ERROR obsolete syntax: `~` notation for owned pointers -fn baz(x: ~[isize]) {} //~ ERROR obsolete syntax: `~[T]` is no longer a type - -fn main() { - let x = ~4is; //~ ERROR obsolete syntax: `~` notation for owned pointer allocation - let y = ~"hello"; //~ ERROR obsolete syntax: `~` notation for owned pointer allocation - let z = ~[1is, 2, 3]; //~ ERROR obsolete syntax: `~[T]` is no longer a type -} diff --git a/src/test/debuginfo/limited-debuginfo.rs b/src/test/debuginfo/limited-debuginfo.rs index 35889ff81335c..00de4497cedbf 100644 --- a/src/test/debuginfo/limited-debuginfo.rs +++ b/src/test/debuginfo/limited-debuginfo.rs @@ -48,7 +48,11 @@ fn zzz() {()} fn some_function(a: int, b: int) { let some_variable = Struct { a: 11, b: 22 }; let some_other_variable = 23i; - zzz(); // #break + + for x in range(0, 1) { + zzz(); // #break + } } fn some_other_function(a: int, b: int) -> bool { true } + diff --git a/src/test/run-make/graphviz-flowgraph/Makefile b/src/test/run-make/graphviz-flowgraph/Makefile index 0562e000e56e9..4ac8cb7ae1da7 100644 --- a/src/test/run-make/graphviz-flowgraph/Makefile +++ b/src/test/run-make/graphviz-flowgraph/Makefile @@ -28,7 +28,7 @@ $(TMPDIR)/%.pp: %.rs $(TMPDIR)/%.dot: %.rs $(eval $(call FIND_LAST_BLOCK,$<)) - $(RUSTC_LIB) -Z unstable-options --xpretty flowgraph=$(LASTBLOCKNUM_$<) $< -o $@.tmp + $(RUSTC_LIB) -Z unstable-options --xpretty flowgraph,unlabelled=$(LASTBLOCKNUM_$<) $< -o $@.tmp cat $@.tmp | sed -e 's@ (id=[0-9]*)@@g' \ -e 's@\[label=""\]@@' \ -e 's@digraph [a-zA-Z0-9_]* @digraph block @' \ diff --git a/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot index e9cd07c0356f8..12b16cc9f8ce8 100644 --- a/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot @@ -34,7 +34,7 @@ digraph block { N11 -> N12; N12 -> N13; N13 -> N14; - N14 -> N6[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2is { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1is; if x == 2is { break ; \"unreachable\"; } }"]; + N14 -> N6; N15 -> N16; N16 -> N17; N17 -> N18; diff --git a/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot index 7b01c606083ff..47e9b3f6cbe1a 100644 --- a/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot @@ -61,7 +61,7 @@ digraph block { N12 -> N13; N13 -> N14; N14 -> N15; - N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { break ; \"unreachable\"; }\l y -= 3is;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { break ; \"unreachable\"; }\l y -= 3is;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { break ; \"unreachable\"; }\l y -= 3is;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { break ; \"unreachable\"; }\l y -= 3is;\l }\l y -= 4is;\l x -= 5is;\l}\l"]; + N15 -> N9; N16 -> N17; N17 -> N18; N18 -> N19; @@ -73,7 +73,7 @@ digraph block { N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 2is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 2is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { break ; \"unreachable\"; }\l y -= 3is;\l}\l"]; + N26 -> N11; N27 -> N28; N28 -> N29; N29 -> N30; diff --git a/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot index 2123185a08386..a37869b226498 100644 --- a/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot @@ -64,7 +64,7 @@ digraph block { N12 -> N13; N13 -> N14; N14 -> N15; - N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 1is { break ; \"unreachable\"; }\l y -= 1is;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 1is { break ; \"unreachable\"; }\l y -= 1is;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 1is { break ; \"unreachable\"; }\l y -= 1is;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 1is { break ; \"unreachable\"; }\l y -= 1is;\l }\l y -= 1is;\l x -= 1is;\l}\l"]; + N15 -> N8; N16 -> N17; N17 -> N18; N18 -> N19; @@ -76,7 +76,7 @@ digraph block { N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 1is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 1is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 1is { break ; \"unreachable\"; }\l y -= 1is;\l}\l"]; + N26 -> N11; N27 -> N28; N28 -> N29; N29 -> N30; diff --git a/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot index e7a2cf2ff732f..46f1634416e5b 100644 --- a/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot @@ -59,7 +59,7 @@ digraph block { N12 -> N13; N13 -> N14; N14 -> N15; - N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l }\l \"unreachable\";\l}\l"]; + N15 -> N9; N16 -> N17; N17 -> N18; N18 -> N19; @@ -71,7 +71,7 @@ digraph block { N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1is { break \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l y -= 3is;\l x -= 5is;\l }\l \"unreachable\";\l }\l"]; + N26 -> N1; N27 -> N28; N28 -> N29; N29 -> N30; diff --git a/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot index edd39b40b36a3..3f35a9b0f9ab3 100644 --- a/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot @@ -62,7 +62,7 @@ digraph block { N12 -> N13; N13 -> N14; N14 -> N15; - N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l}\l,\lexiting scope_6 expr \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l }\l,\lexiting scope_7 stmt \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l }\l,\lexiting scope_8 block {\l \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l }\l \"unreachable\";\l}\l"]; + N15 -> N8; N16 -> N17; N17 -> N18; N18 -> N19; @@ -74,7 +74,7 @@ digraph block { N23 -> N24; N24 -> N25; N25 -> N26; - N26 -> N1[label="exiting scope_0 expr \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l }\l,\lexiting scope_1 expr \'outer:\l loop {\l \'inner:\l loop {\l if x == 1is { continue \'outer ; \"unreachable\"; }\l if y >= 2is { return; \"unreachable\"; }\l x -= 1is;\l y -= 3is;\l }\l \"unreachable\";\l }\l"]; + N26 -> N1; N27 -> N28; N28 -> N29; N29 -> N30; diff --git a/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot index 2b5c5cdff44e3..c9f7d4cdf0aab 100644 --- a/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot @@ -95,7 +95,7 @@ digraph block { N40 -> N41; N41 -> N42; N42 -> N43; - N43 -> N1[label="exiting scope_0 expr while y > 0is {\l y -= 1is;\l while z > 0is { z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0is {\l x -= 1is;\l while y > 0is {\l y -= 1is;\l while z > 0is { z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l }\l}\l"]; + N43 -> N1; N44 -> N45; N45 -> N46; N46 -> N47; diff --git a/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot index ee3fe7ced6cd7..a5373bda39b18 100644 --- a/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot @@ -90,7 +90,7 @@ digraph block { N13 -> N14; N14 -> N15; N15 -> N16; - N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0is { break ; \"unreachable\"; }\l x -= 1is;\l loop {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l }\l}\l"]; + N16 -> N12; N17 -> N18; N18 -> N19; N19 -> N20; @@ -107,7 +107,7 @@ digraph block { N30 -> N31; N31 -> N32; N32 -> N33; - N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l}\l"]; + N33 -> N29; N34 -> N35; N35 -> N36; N36 -> N37; @@ -124,7 +124,7 @@ digraph block { N47 -> N48; N48 -> N49; N49 -> N50; - N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0is { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"]; + N50 -> N46; N51 -> N52; N52 -> N53; N53 -> N54; @@ -143,7 +143,7 @@ digraph block { N64 -> N65; N65 -> N66; N66 -> N67; - N67 -> N1[label="exiting scope_0 expr loop {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop {\l if x == 0is { break ; \"unreachable\"; }\l x -= 1is;\l loop {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { return; \"unreachable\"; }\l }\l}\l"]; + N67 -> N1; N68 -> N69; N69 -> N70; N70 -> N71; diff --git a/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot b/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot index 82799c724b0bd..2611219e816e9 100644 --- a/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot +++ b/src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot @@ -90,7 +90,7 @@ digraph block { N13 -> N14; N14 -> N15; N15 -> N16; - N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0is { break ; \"unreachable\"; }\l x -= 1is;\l \'a:\l loop {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l \'a: loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { continue \'a ; \"unreachable\"; }\l }\l}\l"]; + N16 -> N12; N17 -> N18; N18 -> N19; N19 -> N20; @@ -107,7 +107,7 @@ digraph block { N30 -> N31; N31 -> N32; N32 -> N33; - N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l \'a: loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { continue \'a ; \"unreachable\"; }\l}\l"]; + N33 -> N29; N34 -> N35; N35 -> N36; N36 -> N37; @@ -124,7 +124,7 @@ digraph block { N47 -> N48; N48 -> N49; N49 -> N50; - N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0is { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"]; + N50 -> N46; N51 -> N52; N52 -> N53; N53 -> N54; @@ -143,7 +143,7 @@ digraph block { N64 -> N65; N65 -> N66; N66 -> N67; - N67 -> N28[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10is { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l if y == 0is { break ; \"unreachable\"; }\l y -= 1is;\l \'a: loop { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l if x > 10is { continue \'a ; \"unreachable\"; }\l}\l"]; + N67 -> N28; N68 -> N69; N69 -> N70; N70 -> N71; diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index f5027618814a9..365cbf93da203 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -51,7 +51,7 @@ endif # Extra flags needed to compile a working executable with the standard library ifdef IS_WINDOWS - EXTRACFLAGS := + EXTRACFLAGS := -lws2_32 else ifeq ($(shell uname),Darwin) else diff --git a/src/test/run-pass-fulldeps/macro-crate.rs b/src/test/run-pass-fulldeps/macro-crate.rs index 4ffb8a3f74d4f..5236b35d4d2b9 100644 --- a/src/test/run-pass-fulldeps/macro-crate.rs +++ b/src/test/run-pass-fulldeps/macro-crate.rs @@ -1,4 +1,4 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -20,12 +20,36 @@ extern crate macro_crate_test; #[derive(PartialEq, Clone, Show)] fn foo() -> AFakeTypeThatHadBetterGoAway {} +#[into_multi_foo] +#[derive(PartialEq, Clone, Show)] +fn foo() -> AnotherFakeTypeThatHadBetterGoAway {} + +trait Qux { + #[into_multi_foo] + fn bar(); +} + +impl Qux for i32 { + #[into_multi_foo] + fn bar() {} +} + +impl Qux for u8 {} + pub fn main() { assert_eq!(1, make_a_1!()); assert_eq!(2, exported_macro!()); assert_eq!(Foo::Bar, Foo::Bar); test(None::); + + assert_eq!(Foo2::Bar2, Foo2::Bar2); + test(None::); + + let x = 10i32; + assert_eq!(x.foo(), 42); + let x = 10u8; + assert_eq!(x.foo(), 0); } fn test(_: Option) {} diff --git a/src/test/run-pass/associated-types-normalize-unifield-struct.rs b/src/test/run-pass/associated-types-normalize-unifield-struct.rs new file mode 100644 index 0000000000000..c517f61de0c16 --- /dev/null +++ b/src/test/run-pass/associated-types-normalize-unifield-struct.rs @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #21010: Normalize associated types in +// various special paths in the `type_is_immediate` function. + +#![allow(unstable)] + +pub trait OffsetState: Sized {} +pub trait Offset { type State: OffsetState; } + +#[derive(Copy)] pub struct X; +impl Offset for X { type State = Y; } + +#[derive(Copy)] pub struct Y; +impl OffsetState for Y {} + +pub fn now() -> DateTime { from_utc(Y) } + +pub struct DateTime { pub offset: Off::State } +pub fn from_utc(offset: Off::State) -> DateTime { DateTime { offset: offset } } + +pub fn main() { + let _x = now(); +} diff --git a/src/test/run-pass/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types-projection-in-object-type.rs new file mode 100644 index 0000000000000..44dd49b72976e --- /dev/null +++ b/src/test/run-pass/associated-types-projection-in-object-type.rs @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Corrected regression test for #20831. The original did not compile. +// When fixed, it revealed another problem concerning projections that +// appear in associated type bindings in object types, which were not +// being properly flagged. + +use std::ops::{Shl, Shr}; +use std::cell::RefCell; + +pub trait Subscriber { + type Input; +} + +pub trait Publisher<'a> { + type Output; + fn subscribe(&mut self, Box + 'a>); +} + +pub trait Processor<'a> : Subscriber + Publisher<'a> { } + +impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } + +struct MyStruct<'a> { + sub: Box + 'a> +} + +impl<'a> Publisher<'a> for MyStruct<'a> { + type Output = u64; + fn subscribe(&mut self, t : Box + 'a>) { + self.sub = t; + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-20575.rs b/src/test/run-pass/issue-20575.rs new file mode 100644 index 0000000000000..f83150b95184b --- /dev/null +++ b/src/test/run-pass/issue-20575.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that overloaded calls work with zero arity closures + +#![feature(box_syntax)] + +fn main() { + let functions: [Box Option<()>>; 1] = [box || None]; + + let _: Option> = functions.iter().map(|f| (*f)()).collect(); +} diff --git a/src/test/run-pass/issue-20676.rs b/src/test/run-pass/issue-20676.rs new file mode 100644 index 0000000000000..fd99fc01a23d1 --- /dev/null +++ b/src/test/run-pass/issue-20676.rs @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #20676. Error was that we didn't support +// UFCS-style calls to a method in `Trait` where `Self` was bound to a +// trait object of type `Trait`. See also `ufcs-trait-object.rs`. + +use std::fmt; + +fn main() { + let a: &fmt::Show = &1_i32; + format!("{:?}", a); +} diff --git a/src/test/run-pass/issue-21058.rs b/src/test/run-pass/issue-21058.rs new file mode 100644 index 0000000000000..cbce577451faf --- /dev/null +++ b/src/test/run-pass/issue-21058.rs @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unstable)] + +struct NT(str); +struct DST { a: u32, b: str } + +fn main() { + // get_tydesc should support unsized types + assert!(unsafe {( + // Slice + (*std::intrinsics::get_tydesc::<[u8]>()).name, + // str + (*std::intrinsics::get_tydesc::()).name, + // Trait + (*std::intrinsics::get_tydesc::()).name, + // Newtype + (*std::intrinsics::get_tydesc::()).name, + // DST + (*std::intrinsics::get_tydesc::()).name + )} == ("[u8]", "str", "core::marker::Copy + 'static", "NT", "DST")); +} diff --git a/src/librustc_driver/mod.rs b/src/test/run-pass/regions-debruijn-of-object.rs similarity index 59% rename from src/librustc_driver/mod.rs rename to src/test/run-pass/regions-debruijn-of-object.rs index 1fbbc9c05213b..b9d3ed49c625f 100644 --- a/src/librustc_driver/mod.rs +++ b/src/test/run-pass/regions-debruijn-of-object.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,3 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +struct ctxt<'tcx> { + x: &'tcx i32 +} + +trait AstConv<'tcx> { + fn tcx<'a>(&'a self) -> &'a ctxt<'tcx>; +} + +fn foo(conv: &AstConv) { } + +fn bar<'tcx>(conv: &AstConv<'tcx>) { + foo(conv) +} + +fn main() { } diff --git a/src/test/debuginfo/associated_types.rs b/src/test/run-pass/ufcs-trait-object.rs similarity index 51% rename from src/test/debuginfo/associated_types.rs rename to src/test/run-pass/ufcs-trait-object.rs index 92336e9b34b79..2ae63040d1785 100644 --- a/src/test/debuginfo/associated_types.rs +++ b/src/test/run-pass/ufcs-trait-object.rs @@ -1,4 +1,4 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,21 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-android: FIXME(#10381) -// min-lldb-version: 310 +// Test that when you use ufcs form to invoke a trait method (on a +// trait object) everything works fine. -// compile-flags:-g +trait Foo { + fn test(&self) -> i32; +} -struct Peekable where I: Iterator { - _iter: I, - _next: Option<::Item>, +impl Foo for i32 { + fn test(&self) -> i32 { *self } } fn main() { - let mut iter = Vec::::new().into_iter(); - let next = iter.next(); - let _v = Peekable { - _iter: iter, - _next : next, - }; + let a: &Foo = &22_i32; + assert_eq!(Foo::test(a), 22); } diff --git a/src/test/run-pass/zero_sized_subslice_match.rs b/src/test/run-pass/zero_sized_subslice_match.rs new file mode 100644 index 0000000000000..65882d39375c3 --- /dev/null +++ b/src/test/run-pass/zero_sized_subslice_match.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = [(), ()]; + + // The subslice used to go out of bounds for zero-sized array items, check that this doesn't + // happen anymore + match x { + [_, y..] => assert_eq!(&x[1] as *const _, &y[0] as *const _) + } +}