From ecc0bd26c0fbf70ed7ac57d5752fdf4e8594c3df Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 31 Mar 2016 15:53:12 +0100 Subject: [PATCH 01/14] Fix LLVM assert when handling bad intrinsic monomorphizations --- src/librustc_trans/intrinsic.rs | 6 +-- .../bad-intrinsic-monomorphization.rs | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/test/compile-fail/bad-intrinsic-monomorphization.rs diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 130a864f5e6ec..885656a306b10 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -658,7 +658,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, tcx.sess, span, &format!("invalid monomorphization of `{}` intrinsic: \ expected basic integer type, found `{}`", name, sty)); - C_null(llret_ty) + C_nil(ccx) } } @@ -681,7 +681,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, tcx.sess, span, &format!("invalid monomorphization of `{}` intrinsic: \ expected basic float type, found `{}`", name, sty)); - C_null(llret_ty) + C_nil(ccx) } } @@ -1454,7 +1454,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a> ($cond: expr, $($fmt: tt)*) => { if !$cond { emit_error!($($fmt)*); - return C_null(llret_ty) + return C_nil(bcx.ccx()) } } } diff --git a/src/test/compile-fail/bad-intrinsic-monomorphization.rs b/src/test/compile-fail/bad-intrinsic-monomorphization.rs new file mode 100644 index 0000000000000..5be420a13b2f4 --- /dev/null +++ b/src/test/compile-fail/bad-intrinsic-monomorphization.rs @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics, rustc_attrs, core_intrinsics)] +#![allow(warnings)] + +// Bad monomorphizations could previously cause LLVM asserts even though the +// error was caught in the compiler. + +extern "platform-intrinsic" { + fn simd_add(x: T, y: T) -> T; +} + +use std::intrinsics; + +#[derive(Copy, Clone)] +struct Foo(i64); + +unsafe fn test_cttz(v: Foo) -> Foo { + intrinsics::cttz(v) + //~^ ERROR `cttz` intrinsic: expected basic integer type, found `Foo` +} + +unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo { + intrinsics::fadd_fast(a, b) + //~^ ERROR `fadd_fast` intrinsic: expected basic float type, found `Foo` +} + +unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo { + simd_add(a, b) + //~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` +} + +fn main() {} From 313eb328da6cbf06d17a221898f9e06588e07ce0 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 1 Apr 2016 10:18:41 -0400 Subject: [PATCH 02/14] Address FIXMEs related to short lifetimes in `HashMap`. --- src/libstd/collections/hash/map.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 80b5448800e34..8ce36e814a806 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -428,10 +428,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>, mut val: V) -> &'a mut V { let starting_index = bucket.index(); - let size = { - let table = bucket.table(); // FIXME "lifetime too short". - table.size() - }; + let size = bucket.table().size(); // Save the *starting point*. let mut bucket = bucket.stash(); // There can be at most `size - dib` buckets to displace, because @@ -744,10 +741,9 @@ impl HashMap let h = bucket.hash(); let (b, k, v) = bucket.take(); self.insert_hashed_ordered(h, k, v); - { - let t = b.table(); // FIXME "lifetime too short". - if t.size() == 0 { break } - }; + if b.table().size() == 0 { + break; + } b.into_bucket() } Empty(b) => b.into_bucket() From a2f6d294202764e3d951054b42955c568e3a306b Mon Sep 17 00:00:00 2001 From: Tang Chenglong Date: Sat, 2 Apr 2016 21:03:59 +0800 Subject: [PATCH 03/14] Remove error description of `move` (1) `x` can be used in main() after the call to spawn(). Because the variables follow normal move semantics, though the keyword `move` is used, and i32 implements `Copy`. (2) I remove this sentence because the previous sentence gives the referrence to `move closures`, and more description of `move` may be redundant. --- src/doc/book/concurrency.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/doc/book/concurrency.md b/src/doc/book/concurrency.md index 87d551b68df07..d90b7e3eaf081 100644 --- a/src/doc/book/concurrency.md +++ b/src/doc/book/concurrency.md @@ -127,9 +127,7 @@ thread may outlive the scope of `x`, leading to a dangling pointer. To fix this, we use a `move` closure as mentioned in the error message. `move` closures are explained in depth [here](closures.html#move-closures); basically -they move variables from their environment into themselves. This means that `x` -is now owned by the closure, and cannot be used in `main()` after the call to -`spawn()`. +they move variables from their environment into themselves. ```rust use std::thread; From da4d7f59ad5b79baaec10aa85304e3dd2604d687 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 2 Apr 2016 20:20:52 -0400 Subject: [PATCH 04/14] Indicate `None` is code-like in doc comment. --- src/libstd/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 40f6528f63efb..f67f7e098d345 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -181,7 +181,7 @@ fn _var(key: &OsStr) -> Result { } /// Fetches the environment variable `key` from the current process, returning -/// None if the variable isn't set. +/// `None` if the variable isn't set. /// /// # Examples /// From a09a3acbbd31fe3ea1c11938b6958d87f6096810 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Mon, 4 Apr 2016 20:32:42 +0900 Subject: [PATCH 05/14] Remove outdated comment --- src/librustc_resolve/check_unused.rs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index ea197109cabc4..19a8f9ec5e89a 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -51,16 +51,8 @@ impl<'a, 'b, 'tcx:'b> DerefMut for UnusedImportCheckVisitor<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> { // We have information about whether `use` (import) directives are actually - // used now. If an import is not used at all, we signal a lint error. If an - // import is only used for a single namespace, we remove the other namespace - // from the recorded privacy information. That means in privacy.rs, we will - // only check imports and namespaces which are used. In particular, this - // means that if an import could name either a public or private item, we - // will check the correct thing, dependent on how the import is used. - fn finalize_import(&mut self, id: ast::NodeId, span: Span) { - debug!("finalizing import uses for {:?}", - self.session.codemap().span_to_snippet(span)); - + // used now. If an import is not used at all, we signal a lint error. + fn check_import(&mut self, id: ast::NodeId, span: Span) { if !self.used_imports.contains(&(id, TypeNS)) && !self.used_imports.contains(&(id, ValueNS)) { self.session.add_lint(lint::builtin::UNUSED_IMPORTS, @@ -95,23 +87,16 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> { hir::ItemUse(ref p) => { match p.node { ViewPathSimple(_, _) => { - self.finalize_import(item.id, p.span) + self.check_import(item.id, p.span) } ViewPathList(_, ref list) => { for i in list { - self.finalize_import(i.node.id(), i.span); + self.check_import(i.node.id(), i.span); } } ViewPathGlob(_) => { - if !self.used_imports.contains(&(item.id, TypeNS)) && - !self.used_imports.contains(&(item.id, ValueNS)) { - self.session - .add_lint(lint::builtin::UNUSED_IMPORTS, - item.id, - p.span, - "unused import".to_string()); - } + self.check_import(item.id, p.span) } } } From 2325cab5fe7314b7f577042e73523df4454f2331 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 Apr 2016 17:24:57 +0300 Subject: [PATCH 06/14] minor: update old comments No more lifetimes in function types after https://github.com/rust-lang/rust/commit/f945190e6352a1bc965a117569532643319b400f --- src/libsyntax/parse/parser.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9027a5b107452..4ad46b507438e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1191,12 +1191,12 @@ impl<'a> Parser<'a> { -> PResult<'a, TyKind> { /* - [unsafe] [extern "ABI"] fn <'lt> (S) -> T - ^~~~^ ^~~~^ ^~~~^ ^~^ ^ - | | | | | - | | | | Return type - | | | Argument types - | | Lifetimes + [unsafe] [extern "ABI"] fn (S) -> T + ^~~~^ ^~~~^ ^~^ ^ + | | | | + | | | Return type + | | Argument types + | | | ABI Function Style */ From a44712496379844c30bb8a37c725cd4687d5c395 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 28 Mar 2016 03:25:23 +0530 Subject: [PATCH 07/14] Mention that it's not actually a data race Conflicts: src/doc/book/concurrency.md --- src/doc/book/concurrency.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doc/book/concurrency.md b/src/doc/book/concurrency.md index 87d551b68df07..82d2de7e3bfd5 100644 --- a/src/doc/book/concurrency.md +++ b/src/doc/book/concurrency.md @@ -164,7 +164,7 @@ The same [ownership system](ownership.html) that helps prevent using pointers incorrectly also helps rule out data races, one of the worst kinds of concurrency bugs. -As an example, here is a Rust program that would have a data race in many +As an example, here is a Rust program that could have a data race in many languages. It will not compile: ```ignore @@ -197,6 +197,11 @@ thread, and the thread takes ownership of the reference, we'd have three owners! `data` gets moved out of `main` in the first call to `spawn()`, so subsequent calls in the loop cannot use this variable. +Note that this specific example will not cause a data race since different array +indices are being accessed. But this can't be determined at compile time, and in +a similar situation where `i` is a constant or is random, you would have a data +race. + So, we need some type that lets us have more than one owning reference to a value. Usually, we'd use `Rc` for this, which is a reference counted type that provides shared ownership. It has some runtime bookkeeping that keeps track From cfe25adfe43a96b3ccfe1a05c4f6daee7aad4d5b Mon Sep 17 00:00:00 2001 From: Marcus Klaas Date: Sun, 3 Apr 2016 22:30:21 +0200 Subject: [PATCH 08/14] Fix the span for try shorthand expressions --- src/libsyntax/parse/parser.rs | 2 +- .../compile-fail/symbol-names/issue-32709.rs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/symbol-names/issue-32709.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9027a5b107452..f4a426849652d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2576,7 +2576,7 @@ impl<'a> Parser<'a> { loop { // expr? while self.eat(&token::Question) { - let hi = self.span.hi; + let hi = self.last_span.hi; e = self.mk_expr(lo, hi, ExprKind::Try(e), None); } diff --git a/src/test/compile-fail/symbol-names/issue-32709.rs b/src/test/compile-fail/symbol-names/issue-32709.rs new file mode 100644 index 0000000000000..423e284dc2d1a --- /dev/null +++ b/src/test/compile-fail/symbol-names/issue-32709.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(question_mark)] + +// Make sure that the span of try shorthand does not include the trailing +// semicolon; +fn test() -> Result { + let x = Ok(1); + let y: Option = x?; //~ ERROR 17:26: 17:28 + Ok(1) +} + +fn main() {} From 6fee337b10107e421fee0ca580f0feba224dbb93 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 5 Apr 2016 14:11:08 +0200 Subject: [PATCH 09/14] Add example doc for ToOwned trait --- src/libcollections/borrow.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index 0e92676cf971b..6ca0db68a88ce 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -49,6 +49,18 @@ pub trait ToOwned { type Owned: Borrow; /// Creates owned data from borrowed data, usually by cloning. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let s = "a"; // &str + /// let ss = s.to_owned(); // String + /// + /// let v = &[1, 2]; // slice + /// let vv = v.to_owned(); // Vec + /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn to_owned(&self) -> Self::Owned; } From 8f463ea98e1ce5763b2ecfb4480bc7cce83125ac Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Tue, 5 Apr 2016 17:55:14 +0200 Subject: [PATCH 10/14] doc: make env::consts summaries less confusing --- src/libstd/env.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index fa48efb27881b..cd541e63fb7e9 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -618,7 +618,7 @@ pub mod consts { #[stable(feature = "env", since = "1.0.0")] pub const ARCH: &'static str = super::arch::ARCH; - /// The family of the operating system. In this case, `unix`. + /// The family of the operating system. Example value is `unix`. /// /// Some possible values: /// @@ -627,8 +627,8 @@ pub mod consts { #[stable(feature = "env", since = "1.0.0")] pub const FAMILY: &'static str = super::os::FAMILY; - /// A string describing the specific operating system in use: in this - /// case, `linux`. + /// A string describing the specific operating system in use. + /// Example value is `linux`. /// /// Some possible values: /// @@ -647,7 +647,7 @@ pub mod consts { pub const OS: &'static str = super::os::OS; /// Specifies the filename prefix used for shared libraries on this - /// platform: in this case, `lib`. + /// platform. Example value is `lib`. /// /// Some possible values: /// @@ -657,7 +657,7 @@ pub mod consts { pub const DLL_PREFIX: &'static str = super::os::DLL_PREFIX; /// Specifies the filename suffix used for shared libraries on this - /// platform: in this case, `.so`. + /// platform. Example value is `.so`. /// /// Some possible values: /// @@ -668,7 +668,7 @@ pub mod consts { pub const DLL_SUFFIX: &'static str = super::os::DLL_SUFFIX; /// Specifies the file extension used for shared libraries on this - /// platform that goes after the dot: in this case, `so`. + /// platform that goes after the dot. Example value is `so`. /// /// Some possible values: /// @@ -679,7 +679,7 @@ pub mod consts { pub const DLL_EXTENSION: &'static str = super::os::DLL_EXTENSION; /// Specifies the filename suffix used for executable binaries on this - /// platform: in this case, the empty string. + /// platform. Example value is `.exe`. /// /// Some possible values: /// @@ -691,7 +691,7 @@ pub mod consts { pub const EXE_SUFFIX: &'static str = super::os::EXE_SUFFIX; /// Specifies the file extension, if any, used for executable binaries - /// on this platform: in this case, the empty string. + /// on this platform. Example value is `exe`. /// /// Some possible values: /// From d841c157046d4b686a8ffb614db8f9d700d21134 Mon Sep 17 00:00:00 2001 From: Varun Vats Date: Wed, 30 Mar 2016 21:05:12 -0500 Subject: [PATCH 11/14] Doc fix: function takes argument by reference. --- src/doc/book/lifetimes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md index e7a4045d9b249..695b1614fb70c 100644 --- a/src/doc/book/lifetimes.md +++ b/src/doc/book/lifetimes.md @@ -56,8 +56,8 @@ To fix this, we have to make sure that step four never happens after step three. The ownership system in Rust does this through a concept called lifetimes, which describe the scope that a reference is valid for. -When we have a function that takes a reference by argument, we can be implicit -or explicit about the lifetime of the reference: +When we have a function that takes an argument by reference, we can be +implicit or explicit about the lifetime of the reference: ```rust // implicit From a7d15ce6a647670ca555b12f0f3b45b0c939fe66 Mon Sep 17 00:00:00 2001 From: Varun Vats Date: Wed, 30 Mar 2016 21:11:06 -0500 Subject: [PATCH 12/14] Doc fix: list all module files Rust looks for. 1. In the English/Japanese phrases example in the "Multiple File Crates" section of the "Crates and Modules" chapter, there are a total of 8 module files that Rust looks for, while only four were listed. This commit lists all 8 explicitly. 2. Title case fix. --- src/doc/book/crates-and-modules.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/doc/book/crates-and-modules.md b/src/doc/book/crates-and-modules.md index 0c9ed0bf12281..b3ccefe0a6b43 100644 --- a/src/doc/book/crates-and-modules.md +++ b/src/doc/book/crates-and-modules.md @@ -118,7 +118,7 @@ build deps examples libphrases-a7448e02a0468eaa.rlib native `libphrases-hash.rlib` is the compiled crate. Before we see how to use this crate from another crate, let’s break it up into multiple files. -# Multiple file crates +# Multiple File Crates If each crate were just one file, these files would get very large. It’s often easier to split up crates into multiple files, and Rust supports this in two @@ -190,13 +190,19 @@ mod farewells; ``` Again, these declarations tell Rust to look for either -`src/english/greetings.rs` and `src/japanese/greetings.rs` or -`src/english/farewells/mod.rs` and `src/japanese/farewells/mod.rs`. Because -these sub-modules don’t have their own sub-modules, we’ve chosen to make them -`src/english/greetings.rs` and `src/japanese/farewells.rs`. Whew! - -The contents of `src/english/greetings.rs` and `src/japanese/farewells.rs` are -both empty at the moment. Let’s add some functions. +`src/english/greetings.rs`, `src/english/farewells.rs`, +`src/japanese/greetings.rs` and `src/japanese/farewells.rs` or +`src/english/greetings/mod.rs`, `src/english/farewells/mod.rs`, +`src/japanese/greetings/mod.rs` and +`src/japanese/farewells/mod.rs`. Because these sub-modules don’t have +their own sub-modules, we’ve chosen to make them +`src/english/greetings.rs`, `src/english/farewells.rs`, +`src/japanese/greetings.rs` and `src/japanese/farewells.rs`. Whew! + +The contents of `src/english/greetings.rs`, +`src/english/farewells.rs`, `src/japanese/greetings.rs` and +`src/japanese/farewells.rs` are all empty at the moment. Let’s add +some functions. Put this in `src/english/greetings.rs`: From 922e666820fef2f5d9bd7fa450b4a45d85fdd84a Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 6 Apr 2016 06:24:19 +0200 Subject: [PATCH 13/14] avoid "==" in assert! when one of the values is a bool --- src/libcore/ptr.rs | 4 ++-- src/libstd/fs.rs | 2 +- src/libtest/lib.rs | 2 +- .../specialization-cross-crate-defaults.rs | 10 +++++----- .../specialization/specialization-default-methods.rs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 37e9d18095f82..42aef3ab3dd75 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -220,7 +220,7 @@ impl *const T { /// ``` /// let s: &str = "Follow the rabbit"; /// let ptr: *const u8 = s.as_ptr(); - /// assert!(ptr.is_null() == false); + /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -306,7 +306,7 @@ impl *mut T { /// ``` /// let mut s = [1, 2, 3]; /// let ptr: *mut u32 = s.as_mut_ptr(); - /// assert!(ptr.is_null() == false); + /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index d8af73816c9c0..c4d6cb33365d0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1708,7 +1708,7 @@ mod tests { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); check!(fs::create_dir(dir)); - assert!(dir.is_file() == false); + assert!(!dir.is_file()); check!(fs::remove_dir(dir)); } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index e7fe128a7ae8d..e78fd0dea292a 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1509,7 +1509,7 @@ mod tests { assert_eq!(filtered.len(), 1); assert_eq!(filtered[0].desc.name.to_string(), "1"); - assert!(filtered[0].desc.ignore == false); + assert!(!filtered[0].desc.ignore); } #[test] diff --git a/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs b/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs index bc695ea821d0a..62c7e3e2e4431 100644 --- a/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs +++ b/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs @@ -26,12 +26,12 @@ impl Foo for LocalOverride { } fn test_foo() { - assert!(0i8.foo() == false); - assert!(0i32.foo() == false); - assert!(0i64.foo() == true); + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); - assert!(LocalDefault.foo() == false); - assert!(LocalOverride.foo() == true); + assert!(!LocalDefault.foo()); + assert!(LocalOverride.foo()); } fn test_bar() { diff --git a/src/test/run-pass/specialization/specialization-default-methods.rs b/src/test/run-pass/specialization/specialization-default-methods.rs index 3f0f21ff03f27..9cfc6aabbb4f2 100644 --- a/src/test/run-pass/specialization/specialization-default-methods.rs +++ b/src/test/run-pass/specialization/specialization-default-methods.rs @@ -35,9 +35,9 @@ impl Foo for i64 { } fn test_foo() { - assert!(0i8.foo() == false); - assert!(0i32.foo() == false); - assert!(0i64.foo() == true); + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); } // Next, test mixture of explicit `default` and provided methods: From b27b3e12788cee1a36ccd42c0fcf2413caca6a00 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 6 Apr 2016 05:37:08 -0400 Subject: [PATCH 14/14] change constant patterns to have a warning cycle This was the original intention :( --- src/librustc/lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 1573d0c4292ac..2564838c67d65 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -144,7 +144,7 @@ declare_lint! { declare_lint! { pub ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN, - Deny, + Warn, "constants of struct or enum type can only be used in a pattern if \ the struct or enum has `#[derive(PartialEq, Eq)]`" }