From 94ee40a5d46567c9ff45511fb4d9dd5c78a4e794 Mon Sep 17 00:00:00 2001 From: Tang Chenglong Date: Wed, 16 Mar 2016 00:15:40 +0800 Subject: [PATCH 01/16] FreeBSD has already supported Cargo Both Packages and Ports of FreeBSD have Cargo in present. --- src/doc/book/getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index ca83f2226c048..539fdd32c6b9a 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -93,8 +93,8 @@ unofficial locations. | `armv7-apple-ios` | ✓ | | | ARM iOS | | `armv7s-apple-ios` | ✓ | | | ARM iOS | | `aarch64-apple-ios` | ✓ | | | ARM64 iOS | -| `i686-unknown-freebsd` | ✓ | ✓ | | 32-bit FreeBSD | -| `x86_64-unknown-freebsd` | ✓ | ✓ | | 64-bit FreeBSD | +| `i686-unknown-freebsd` | ✓ | ✓ | ✓ | 32-bit FreeBSD | +| `x86_64-unknown-freebsd` | ✓ | ✓ | ✓ | 64-bit FreeBSD | | `x86_64-unknown-openbsd` | ✓ | ✓ | | 64-bit OpenBSD | | `x86_64-unknown-netbsd` | ✓ | ✓ | | 64-bit NetBSD | | `x86_64-unknown-bitrig` | ✓ | ✓ | | 64-bit Bitrig | From 178b28099fa542430a8e9491e23053a162aedcb9 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 15 Mar 2016 19:50:11 +0100 Subject: [PATCH 02/16] syntax: impl ToTokens for P --- src/libsyntax/ext/quote.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 38da478b5edaf..77aeaf8459aec 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -121,6 +121,12 @@ pub mod rt { } } + impl ToTokens for P { + fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { + vec![TokenTree::Token(self.span, token::Interpolated(token::NtImplItem(self.clone())))] + } + } + impl ToTokens for ast::TraitItem { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { vec![TokenTree::Token(self.span, From 6ed7846257af7c2da9d2164916eb8fe150b50ec2 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 15 Mar 2016 16:33:59 -0400 Subject: [PATCH 03/16] Add comment about opt-in nature of compiletest note/help messages. The opt-in functionality was proposed and discussed in https://github.com/rust-lang/rust/issues/21195 --- src/compiletest/runtest.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 8c3ee3fb5f4b6..dbb5703978a75 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1009,6 +1009,10 @@ fn check_expected_errors(revision: Option<&str>, expected.replace(r"\", "/") }).collect::>(); + // If the testcase being checked contains at least one expected "help" + // message, then we'll ensure that all "help" messages are expected. + // Otherwise, all "help" messages reported by the compiler will be ignored. + // This logic also applies to "note" messages. let (expect_help, expect_note) = expected_errors.iter() .fold((false, false), From 01d76099f261abe50342d9261fad618c5323274b Mon Sep 17 00:00:00 2001 From: Tang Chenglong Date: Wed, 16 Mar 2016 23:45:28 +0800 Subject: [PATCH 04/16] docs: One typo I think it's a mistake of spelling. --- src/doc/book/guessing-game.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/guessing-game.md b/src/doc/book/guessing-game.md index e071bfdf8bce1..590c7e848190a 100644 --- a/src/doc/book/guessing-game.md +++ b/src/doc/book/guessing-game.md @@ -912,7 +912,7 @@ returned by `parse()`, this is an `enum` like `Ordering`, but in this case, each variant has some data associated with it: `Ok` is a success, and `Err` is a failure. Each contains more information: the successfully parsed integer, or an error type. In this case, we `match` on `Ok(num)`, which sets the name `num` to -the unwrapped `Ok` value (ythe integer), and then we return it on the +the unwrapped `Ok` value (the integer), and then we return it on the right-hand side. In the `Err` case, we don’t care what kind of error it is, so we just use the catch all `_` instead of a name. This catches everything that isn't `Ok`, and `continue` lets us move to the next iteration of the loop; in From 2910c0020661304df237fb8ed646296304c8e0d2 Mon Sep 17 00:00:00 2001 From: York Xiang Date: Fri, 18 Mar 2016 00:49:15 +0900 Subject: [PATCH 05/16] Fix usability problem when browse document locally --- src/librustdoc/html/static/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f3efbcb1db308..8fb58f58e8a5f 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -740,7 +740,11 @@ $(".search-input").on("keyup input",function() { clearTimeout(searchTimeout); if ($(this).val().length === 0) { - window.history.replaceState("", "std - Rust", "?search="); + if (browserSupportsHistoryApi()) { + history.replaceState("", "std - Rust", "?search="); + } else { + location.replace("?search="); + } $('#main.content').removeClass('hidden'); $('#search.content').addClass('hidden'); } else { @@ -996,7 +1000,7 @@ var prev_id = 0; function set_fragment(name) { - if (history.replaceState) { + if (browserSupportsHistoryApi()) { history.replaceState(null, null, '#' + name); $(window).trigger('hashchange'); } else { From 79244c3a6b4478e1561a1dfa1aff035650aff3ad Mon Sep 17 00:00:00 2001 From: Tang Chenglong Date: Fri, 18 Mar 2016 01:17:19 +0800 Subject: [PATCH 06/16] `let` introduces a statement I changes *expression* to *statement* to make more accurate, because in Rust, `let` introduces a declaration statement. --- src/doc/book/variable-bindings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/book/variable-bindings.md b/src/doc/book/variable-bindings.md index 29b59937a63fa..1c8c03cf67937 100644 --- a/src/doc/book/variable-bindings.md +++ b/src/doc/book/variable-bindings.md @@ -18,14 +18,14 @@ function, rather than leaving it off. Otherwise, you’ll get an error. In many languages, a variable binding would be called a *variable*, but Rust’s variable bindings have a few tricks up their sleeves. For example the -left-hand side of a `let` expression is a ‘[pattern][pattern]’, not a +left-hand side of a `let` statement is a ‘[pattern][pattern]’, not a variable name. This means we can do things like: ```rust let (x, y) = (1, 2); ``` -After this expression is evaluated, `x` will be one, and `y` will be two. +After this statement is evaluated, `x` will be one, and `y` will be two. Patterns are really powerful, and have [their own section][pattern] in the book. We don’t need those features for now, so we’ll keep this in the back of our minds as we go forward. From a6e077ebdfe55741e69375de3f22e964b678c22b Mon Sep 17 00:00:00 2001 From: Katze Date: Thu, 17 Mar 2016 20:15:22 +0100 Subject: [PATCH 07/16] documentation fix in RELEASES.md f32 should probably be denoted as 0.0 as it might improve readability. Signed-off-by: benaryorg --- RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 97edaa122eff9..a5e307ac0d018 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -116,8 +116,8 @@ Compatibility Notes that were not intended. In this release, [defaulted type parameters appearing outside of type definitions will generate a warning][1.7d], which will become an error in future releases. -* [Parsing "." as a float results in an error instead of - 0][1.7p]. That is, `".".parse::()` returns `Err`, not `Ok(0)`. +* [Parsing "." as a float results in an error instead of 0][1.7p]. + That is, `".".parse::()` returns `Err`, not `Ok(0.0)`. * [Borrows of closure parameters may not outlive the closure][1.7bc]. [1.7a]: https://github.com/rust-lang/rust/pull/30928 From d7f80ca2c731cb0e1b00c7dc772b03753e16150a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Mar 2016 13:58:26 -0700 Subject: [PATCH 08/16] rustbuild: Fix cross to netbsd from Linux Apparently the NetBSD compiler-rt builds into the linux directory as well. I'm... detecting a trend! --- src/bootstrap/build/native.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/build/native.rs b/src/bootstrap/build/native.rs index 52595d3638c27..b3bd6b9229965 100644 --- a/src/bootstrap/build/native.rs +++ b/src/bootstrap/build/native.rs @@ -114,7 +114,8 @@ pub fn compiler_rt(build: &Build, target: &str) { let arch = target.split('-').next().unwrap(); let mode = if build.config.rust_optimize {"Release"} else {"Debug"}; let (dir, build_target, libname) = if target.contains("linux") || - target.contains("freebsd") { + target.contains("freebsd") || + target.contains("netbsd") { let os = if target.contains("android") {"-android"} else {""}; let arch = if arch.starts_with("arm") && target.contains("eabihf") { "armhf" From 667d1c67e28fbeb6bd208161d84f81df69119989 Mon Sep 17 00:00:00 2001 From: Todd Lucas Date: Thu, 17 Mar 2016 20:14:05 -0700 Subject: [PATCH 09/16] Minor phrasing adjustment --- src/doc/book/references-and-borrowing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/book/references-and-borrowing.md b/src/doc/book/references-and-borrowing.md index 7be5cc442dd5f..74983c1255333 100644 --- a/src/doc/book/references-and-borrowing.md +++ b/src/doc/book/references-and-borrowing.md @@ -163,8 +163,8 @@ both at the same time: * exactly one mutable reference (`&mut T`). -You may notice that this is very similar, though not exactly the same as, -to the definition of a data race: +You may notice that this is very similar to, though not exactly the same as, +the definition of a data race: > There is a ‘data race’ when two or more pointers access the same memory > location at the same time, where at least one of them is writing, and the From 74d00bde8ee55c26683bd788df439a9c29b7042e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 17 Mar 2016 22:43:17 -0700 Subject: [PATCH 10/16] Make AssertRecoverSafe's field public It's basically the very definition of a newtype, so we might as well make things easy on people and let them construct and access it directly. --- src/librustdoc/test.rs | 8 ++++---- src/libstd/panic.rs | 8 +++++--- src/test/run-pass/binary-heap-panic-safe.rs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 7d4061b655941..331e3431cee84 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -257,10 +257,10 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec, libs: SearchPaths, } match { - let b_sess = AssertRecoverSafe::new(&sess); - let b_cstore = AssertRecoverSafe::new(&cstore); - let b_cfg = AssertRecoverSafe::new(cfg.clone()); - let b_control = AssertRecoverSafe::new(&control); + let b_sess = AssertRecoverSafe(&sess); + let b_cstore = AssertRecoverSafe(&cstore); + let b_cfg = AssertRecoverSafe(cfg.clone()); + let b_control = AssertRecoverSafe(&control); panic::recover(|| { driver::compile_input(&b_sess, &b_cstore, (*b_cfg).clone(), diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 5c2e36623cbed..c29a57b096c47 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -147,7 +147,7 @@ pub trait RefRecoverSafe {} /// // }); /// /// // This, however, will compile due to the `AssertRecoverSafe` wrapper -/// let result = panic::recover(AssertRecoverSafe::new(|| { +/// let result = panic::recover(AssertRecoverSafe(|| { /// variable += 3; /// })); /// // ... @@ -171,7 +171,7 @@ pub trait RefRecoverSafe {} /// let other_capture = 3; /// /// let result = { -/// let mut wrapper = AssertRecoverSafe::new(&mut variable); +/// let mut wrapper = AssertRecoverSafe(&mut variable); /// panic::recover(move || { /// **wrapper += other_capture; /// }) @@ -179,7 +179,7 @@ pub trait RefRecoverSafe {} /// // ... /// ``` #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] -pub struct AssertRecoverSafe(T); +pub struct AssertRecoverSafe(pub T); // Implementations of the `RecoverSafe` trait: // @@ -216,12 +216,14 @@ impl RefRecoverSafe for AssertRecoverSafe {} impl AssertRecoverSafe { /// Creates a new `AssertRecoverSafe` wrapper around the provided type. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] + #[rustc_deprecated(reason = "the type's field is now public, construct it directly")] pub fn new(t: T) -> AssertRecoverSafe { AssertRecoverSafe(t) } /// Consumes the `AssertRecoverSafe`, returning the wrapped value. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] + #[rustc_deprecated(reason = "the type's field is now public, access it directly")] pub fn into_inner(self) -> T { self.0 } diff --git a/src/test/run-pass/binary-heap-panic-safe.rs b/src/test/run-pass/binary-heap-panic-safe.rs index d85fd3a2b6b1c..7fbd8dc4786ba 100644 --- a/src/test/run-pass/binary-heap-panic-safe.rs +++ b/src/test/run-pass/binary-heap-panic-safe.rs @@ -70,7 +70,7 @@ fn test_integrity() { { // push the panicking item to the heap and catch the panic let thread_result = { - let mut heap_ref = AssertRecoverSafe::new(&mut heap); + let mut heap_ref = AssertRecoverSafe(&mut heap); panic::recover(move || { heap_ref.push(panic_item); }) From fcaefcfdb0489e86d9ba7ad6ab75b41ae33bc6c3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 18 Mar 2016 11:34:51 +0100 Subject: [PATCH 11/16] liveness: substitute bound regions with free ones before normalizing the return type Fixes #32323 --- src/librustc/middle/liveness.rs | 4 +++- src/test/compile-fail/issue-32323.rs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/issue-32323.rs diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 0bfb830efc1e7..73db978cffe2c 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -115,6 +115,7 @@ use middle::pat_util; use middle::ty::{self, TyCtxt, ParameterEnvironment}; use middle::traits::{self, ProjectionMode}; use middle::infer; +use middle::subst::Subst; use lint; use util::nodemap::NodeMap; @@ -1495,6 +1496,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => { let param_env = ParameterEnvironment::for_item(&self.ir.tcx, id); + let t_ret_subst = t_ret.subst(&self.ir.tcx, ¶m_env.free_substs); let infcx = infer::new_infer_ctxt(&self.ir.tcx, &self.ir.tcx.tables, Some(param_env), @@ -1502,7 +1504,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let cause = traits::ObligationCause::dummy(); let norm = traits::fully_normalize(&infcx, cause, - &t_ret); + &t_ret_subst); if norm.unwrap().is_nil() { // for nil return types, it is ok to not return a value expl. diff --git a/src/test/compile-fail/issue-32323.rs b/src/test/compile-fail/issue-32323.rs new file mode 100644 index 0000000000000..e3461e52e1c71 --- /dev/null +++ b/src/test/compile-fail/issue-32323.rs @@ -0,0 +1,18 @@ +// 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. + +pub trait Tr<'a> { + type Out; +} + +pub fn f<'a, T: Tr<'a>>() -> >::Out {} +//~^ ERROR not all control paths return a value + +pub fn main() {} From 9e1d65975c050c89b9ff3d0b0e404946d1f21f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 18 Mar 2016 15:51:17 +0100 Subject: [PATCH 12/16] Update LLVM to include a backport to restore AA performance cc #31435 --- src/llvm | 2 +- src/rustllvm/llvm-auto-clean-trigger | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llvm b/src/llvm index 63f3a1bfcd783..25c7dc3703594 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 63f3a1bfcd78355398a460712db25922247756b6 +Subproject commit 25c7dc370359433ca02f29919dfa36f94432155e diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 502ac53978e22..d6e8852cfecfe 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. -2016-03-15 +2016-03-18 From b3ade68f270969d5f3fc2c332ad8adef675110cc Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 18 Mar 2016 09:13:55 -0700 Subject: [PATCH 13/16] Add a since to deprecations --- src/libstd/panic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index c29a57b096c47..ced778571882b 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -216,14 +216,14 @@ impl RefRecoverSafe for AssertRecoverSafe {} impl AssertRecoverSafe { /// Creates a new `AssertRecoverSafe` wrapper around the provided type. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, construct it directly")] + #[rustc_deprecated(reason = "the type's field is now public, construct it directly", since = "1.9.0")] pub fn new(t: T) -> AssertRecoverSafe { AssertRecoverSafe(t) } /// Consumes the `AssertRecoverSafe`, returning the wrapped value. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, access it directly")] + #[rustc_deprecated(reason = "the type's field is now public, access it directly", since = "1.9.0)] pub fn into_inner(self) -> T { self.0 } From 797d520d2baa6a9264060b657c3aeeed8c709167 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 18 Mar 2016 09:30:36 -0700 Subject: [PATCH 14/16] Fix tidy --- src/libstd/panic.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index ced778571882b..20d29205445e4 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -216,14 +216,16 @@ impl RefRecoverSafe for AssertRecoverSafe {} impl AssertRecoverSafe { /// Creates a new `AssertRecoverSafe` wrapper around the provided type. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, construct it directly", since = "1.9.0")] + #[rustc_deprecated(reason = "the type's field is now public, construct it directly", + since = "1.9.0")] pub fn new(t: T) -> AssertRecoverSafe { AssertRecoverSafe(t) } /// Consumes the `AssertRecoverSafe`, returning the wrapped value. #[unstable(feature = "recover", reason = "awaiting feedback", issue = "27719")] - #[rustc_deprecated(reason = "the type's field is now public, access it directly", since = "1.9.0)] + #[rustc_deprecated(reason = "the type's field is now public, access it directly", + since = "1.9.0")] pub fn into_inner(self) -> T { self.0 } From 2ab1f0a850f4e02c5dacf882c040b3acee57f86a Mon Sep 17 00:00:00 2001 From: petevine Date: Sat, 19 Mar 2016 00:04:27 +0100 Subject: [PATCH 15/16] Use explicit -march flags in the i586 mk file `-march` should definitely go last, after the environment C(XX)FLAGS, or it's back to square one. This fixes cross-compilation issues on x86_64. --- mk/cfg/i586-unknown-linux-gnu.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mk/cfg/i586-unknown-linux-gnu.mk b/mk/cfg/i586-unknown-linux-gnu.mk index 0609f365de408..2b28550320d85 100644 --- a/mk/cfg/i586-unknown-linux-gnu.mk +++ b/mk/cfg/i586-unknown-linux-gnu.mk @@ -7,9 +7,9 @@ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM -CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS) -CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) +CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium +CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS) -march=pentium +CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) -march=pentium CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32 CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= CFG_LLC_FLAGS_i586-unknown-linux-gnu := From 135d24dd039306daab7157c4c47963986c091d26 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 19 Mar 2016 02:18:33 +0000 Subject: [PATCH 16/16] Fix volatile stores of fat pointers --- src/librustc_trans/trans/intrinsic.rs | 21 +++++++++++++-------- src/test/run-pass/volatile-fat-ptr.rs | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/test/run-pass/volatile-fat-ptr.rs diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 43976f8233bce..3c0329e0b7c16 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -589,15 +589,20 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, }, (_, "volatile_store") => { let tp_ty = *substs.types.get(FnSpace, 0); - let val = if fn_ty.args[1].is_indirect() { - Load(bcx, llargs[1]) + if type_is_fat_ptr(bcx.tcx(), tp_ty) { + VolatileStore(bcx, llargs[1], expr::get_dataptr(bcx, llargs[0])); + VolatileStore(bcx, llargs[2], expr::get_meta(bcx, llargs[0])); } else { - from_immediate(bcx, llargs[1]) - }; - let ptr = PointerCast(bcx, llargs[0], val_ty(val).ptr_to()); - let store = VolatileStore(bcx, val, ptr); - unsafe { - llvm::LLVMSetAlignment(store, type_of::align_of(ccx, tp_ty)); + let val = if fn_ty.args[1].is_indirect() { + Load(bcx, llargs[1]) + } else { + from_immediate(bcx, llargs[1]) + }; + let ptr = PointerCast(bcx, llargs[0], val_ty(val).ptr_to()); + let store = VolatileStore(bcx, val, ptr); + unsafe { + llvm::LLVMSetAlignment(store, type_of::align_of(ccx, tp_ty)); + } } C_nil(ccx) }, diff --git a/src/test/run-pass/volatile-fat-ptr.rs b/src/test/run-pass/volatile-fat-ptr.rs new file mode 100644 index 0000000000000..03ba5587fcec8 --- /dev/null +++ b/src/test/run-pass/volatile-fat-ptr.rs @@ -0,0 +1,22 @@ +// 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(volatile)] +use std::ptr::{read_volatile, write_volatile}; + +fn main() { + let mut x: &'static str = "test"; + unsafe { + let a = read_volatile(&x); + assert_eq!(a, "test"); + write_volatile(&mut x, "foo"); + assert_eq!(x, "foo"); + } +}