From 00211ecfda53521ea6b6405beff1c490b04f3ce5 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 12 Mar 2015 19:24:59 -0700 Subject: [PATCH 01/10] Avoid passing -L "" during cross-compilation. LLVM_LIBDIR_ is only defined for host triples, not target triples. FWIW, the same is true for LLVM_STDCPP_RUSTFLAGS_, where we explicitly define it as empty when --enable-llvm-static-stdcpp is not specified, but it's still undefined for cross-compiled triples. --- mk/main.mk | 1 + mk/target.mk | 2 +- mk/tests.mk | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mk/main.mk b/mk/main.mk index ad9d0d0ca5e77..b9f2cf1cce89c 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -290,6 +290,7 @@ LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version) LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir) LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir) LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir) +LLVM_LIBDIR_RUSTFLAGS_$(1)=-L "$$(LLVM_LIBDIR_$(1))" LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS)) LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags) # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM), diff --git a/mk/target.mk b/mk/target.mk index 4182ec81a7e6c..0a41f363649db 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -84,7 +84,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \ $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \ $$(RUST_LIB_FLAGS_ST$(1)) \ -L "$$(RT_OUTPUT_DIR_$(2))" \ - -L "$$(LLVM_LIBDIR_$(2))" \ + $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \ $$(LLVM_STDCPP_RUSTFLAGS_$(2)) \ $$(RUSTFLAGS_$(4)) \ --out-dir $$(@D) \ diff --git a/mk/tests.mk b/mk/tests.mk index 78f5ac11f06a7..48e50e47d4d1a 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -372,7 +372,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \ $(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \ $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \ -L "$$(RT_OUTPUT_DIR_$(2))" \ - -L "$$(LLVM_LIBDIR_$(2))" \ + $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \ $$(RUSTFLAGS_$(4)) endef From 60aa7516209f50eff7fd879fc2b0e6c5d5ebb8aa Mon Sep 17 00:00:00 2001 From: York Xiang Date: Sat, 14 Mar 2015 13:40:33 +0800 Subject: [PATCH 02/10] Improve camelcase suggestion --- src/librustc_lint/builtin.rs | 2 +- src/test/compile-fail/lint-non-camel-case-types.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 074591fb927d2..f6f82c65374bd 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -811,7 +811,7 @@ impl NonCamelCaseTypes { if i == 0 { c.to_uppercase().collect::() } else { - c.to_string() + c.to_lowercase().collect() } )).collect::>().concat() } diff --git a/src/test/compile-fail/lint-non-camel-case-types.rs b/src/test/compile-fail/lint-non-camel-case-types.rs index 9f58d5791cb0b..f6d3d62d0bf75 100644 --- a/src/test/compile-fail/lint-non-camel-case-types.rs +++ b/src/test/compile-fail/lint-non-camel-case-types.rs @@ -11,6 +11,9 @@ #![forbid(non_camel_case_types)] #![allow(dead_code)] +struct ONE_TWO_THREE; +//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree` + struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo` bar: isize, } From 85b084f4bd5c61adf23ca0de08cfba3d23ef1cfc Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 13 Mar 2015 23:49:44 -0700 Subject: [PATCH 03/10] Reject `-L ""`, `-L native=`, and other empty search paths. It wasn't clear to me that early_error was correct here, but it seems to work. This code is reachable from `rustdoc`, which is problematic, because early_error panics. rustc handles the panics gracefully (without ICEing or crashing), but rustdoc does not. It's not the first such rustdoc problem, though: $ rustdoc hello.rs --extern std=bad-std error: extern location for std does not exist: bad-std hello.rs:1:1: 1:1 error: can't find crate for `std` hello.rs:1 ^ error: aborting due to 2 previous errors thread '' panicked at 'Box', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:151 thread '' panicked at 'called `Result::unwrap()` on an `Err` value: "rustc failed"', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:744 thread '
' panicked at 'child thread None panicked', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread.rs:661 --- src/librustc/session/search_paths.rs | 4 ++++ .../compile-fail/manual-link-bad-search-path.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/test/compile-fail/manual-link-bad-search-path.rs diff --git a/src/librustc/session/search_paths.rs b/src/librustc/session/search_paths.rs index f85fb3039102e..3c5d97445058b 100644 --- a/src/librustc/session/search_paths.rs +++ b/src/librustc/session/search_paths.rs @@ -10,6 +10,7 @@ use std::slice; use std::path::{Path, PathBuf}; +use session::early_error; #[derive(Clone, Debug)] pub struct SearchPaths { @@ -50,6 +51,9 @@ impl SearchPaths { } else { (PathKind::All, path) }; + if path.is_empty() { + early_error("empty search path given via `-L`"); + } self.paths.push((kind, PathBuf::new(path))); } diff --git a/src/test/compile-fail/manual-link-bad-search-path.rs b/src/test/compile-fail/manual-link-bad-search-path.rs new file mode 100644 index 0000000000000..2bf61cbe24ca3 --- /dev/null +++ b/src/test/compile-fail/manual-link-bad-search-path.rs @@ -0,0 +1,15 @@ +// 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. + +// compile-flags:-L native= +// error-pattern: empty search path given via `-L` + +fn main() { +} From b09e5daa89b6dbfe93b9db7a66b670ca6d1b5f4a Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 14 Mar 2015 00:45:39 +0200 Subject: [PATCH 04/10] Split rustdoc summary lines in a smarter way Previously it would fail on a trivial case like /// Summary line /// /// Regular content Compliant markdown preprocessor would render that as two separate paragraphs, but our summary line extractor would interpret both lines as the same paragraph and include both into the short summary. --- src/librustdoc/html/render.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index dba7b16eceecb..85c04d76394a5 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -407,7 +407,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result { ty: shortty(item), name: item.name.clone().unwrap(), path: fqp[..fqp.len() - 1].connect("::"), - desc: shorter(item.doc_value()).to_string(), + desc: shorter(item.doc_value()), parent: Some(did), }); }, @@ -876,7 +876,7 @@ impl DocFolder for Cache { ty: shortty(&item), name: s.to_string(), path: path.connect("::").to_string(), - desc: shorter(item.doc_value()).to_string(), + desc: shorter(item.doc_value()), parent: parent, }); } @@ -1467,13 +1467,14 @@ fn full_path(cx: &Context, item: &clean::Item) -> String { return s } -fn shorter<'a>(s: Option<&'a str>) -> &'a str { +fn shorter<'a>(s: Option<&'a str>) -> String { match s { - Some(s) => match s.find("\n\n") { - Some(pos) => &s[..pos], - None => s, - }, - None => "" + Some(s) => s.lines().take_while(|line|{ + (*line).chars().any(|chr|{ + !chr.is_whitespace() + }) + }).collect::>().connect("\n"), + None => "".to_string() } } @@ -1603,7 +1604,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, ", *myitem.name.as_ref().unwrap(), - Markdown(shorter(myitem.doc_value())), + Markdown(&shorter(myitem.doc_value())[..]), class = shortty(myitem), href = item_path(myitem), title = full_path(cx, myitem), From bb18a3cfe7554143622af4911028605e89c80104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 14 Mar 2015 13:14:04 +0100 Subject: [PATCH 05/10] Drop support for LLVM < 3.5 and fix compile errors with 3.5 LLVM older that 3.6 has a bug that cause assertions when compiling certain constructs. For 3.5 there's still a chance that the bug might get fixed in 3.5.2, so let's keep allowing to compile with it for it for now. --- configure | 4 +- src/rustllvm/RustWrapper.cpp | 120 ++++------------------------------- 2 files changed, 14 insertions(+), 110 deletions(-) diff --git a/configure b/configure index 73e09158539aa..760203ae5cf4e 100755 --- a/configure +++ b/configure @@ -823,11 +823,11 @@ then LLVM_VERSION=$($LLVM_CONFIG --version) case $LLVM_VERSION in - (3.[2-6]*) + (3.[5-6]*) msg "found ok version of LLVM: $LLVM_VERSION" ;; (*) - err "bad LLVM version: $LLVM_VERSION, need >=3.0svn" + err "bad LLVM version: $LLVM_VERSION, need >=3.5" ;; esac fi diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index aaf6d8df29cad..9a87c03f1c407 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -14,11 +14,7 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" -#if LLVM_VERSION_MINOR >= 5 #include "llvm/IR/CallSite.h" -#else -#include "llvm/Support/CallSite.h" -#endif //===----------------------------------------------------------------------=== // @@ -33,7 +29,6 @@ using namespace llvm::object; static char *LastError; -#if LLVM_VERSION_MINOR >= 5 extern "C" LLVMMemoryBufferRef LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) { ErrorOr> buf_or = MemoryBuffer::getFile(Path, @@ -45,18 +40,6 @@ LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) { } return wrap(buf_or.get().release()); } -#else -extern "C" LLVMMemoryBufferRef -LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) { - OwningPtr buf; - error_code err = MemoryBuffer::getFile(Path, buf, -1, false); - if (err) { - LLVMRustSetLastError(err.message().c_str()); - return NULL; - } - return wrap(buf.take()); -} -#endif extern "C" char *LLVMRustGetLastError(void) { char *ret = LastError; @@ -116,7 +99,6 @@ extern "C" void LLVMAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, uin } -#if LLVM_VERSION_MINOR >= 5 extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned idx, uint64_t b) { CallSite Call = CallSite(unwrap(Instr)); AttrBuilder B; @@ -126,9 +108,6 @@ extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned AttributeSet::get(Call->getContext(), idx, B))); } -#else -extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef, unsigned, uint64_t) {} -#endif extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index, uint64_t Val) { Function *A = unwrap(Fn); @@ -137,16 +116,12 @@ extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index, uint64 A->addAttributes(index, AttributeSet::get(A->getContext(), index, B)); } -#if LLVM_VERSION_MINOR >= 5 extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef Fn, unsigned index, uint64_t bytes) { Function *A = unwrap(Fn); AttrBuilder B; B.addDereferenceableAttr(bytes); A->addAttributes(index, AttributeSet::get(A->getContext(), index, B)); } -#else -extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef, unsigned, uint64_t) {} -#endif extern "C" void LLVMAddFunctionAttrString(LLVMValueRef Fn, unsigned index, const char *Name) { Function *F = unwrap(Fn); @@ -199,10 +174,8 @@ extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, AtomicOrdering order, AtomicOrdering failure_order) { return wrap(unwrap(B)->CreateAtomicCmpXchg(unwrap(target), unwrap(old), - unwrap(source), order -#if LLVM_VERSION_MINOR >= 5 - , failure_order -#endif + unwrap(source), order, + failure_order )); } extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B, AtomicOrdering order) { @@ -247,11 +220,7 @@ DIT unwrapDI(LLVMMetadataRef ref) { return DIT(ref ? unwrap(ref) : NULL); } -#if LLVM_VERSION_MINOR >= 5 extern "C" const uint32_t LLVMRustDebugMetadataVersion = DEBUG_METADATA_VERSION; -#else -extern "C" const uint32_t LLVMRustDebugMetadataVersion = 1; -#endif extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M, const char *name, @@ -383,10 +352,8 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType( unwrapDI(DerivedFrom), unwrapDI(Elements), RunTimeLang, - unwrapDI(VTableHolder) -#if LLVM_VERSION_MINOR >= 4 - ,UniqueId -#endif + unwrapDI(VTableHolder), + UniqueId )); } @@ -465,8 +432,8 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable( #if LLVM_VERSION_MINOR < 6 if (AddrOpsCount > 0) { SmallVector addr_ops; - llvm::Type *Int64Ty = Type::getInt64Ty(VMContext); - for (int i = 0; i < AddrOpsCount; ++i) + llvm::Type *Int64Ty = Type::getInt64Ty(unwrap(Scope)->getContext()); + for (unsigned i = 0; i < AddrOpsCount; ++i) addr_ops.push_back(ConstantInt::get(Int64Ty, AddrOps[i])); return wrap(Builder->createComplexVariable( @@ -522,7 +489,11 @@ extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray( LLVMMetadataRef* Ptr, unsigned Count) { return wrap(Builder->getOrCreateArray( +#if LLVM_VERSION_MINOR >= 6 ArrayRef(unwrap(Ptr), Count))); +#else + ArrayRef(reinterpret_cast(Ptr), Count))); +#endif } extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( @@ -627,19 +598,11 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType( AlignInBits, Flags, unwrapDI(Elements), - RunTimeLang -#if LLVM_VERSION_MINOR >= 4 - ,UniqueId -#endif + RunTimeLang, + UniqueId )); } -#if LLVM_VERSION_MINOR < 5 -extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) { - unwrap(Value)->setUnnamedAddr(Unnamed); -} -#endif - extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter( DIBuilderRef Builder, LLVMMetadataRef Scope, @@ -730,7 +693,6 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) { os << ")"; } -#if LLVM_VERSION_MINOR >= 5 extern "C" bool LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { Module *Dst = unwrap(dst); @@ -763,28 +725,7 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { } return true; } -#else -extern "C" bool -LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { - Module *Dst = unwrap(dst); - MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len)); - std::string Err; - Module *Src = llvm::getLazyBitcodeModule(buf, Dst->getContext(), &Err); - if (!Src) { - LLVMRustSetLastError(Err.c_str()); - delete buf; - return false; - } - - if (Linker::LinkModules(Dst, Src, Linker::DestroySource, &Err)) { - LLVMRustSetLastError(Err.c_str()); - return false; - } - return true; -} -#endif -#if LLVM_VERSION_MINOR >= 5 extern "C" void* LLVMRustOpenArchive(char *path) { ErrorOr> buf_or = MemoryBuffer::getFile(path, @@ -817,23 +758,6 @@ LLVMRustOpenArchive(char *path) { return ret; } -#else -extern "C" void* -LLVMRustOpenArchive(char *path) { - OwningPtr buf; - error_code err = MemoryBuffer::getFile(path, buf, -1, false); - if (err) { - LLVMRustSetLastError(err.message().c_str()); - return NULL; - } - Archive *ret = new Archive(buf.take(), err); - if (err) { - LLVMRustSetLastError(err.message().c_str()); - return NULL; - } - return ret; -} -#endif extern "C" const char* #if LLVM_VERSION_MINOR >= 6 @@ -844,21 +768,12 @@ LLVMRustArchiveReadSection(OwningBinary *ob, char *name, size_t *size) LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) { #endif -#if LLVM_VERSION_MINOR >= 5 Archive::child_iterator child = ar->child_begin(), end = ar->child_end(); for (; child != end; ++child) { ErrorOr name_or_err = child->getName(); if (name_or_err.getError()) continue; StringRef sect_name = name_or_err.get(); -#else - Archive::child_iterator child = ar->begin_children(), - end = ar->end_children(); - for (; child != end; ++child) { - StringRef sect_name; - error_code err = child->getName(sect_name); - if (err) continue; -#endif if (sect_name.trim(" ") == name) { StringRef buf = child->getBuffer(); *size = buf.size(); @@ -877,18 +792,11 @@ LLVMRustDestroyArchive(Archive *ar) { delete ar; } -#if LLVM_VERSION_MINOR >= 5 extern "C" void LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) { GlobalValue *V = unwrap(Value); V->setDLLStorageClass(GlobalValue::DLLExportStorageClass); } -#else -extern "C" void -LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) { - LLVMSetLinkage(Value, LLVMDLLExportLinkage); -} -#endif extern "C" int LLVMVersionMinor() { @@ -918,11 +826,7 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { extern "C" int LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) { StringRef ret; -#if LLVM_VERSION_MINOR >= 5 if (std::error_code ec = (*unwrap(SI))->getName(ret)) -#else - if (error_code ec = (*unwrap(SI))->getName(ret)) -#endif report_fatal_error(ec.message()); *ptr = ret.data(); return ret.size(); From cb02f366dca49d1147ded5c2c0d31b56af22e5b2 Mon Sep 17 00:00:00 2001 From: Ricardo Martins Date: Sat, 14 Mar 2015 12:42:12 +0000 Subject: [PATCH 06/10] Fix a typo in the documentation. --- src/doc/trpl/concurrency.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/concurrency.md b/src/doc/trpl/concurrency.md index 9b6d6ca67f6c8..4a16db63950dd 100644 --- a/src/doc/trpl/concurrency.md +++ b/src/doc/trpl/concurrency.md @@ -339,7 +339,7 @@ fn main() { }); } - rx.recv().ok().expect("Could not recieve answer"); + rx.recv().ok().expect("Could not receive answer"); } ``` From 3a8f989dbb7df27f78874d5afbc579cb420159d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 14 Mar 2015 14:19:29 +0100 Subject: [PATCH 07/10] Always evaluate the expression in [expr; n] In case that there is a destination for the array, like in "let x = [expr; n]", we currently don't evaluate the given expression if n is zero. That's inconsistent with all other cases, including "[expr; 0]" without a destination. Fixes #23354 --- src/librustc_trans/trans/tvec.rs | 2 +- src/test/run-fail/issue-23354.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/run-fail/issue-23354.rs diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index a5c3923336ae8..6ed45211084e3 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -293,7 +293,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } SaveIn(lldest) => { match ty::eval_repeat_count(bcx.tcx(), &**count_expr) { - 0 => bcx, + 0 => expr::trans_into(bcx, &**element, Ignore), 1 => expr::trans_into(bcx, &**element, SaveIn(lldest)), count => { let elem = unpack_datum!(bcx, expr::trans(bcx, &**element)); diff --git a/src/test/run-fail/issue-23354.rs b/src/test/run-fail/issue-23354.rs new file mode 100644 index 0000000000000..f6b937c82595b --- /dev/null +++ b/src/test/run-fail/issue-23354.rs @@ -0,0 +1,16 @@ +// 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. + +// error-pattern:panic evaluated + +#[allow(unused_variables)] +fn main() { + let x = [panic!("panic evaluated"); 0]; +} From 9eed8ea644c18e81079be240684b41dd0cf00b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 14 Mar 2015 14:21:43 +0100 Subject: [PATCH 08/10] Fix broken codegen for [expr; n] where "expr" diverges --- src/librustc_trans/trans/tvec.rs | 6 +++++- src/test/run-fail/issue-23354-2.rs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/run-fail/issue-23354-2.rs diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 6ed45211084e3..2fd79c1ddb48d 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -410,8 +410,12 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>, { let _icx = push_ctxt("tvec::iter_vec_loop"); - let fcx = bcx.fcx; + if bcx.unreachable.get() { + return bcx; + } + + let fcx = bcx.fcx; let loop_bcx = fcx.new_temp_block("expr_repeat"); let next_bcx = fcx.new_temp_block("expr_repeat: next"); diff --git a/src/test/run-fail/issue-23354-2.rs b/src/test/run-fail/issue-23354-2.rs new file mode 100644 index 0000000000000..b120d3222fa21 --- /dev/null +++ b/src/test/run-fail/issue-23354-2.rs @@ -0,0 +1,17 @@ +// 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. + +// error-pattern:panic evaluated + +#[allow(unused_variables)] +fn main() { + // This used to trigger an LLVM assertion during compilation + let x = [panic!("panic evaluated"); 2]; +} From c8e4f61ad364e97614d095d5ac3beb2319e9a850 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Sat, 14 Mar 2015 13:27:44 -0600 Subject: [PATCH 09/10] Fix indentation in the "Method Syntax" chapter --- src/doc/trpl/method-syntax.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md index 0625d649e3086..59be8c6704fd4 100644 --- a/src/doc/trpl/method-syntax.md +++ b/src/doc/trpl/method-syntax.md @@ -187,13 +187,13 @@ impl CircleBuilder { } fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder { - self.coordinate = coordinate; - self + self.coordinate = coordinate; + self } fn radius(&mut self, radius: f64) -> &mut CircleBuilder { - self.radius = radius; - self + self.radius = radius; + self } fn finalize(&self) -> Circle { From 7130c75e4612f9c91652e4472a66fe7573224df8 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Sat, 14 Mar 2015 14:05:59 -0600 Subject: [PATCH 10/10] Concurrency is now in the "Concurrency" chapter --- src/doc/trpl/closures.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/closures.md b/src/doc/trpl/closures.md index 8cc6be7387ca1..bf4c2d903570b 100644 --- a/src/doc/trpl/closures.md +++ b/src/doc/trpl/closures.md @@ -68,7 +68,7 @@ is that a moving closure always takes ownership of all variables that it uses. Ordinary closures, in contrast, just create a reference into the enclosing stack frame. Moving closures are most useful with Rust's concurrency features, and so we'll just leave it at this for -now. We'll talk about them more in the "Threads" section of the guide. +now. We'll talk about them more in the "Concurrency" chapter of the book. ## Accepting closures as arguments