From: Alex Crichton Date: Thu, 15 Jan 2015 22:11:56 +0000 (-0800) Subject: rollup merge of #21151: brson/beta X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7101ae468602939f0a1185be25949aa848bd3767;hp=9b10e9ac32b2cb786167fb0fca575a68ccd61ef8;p=rust.git rollup merge of #21151: brson/beta --- diff --git a/AUTHORS.txt b/AUTHORS.txt index bc8dbc878ba..896731f0251 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/Makefile.in b/Makefile.in index a2394101f3a..63c5742a540 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 e858e91773b..147d2e9d2f4 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/configure b/configure index d0b99b12fd9..86ed88c8d06 100755 --- a/configure +++ b/configure @@ -448,6 +448,10 @@ case $CFG_CPUTYPE in CFG_CPUTYPE=aarch64 ;; + powerpc) + CFG_CPUTYPE=powerpc + ;; + x86_64 | x86-64 | x64 | amd64) CFG_CPUTYPE=x86_64 ;; @@ -1004,7 +1008,7 @@ do make_dir $t/rt/jemalloc for i in \ isaac sync test \ - arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips + arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips arch/powerpc do make_dir $t/rt/stage$s/$i done @@ -1169,7 +1173,7 @@ do msg "configuring LLVM for $gnu_t" - LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips" + LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips,powerpc" LLVM_BUILD="--build=$gnu_t" LLVM_HOST="--host=$gnu_t" LLVM_TARGET="--target=$gnu_t" diff --git a/mk/cfg/aarch64-apple-ios.mk b/mk/cfg/aarch64-apple-ios.mk index cbd889669ab..0219ab96057 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 23686c41f2b..aee4e64addf 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 ccb7f014159..7540bd44de8 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 5007c0617c5..e84bf49d407 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/powerpc-unknown-linux-gnu.mk b/mk/cfg/powerpc-unknown-linux-gnu.mk new file mode 100644 index 00000000000..fd37bd663f7 --- /dev/null +++ b/mk/cfg/powerpc-unknown-linux-gnu.mk @@ -0,0 +1,28 @@ +# powerpc-unknown-linux-gnu configuration +CROSS_PREFIX_powerpc-unknown-linux-gnu=powerpc-linux-gnu- +CC_powerpc-unknown-linux-gnu=$(CC) +CXX_powerpc-unknown-linux-gnu=$(CXX) +CPP_powerpc-unknown-linux-gnu=$(CPP) +AR_powerpc-unknown-linux-gnu=$(AR) +CFG_LIB_NAME_powerpc-unknown-linux-gnu=lib$(1).so +CFG_STATIC_LIB_NAME_powerpc-unknown-linux-gnu=lib$(1).a +CFG_LIB_GLOB_powerpc-unknown-linux-gnu=lib$(1)-*.so +CFG_LIB_DSYM_GLOB_powerpc-unknown-linux-gnu=lib$(1)-*.dylib.dSYM +CFG_CFLAGS_powerpc-unknown-linux-gnu := -m32 $(CFLAGS) +CFG_GCCISH_CFLAGS_powerpc-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS) +CFG_GCCISH_CXXFLAGS_powerpc-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) +CFG_GCCISH_LINK_FLAGS_powerpc-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32 +CFG_GCCISH_DEF_FLAG_powerpc-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= +CFG_GCCISH_PRE_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-whole-archive +CFG_GCCISH_POST_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-no-whole-archive +CFG_DEF_SUFFIX_powerpc-unknown-linux-gnu := .linux.def +CFG_LLC_FLAGS_powerpc-unknown-linux-gnu := +CFG_INSTALL_NAME_powerpc-unknown-linux-gnu = +CFG_EXE_SUFFIX_powerpc-unknown-linux-gnu = +CFG_WINDOWSY_powerpc-unknown-linux-gnu := +CFG_UNIXY_powerpc-unknown-linux-gnu := 1 +CFG_PATH_MUNGE_powerpc-unknown-linux-gnu := true +CFG_LDPATH_powerpc-unknown-linux-gnu := +CFG_RUN_powerpc-unknown-linux-gnu=$(2) +CFG_RUN_TARG_powerpc-unknown-linux-gnu=$(call CFG_RUN_powerpc-unknown-linux-gnu,,$(2)) +CFG_GNU_TRIPLE_powerpc-unknown-linux-gnu := powerpc-unknown-linux-gnu diff --git a/mk/cfg/x86_64-apple-ios.mk b/mk/cfg/x86_64-apple-ios.mk index 69070ec4fad..b3f05a895a4 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 f60567ea5ec..46cbe34904d 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -262,7 +262,7 @@ endif ###################################################################### # FIXME: x86-ism -LLVM_COMPONENTS=x86 arm aarch64 mips ipo bitreader bitwriter linker asmparser mcjit \ +LLVM_COMPONENTS=x86 arm aarch64 mips powerpc ipo bitreader bitwriter linker asmparser mcjit \ interpreter instrumentation # Only build these LLVM tools diff --git a/mk/platform.mk b/mk/platform.mk index 50bf51b20de..78c1057c2fe 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -177,7 +177,7 @@ define CFG_MAKE_TOOLCHAIN $$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \ $$(call CFG_INSTALL_NAME_$(1),$$(4)) - ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel),) + ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),) # We're using llvm-mc as our assembler because it supports # .cfi pseudo-ops on mac @@ -189,7 +189,7 @@ define CFG_MAKE_TOOLCHAIN -o=$$(1) else - # For the ARM, AARCH64 and MIPS crosses, use the toolchain assembler + # For the ARM, AARCH64, MIPS and POWER crosses, use the toolchain assembler # FIXME: We should be able to use the LLVM assembler CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \ $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1) diff --git a/mk/prepare.mk b/mk/prepare.mk index 6a5daeb6909..f1c4aa65f5f 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/intro.md b/src/doc/intro.md index 0d5e547c827..d93b680ae6d 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 bd4d9591097..c746c5773dd 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 48dad14321a..85b9a7d79db 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -39,6 +39,7 @@ macro_rules! try ( mod test; mod css; +mod javascript; #[cfg(not(test))] // thanks #12327 fn main() { diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 2ac855681f2..4a16b9c257c 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2015-01-05 +2015-01-13 diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 9eeb7ee8857..e3e91e05f55 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/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index 3d8ebc1ecdf..22ba54fea14 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -20,8 +20,7 @@ struct X { data: u32 } impl Something for X { fn yay(_:Option, thing: &[T]) { -//~^ ERROR in method `yay`, type parameter 0 requires bound `Str`, which is not required - + //~^ ERROR the requirement `T : Str` appears on the impl method } } 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 00000000000..aaf45f27398 --- /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/issue-21045.rs b/src/test/compile-fail/issue-21045.rs new file mode 100644 index 00000000000..134240f8c8a --- /dev/null +++ b/src/test/compile-fail/issue-21045.rs @@ -0,0 +1,16 @@ +// 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. +#![feature(asm)] + +fn main() { + 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/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index b141c1f441a..31796e5e20c 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,8 @@ struct E { } impl A for E { - fn b(_x: F) -> F { panic!() } //~ ERROR type parameter 0 requires `Sync` + fn b(_x: F) -> F { panic!() } + //~^ ERROR `F : core::marker::Sync` appears on the impl method } 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 d290d5536a4..00000000000 --- 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/compile-fail/obsolete-tuple-struct-deref.rs b/src/test/compile-fail/obsolete-tuple-struct-deref.rs deleted file mode 100644 index ad5fac3e21e..00000000000 --- a/src/test/compile-fail/obsolete-tuple-struct-deref.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 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() { - struct S(isize); - let s = S(0); - let x = *s; //~ ERROR single-field tuple-structs can no longer be dereferenced -} diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs index 5028ec89972..a3c38dff6b0 100644 --- a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -16,15 +16,16 @@ struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } -pub trait Foo<'a> { +pub trait Foo<'a, 't> { fn no_bound<'b>(self, b: Inv<'b>); fn has_bound<'b:'a>(self, b: Inv<'b>); fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); - fn wrong_bound2<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); + fn okay_bound<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); + fn another_bound<'x: 'a>(self, x: Inv<'x>); } -impl<'a> Foo<'a> for &'a isize { +impl<'a, 't> Foo<'a, 't> for &'a isize { fn no_bound<'b:'a>(self, b: Inv<'b>) { //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match } @@ -47,9 +48,10 @@ fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { // cases. } - fn wrong_bound2<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { - //~^ ERROR distinct set of bounds from its counterpart + fn okay_bound<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { } + + fn another_bound<'x: 't>(self, x: Inv<'x>) {} } fn main() { } diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs index 5fc80d5660d..477bd4f5be9 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -32,15 +32,15 @@ trait Foo { impl Foo for isize { // invalid bound for T, was defined as Eq in trait fn test_error1_fn(&self) {} - //~^ ERROR in method `test_error1_fn`, type parameter 0 requires bound `core::cmp::Ord` + //~^ ERROR the requirement `T : core::cmp::Ord` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error2_fn(&self) {} - //~^ ERROR in method `test_error2_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error3_fn(&self) {} - //~^ ERROR in method `test_error3_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // multiple bounds, same order as in trait fn test3_fn(&self) {} @@ -50,16 +50,16 @@ fn test4_fn(&self) {} // parameters in impls must be equal or more general than in the defining trait fn test_error5_fn(&self) {} - //~^ ERROR in method `test_error5_fn`, type parameter 0 requires bound `B` + //~^ ERROR the requirement `T : B` appears on the impl // bound `std::cmp::Eq` not enforced by this implementation, but this is OK fn test6_fn(&self) {} fn test_error7_fn(&self) {} - //~^ ERROR in method `test_error7_fn`, type parameter 0 requires bound `core::cmp::Eq` + //~^ ERROR the requirement `T : core::cmp::Eq` appears on the impl fn test_error8_fn(&self) {} - //~^ ERROR in method `test_error8_fn`, type parameter 0 requires bound `C` + //~^ ERROR the requirement `T : C` appears on the impl } @@ -71,8 +71,7 @@ trait Trait { impl Trait for usize { fn method>() {} - //~^ ERROR in method `method`, type parameter 0 requires bound `Getter` + //~^ G : Getter` appears on the impl method but not on the corresponding trait method } fn main() {} - diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs index a970a86408e..8ad19116e7b 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -20,7 +20,7 @@ trait IteratorUtil { impl> IteratorUtil for T { fn zip>(self, other: U) -> ZipIterator { - //~^ ERROR in method `zip`, type parameter 1 requires bound `Iterator` + //~^ ERROR the requirement `U : Iterator` appears on the impl method ZipIterator{a: self, b: other} } } diff --git a/src/test/compile-fail/ufcs-qpath-missing-params.rs b/src/test/compile-fail/ufcs-qpath-missing-params.rs new file mode 100644 index 00000000000..5fa66eb98e1 --- /dev/null +++ b/src/test/compile-fail/ufcs-qpath-missing-params.rs @@ -0,0 +1,17 @@ +// 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. + +use std::borrow::IntoCow; + +fn main() { + ::into_cow("foo".to_string()); + //~^ ERROR wrong number of type arguments: expected 2, found 0 +} + diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs new file mode 100644 index 00000000000..868c1eae4a9 --- /dev/null +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -0,0 +1,21 @@ +// 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. + +use std::ops::Add; + +fn main() { + >::add(1, 2); + //~^ ERROR the trait `core::ops::Add` is not implemented for the type `i32` + >::add(1u32, 2); + //~^ ERROR mismatched types + >::add(1, 2u32); + //~^ ERROR mismatched types +} + diff --git a/src/test/compile-fail/vec-matching-obsolete-syntax.rs b/src/test/compile-fail/vec-matching-obsolete-syntax.rs deleted file mode 100644 index 2715b31d196..00000000000 --- a/src/test/compile-fail/vec-matching-obsolete-syntax.rs +++ /dev/null @@ -1,22 +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. - -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); - } - } -} - diff --git a/src/test/debuginfo/associated_types.rs b/src/test/debuginfo/associated_types.rs deleted file mode 100644 index 92336e9b34b..00000000000 --- a/src/test/debuginfo/associated_types.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013-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. - -// ignore-android: FIXME(#10381) -// min-lldb-version: 310 - -// compile-flags:-g - -struct Peekable where I: Iterator { - _iter: I, - _next: Option<::Item>, -} - -fn main() { - let mut iter = Vec::::new().into_iter(); - let next = iter.next(); - let _v = Peekable { - _iter: iter, - _next : next, - }; -} diff --git a/src/test/run-make/graphviz-flowgraph/Makefile b/src/test/run-make/graphviz-flowgraph/Makefile index 0562e000e56..4ac8cb7ae1d 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 e9cd07c0356..12b16cc9f8c 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 7b01c606083..47e9b3f6cbe 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 2123185a083..a37869b2264 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 e7a2cf2ff73..46f1634416e 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 edd39b40b36..3f35a9b0f9a 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 2b5c5cdff44..c9f7d4cdf0a 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 ee3fe7ced6c..a5373bda39b 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 82799c724b0..2611219e816 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-pass-fulldeps/macro-crate.rs b/src/test/run-pass-fulldeps/macro-crate.rs index 4ffb8a3f74d..5236b35d4d2 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 @@ #[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 00000000000..c517f61de0c --- /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 00000000000..44dd49b7297 --- /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/const-polymorphic-paths.rs b/src/test/run-pass/const-polymorphic-paths.rs index 28b346c9ed4..f8f92a56adb 100644 --- a/src/test/run-pass/const-polymorphic-paths.rs +++ b/src/test/run-pass/const-polymorphic-paths.rs @@ -10,9 +10,11 @@ #![feature(macro_rules)] +use std::borrow::{Cow, IntoCow}; use std::collections::Bitv; use std::default::Default; use std::iter::FromIterator; +use std::ops::Add; use std::option::IntoIter as OptionIter; use std::rand::Rand; use std::rand::XorShiftRng as DummyRng; @@ -28,6 +30,11 @@ fn u8_as_i8(x: u8) -> i8 { x as i8 } fn odd(x: uint) -> bool { x % 2 == 1 } fn dummy_rng() -> DummyRng { DummyRng::new_unseeded() } +trait Size: Sized { + fn size() -> uint { std::mem::size_of::() } +} +impl Size for T {} + macro_rules! tests { ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({ const C: $ty = $expr; @@ -70,14 +77,31 @@ macro_rules! tests { // , (vec![b'f', b'o', b'o'], u8_as_i8); // Trait static methods. - // FIXME qualified path expressions aka UFCS i.e. ::method. + ::size, fn() -> uint, (); Default::default, fn() -> int, (); + ::default, fn() -> int, (); Rand::rand, fn(&mut DummyRng) -> int, (&mut dummy_rng()); + ::rand, fn(&mut DummyRng) -> int, (&mut dummy_rng()); Rand::rand::, fn(&mut DummyRng) -> int, (&mut dummy_rng()); + ::rand::, fn(&mut DummyRng) -> int, (&mut dummy_rng()); // Trait non-static methods. Clone::clone, fn(&int) -> int, (&5); + ::clone, fn(&int) -> int, (&5); FromIterator::from_iter, fn(OptionIter) -> Vec, (Some(5).into_iter()); - FromIterator::from_iter::>, fn(OptionIter) -> Vec - , (Some(5).into_iter()); + as FromIterator<_>>::from_iter, fn(OptionIter) -> Vec, + (Some(5).into_iter()); + as FromIterator<_>>::from_iter, fn(OptionIter) -> Vec, + (Some(5).into_iter()); + FromIterator::from_iter::>, fn(OptionIter) -> Vec, + (Some(5).into_iter()); + as FromIterator<_>>::from_iter::>, fn(OptionIter) -> Vec, + (Some(5).into_iter()); + Add::add, fn(i32, i32) -> i32, (5, 6); + >::add, fn(i32, i32) -> i32, (5, 6); + >::add, fn(i32, i32) -> i32, (5, 6); + >::into_cow, fn(String) -> Cow<'static, String, str>, + ("foo".to_string()); + >::into_cow, fn(String) -> Cow<'static, String, str>, + ("foo".to_string()); } diff --git a/src/test/run-pass/issue-20575.rs b/src/test/run-pass/issue-20575.rs new file mode 100644 index 00000000000..f83150b9518 --- /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 00000000000..fd99fc01a23 --- /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/regions-debruijn-of-object.rs b/src/test/run-pass/regions-debruijn-of-object.rs new file mode 100644 index 00000000000..b9d3ed49c62 --- /dev/null +++ b/src/test/run-pass/regions-debruijn-of-object.rs @@ -0,0 +1,25 @@ +// 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. + +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/run-pass/ufcs-trait-object.rs b/src/test/run-pass/ufcs-trait-object.rs new file mode 100644 index 00000000000..2ae63040d17 --- /dev/null +++ b/src/test/run-pass/ufcs-trait-object.rs @@ -0,0 +1,25 @@ +// 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 when you use ufcs form to invoke a trait method (on a +// trait object) everything works fine. + +trait Foo { + fn test(&self) -> i32; +} + +impl Foo for i32 { + fn test(&self) -> i32 { *self } +} + +fn main() { + let a: &Foo = &22_i32; + assert_eq!(Foo::test(a), 22); +} diff --git a/src/test/run-pass/where-clause-bounds-inconsistency.rs b/src/test/run-pass/where-clause-bounds-inconsistency.rs new file mode 100644 index 00000000000..a1a61127f68 --- /dev/null +++ b/src/test/run-pass/where-clause-bounds-inconsistency.rs @@ -0,0 +1,28 @@ +// 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. + +trait Bound {} + +trait Trait { + fn a(&self, T) where T: Bound; + fn b(&self, T) where T: Bound; + fn c(&self, T); + fn d(&self, T); +} + +impl Trait for bool { + fn a(&self, _: T) {} + //^~ This gets rejected but should be accepted + fn b(&self, _: T) where T: Bound {} + fn c(&self, _: T) {} + fn d(&self, _: T) where T: Bound {} +} + +fn main() {} 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 00000000000..65882d39375 --- /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 _) + } +}