about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-02-03 18:40:54 +0000
committerbors <bors@rust-lang.org>2020-02-03 18:40:54 +0000
commit8417d68de5e063426ab6bb7f383df6117d1beeed (patch)
tree46e8f409b07c23138be597bde715fe944f4274ce
parentbdd946df3a7af6be0c075d5ab15f9845b3679364 (diff)
parentaf3c315dafae5a40f4794635461625ab712d3582 (diff)
Auto merge of #68803 - Dylan-DPC:rollup-b4x6ghj, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #68678 (Install robots.txt into rust-docs tarballs)
 - #68711 (Added upper bound of what vecs and boxes can allocate)
 - #68744 (Do not ICE in `type-alias-impl-trait` with save-analysis)
 - #68777 (Clean up E0263 explanation)
 - #68787 (Optimize core::ptr::align_offset (part 1))
 - #68797 (Fix links to types instead of modules)
 - #68798 (Test that `#[track_caller]` as `fn()` respects RT / CTFE equivalence)
 - #68800 (Stabilize `core::iter::once_with()`)

Failed merges:

r? @ghost
-rw-r--r--src/bootstrap/dist.rs1
-rw-r--r--src/doc/robots.txt1
-rw-r--r--src/liballoc/boxed.rs3
-rw-r--r--src/liballoc/vec.rs2
-rw-r--r--src/libcore/iter/mod.rs2
-rw-r--r--src/libcore/iter/sources.rs18
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/ptr/mod.rs38
-rw-r--r--src/libcore/tests/lib.rs1
-rw-r--r--src/librustc_error_codes/error_codes/E0263.md17
-rw-r--r--src/librustc_typeck/check/mod.rs7
-rw-r--r--src/libstd/lib.rs4
-rw-r--r--src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs32
-rw-r--r--src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr6
-rw-r--r--src/test/ui/save-analysis/issue-68621.rs17
-rw-r--r--src/test/ui/save-analysis/issue-68621.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63279.rs2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63279.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs1
19 files changed, 123 insertions, 42 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 8d13df3ee21..facf816857f 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -105,6 +105,7 @@ impl Step for Docs {
         t!(fs::create_dir_all(&dst));
         let src = builder.doc_out(host);
         builder.cp_r(&src, &dst);
+        builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644);
 
         let mut cmd = rust_installer(builder);
         cmd.arg("generate")
diff --git a/src/doc/robots.txt b/src/doc/robots.txt
index 61ee12739fb..d119cc46473 100644
--- a/src/doc/robots.txt
+++ b/src/doc/robots.txt
@@ -1,4 +1,3 @@
-# NB: This file is not automatically deployed. After changes, it needs to be uploaded manually to doc.rust-lang.org
 User-agent: *
 Disallow: /0.3/
 Disallow: /0.4/
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 8735c2c8f36..7e5efbe3078 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -2,7 +2,8 @@
 //!
 //! [`Box<T>`], casually referred to as a 'box', provides the simplest form of
 //! heap allocation in Rust. Boxes provide ownership for this allocation, and
-//! drop their contents when they go out of scope.
+//! drop their contents when they go out of scope. Boxes also ensure that they
+//! never allocate more than `isize::MAX` bytes.
 //!
 //! # Examples
 //!
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 26a7812f58e..4f6b7870e2e 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -4,6 +4,8 @@
 //! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
 //! `O(1)` pop (from the end).
 //!
+//! Vectors ensure they never allocate more than `isize::MAX` bytes.
+//!
 //! # Examples
 //!
 //! You can explicitly create a [`Vec<T>`] with [`new`]:
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs
index d8a56cb3ae5..5fa9962f811 100644
--- a/src/libcore/iter/mod.rs
+++ b/src/libcore/iter/mod.rs
@@ -327,7 +327,7 @@ pub use self::sources::{empty, Empty};
 pub use self::sources::{from_fn, FromFn};
 #[stable(feature = "iter_once", since = "1.2.0")]
 pub use self::sources::{once, Once};
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 pub use self::sources::{once_with, OnceWith};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::sources::{repeat, Repeat};
diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs
index 25dfc573e41..5a31acab273 100644
--- a/src/libcore/iter/sources.rs
+++ b/src/libcore/iter/sources.rs
@@ -399,12 +399,12 @@ pub fn once<T>(value: T) -> Once<T> {
 ///
 /// [`once_with`]: fn.once_with.html
 #[derive(Copy, Clone, Debug)]
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 pub struct OnceWith<F> {
     gen: Option<F>,
 }
 
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
     type Item = A;
 
@@ -420,24 +420,24 @@ impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
     }
 }
 
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 impl<A, F: FnOnce() -> A> DoubleEndedIterator for OnceWith<F> {
     fn next_back(&mut self) -> Option<A> {
         self.next()
     }
 }
 
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 impl<A, F: FnOnce() -> A> ExactSizeIterator for OnceWith<F> {
     fn len(&self) -> usize {
         self.gen.iter().len()
     }
 }
 
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 impl<A, F: FnOnce() -> A> FusedIterator for OnceWith<F> {}
 
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
 
 /// Creates an iterator that lazily generates a value exactly once by invoking
@@ -458,8 +458,6 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
 /// Basic usage:
 ///
 /// ```
-/// #![feature(iter_once_with)]
-///
 /// use std::iter;
 ///
 /// // one is the loneliest number
@@ -476,8 +474,6 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
 /// `.foorc`:
 ///
 /// ```no_run
-/// #![feature(iter_once_with)]
-///
 /// use std::iter;
 /// use std::fs;
 /// use std::path::PathBuf;
@@ -500,7 +496,7 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
 /// }
 /// ```
 #[inline]
-#[unstable(feature = "iter_once_with", issue = "57581")]
+#[stable(feature = "iter_once_with", since = "1.43.0")]
 pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
     OnceWith { gen: Some(gen) }
 }
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index ce7ddffd825..7738ea2ac57 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -87,7 +87,6 @@
 #![feature(intrinsics)]
 #![feature(try_find)]
 #![feature(is_sorted)]
-#![feature(iter_once_with)]
 #![feature(lang_items)]
 #![feature(link_llvm_intrinsics)]
 #![feature(never_type)]
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs
index 9727e4face5..0ee50966f96 100644
--- a/src/libcore/ptr/mod.rs
+++ b/src/libcore/ptr/mod.rs
@@ -1081,9 +1081,8 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
                 // uses e.g., subtraction `mod n`. It is entirely fine to do them `mod
                 // usize::max_value()` instead, because we take the result `mod n` at the end
                 // anyway.
-                inverse = inverse.wrapping_mul(2usize.wrapping_sub(x.wrapping_mul(inverse)))
-                    & (going_mod - 1);
-                if going_mod > m {
+                inverse = inverse.wrapping_mul(2usize.wrapping_sub(x.wrapping_mul(inverse)));
+                if going_mod >= m {
                     return inverse & (m - 1);
                 }
                 going_mod = going_mod.wrapping_mul(going_mod);
@@ -1115,26 +1114,33 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
     let gcdpow = intrinsics::cttz_nonzero(stride).min(intrinsics::cttz_nonzero(a));
     let gcd = 1usize << gcdpow;
 
-    if p as usize & (gcd - 1) == 0 {
+    if p as usize & (gcd.wrapping_sub(1)) == 0 {
         // This branch solves for the following linear congruence equation:
         //
-        // $$ p + so ≡ 0 mod a $$
+        // ` p + so = 0 mod a `
         //
-        // $p$ here is the pointer value, $s$ – stride of `T`, $o$ offset in `T`s, and $a$ – the
+        // `p` here is the pointer value, `s` - stride of `T`, `o` offset in `T`s, and `a` - the
         // requested alignment.
         //
-        // g = gcd(a, s)
-        // o = (a - (p mod a))/g * ((s/g)⁻¹ mod a)
+        // With `g = gcd(a, s)`, and the above asserting that `p` is also divisible by `g`, we can
+        // denote `a' = a/g`, `s' = s/g`, `p' = p/g`, then this becomes equivalent to:
         //
-        // The first term is “the relative alignment of p to a”, the second term is “how does
-        // incrementing p by s bytes change the relative alignment of p”. Division by `g` is
-        // necessary to make this equation well formed if $a$ and $s$ are not co-prime.
+        // ` p' + s'o = 0 mod a' `
+        // ` o = (a' - (p' mod a')) * (s'^-1 mod a') `
         //
-        // Furthermore, the result produced by this solution is not “minimal”, so it is necessary
-        // to take the result $o mod lcm(s, a)$. We can replace $lcm(s, a)$ with just a $a / g$.
-        let j = a.wrapping_sub(pmoda) >> gcdpow;
-        let k = smoda >> gcdpow;
-        return intrinsics::unchecked_rem(j.wrapping_mul(mod_inv(k, a)), a >> gcdpow);
+        // The first term is "the relative alignment of `p` to `a`" (divided by the `g`), the second
+        // term is "how does incrementing `p` by `s` bytes change the relative alignment of `p`" (again
+        // divided by `g`).
+        // Division by `g` is necessary to make the inverse well formed if `a` and `s` are not
+        // co-prime.
+        //
+        // Furthermore, the result produced by this solution is not "minimal", so it is necessary
+        // to take the result `o mod lcm(s, a)`. We can replace `lcm(s, a)` with just a `a'`.
+        let a2 = a >> gcdpow;
+        let a2minus1 = a2.wrapping_sub(1);
+        let s2 = smoda >> gcdpow;
+        let minusp2 = a2.wrapping_sub(pmoda >> gcdpow);
+        return (minusp2.wrapping_mul(mod_inv(s2, a2))) & a2minus1;
     }
 
     // Cannot be aligned at all.
diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs
index 8fd19ef67fc..bfc3ee09dce 100644
--- a/src/libcore/tests/lib.rs
+++ b/src/libcore/tests/lib.rs
@@ -13,7 +13,6 @@
 #![feature(hashmap_internals)]
 #![feature(try_find)]
 #![feature(is_sorted)]
-#![feature(iter_once_with)]
 #![feature(pattern)]
 #![feature(range_is_empty)]
 #![feature(raw)]
diff --git a/src/librustc_error_codes/error_codes/E0263.md b/src/librustc_error_codes/error_codes/E0263.md
index bb4da43b3f5..37271ac692d 100644
--- a/src/librustc_error_codes/error_codes/E0263.md
+++ b/src/librustc_error_codes/error_codes/E0263.md
@@ -1,7 +1,16 @@
-A lifetime name cannot be declared more than once in the same scope. For
-example:
+A lifetime was declared more than once in the same scope.
+
+Erroneous code example:
 
 ```compile_fail,E0263
-// error, lifetime name `'a` declared twice in the same scope
-fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
+fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str, z: &'a str) { // error!
+}
+```
+
+Two lifetimes cannot have the same name. To fix this example, change
+the second `'a` lifetime into something else (`'c` for example):
+
+```
+fn foo<'a, 'b, 'c>(x: &'a str, y: &'b str, z: &'c str) { // ok!
+}
 ```
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0a917a1853e..d0275429747 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -837,8 +837,11 @@ fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
         return tcx.has_typeck_tables(outer_def_id);
     }
 
-    let id = tcx.hir().as_local_hir_id(def_id).unwrap();
-    primary_body_of(tcx, id).is_some()
+    if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
+        primary_body_of(tcx, id).is_some()
+    } else {
+        false
+    }
 }
 
 fn used_trait_imports(tcx: TyCtxt<'_>, def_id: DefId) -> &DefIdSet {
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index bc07c6b487b..230fa84cc15 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -163,11 +163,11 @@
 //! [`Iterator`]: iter/trait.Iterator.html
 //! [`Mutex`]: sync/struct.Mutex.html
 //! [`Option<T>`]: option/enum.Option.html
-//! [`Rc`]: rc/index.html
+//! [`Rc`]: rc/struct.Rc.html
 //! [`RefCell`]: cell/struct.RefCell.html
 //! [`Result<T, E>`]: result/enum.Result.html
 //! [`String`]: string/struct.String.html
-//! [`Vec<T>`]: vec/index.html
+//! [`Vec<T>`]: vec/struct.Vec.html
 //! [array]: primitive.array.html
 //! [slice]: primitive.slice.html
 //! [`atomic`]: sync/atomic/index.html
diff --git a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
new file mode 100644
index 00000000000..fe2b92eafdb
--- /dev/null
+++ b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
@@ -0,0 +1,32 @@
+// Ensure that a `#[track_caller]` function, returning `caller_location()`,
+// which coerced (to a function pointer) and called, inside a `const fn`,
+// in turn called, results in the same output irrespective of whether
+// we're in a const or runtime context.
+
+// run-pass
+// compile-flags: -Z unleash-the-miri-inside-of-you
+
+#![feature(core_intrinsics, const_caller_location, track_caller, const_fn)]
+
+type L = &'static std::panic::Location<'static>;
+
+#[track_caller]
+const fn attributed() -> L {
+    std::intrinsics::caller_location()
+}
+
+const fn calling_attributed() -> L {
+    // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
+    let ptr: fn() -> L = attributed;
+    ptr() //~ WARN skipping const checks
+}
+
+fn main() {
+    const CONSTANT: L = calling_attributed();
+    let runtime = calling_attributed();
+
+    assert_eq!(
+        (runtime.file(), runtime.line(), runtime.column()),
+        (CONSTANT.file(), CONSTANT.line(), CONSTANT.column()),
+    );
+}
diff --git a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr
new file mode 100644
index 00000000000..fcf0945ed4c
--- /dev/null
+++ b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr
@@ -0,0 +1,6 @@
+warning: skipping const checks
+  --> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5
+   |
+LL |     ptr()
+   |     ^^^^^
+
diff --git a/src/test/ui/save-analysis/issue-68621.rs b/src/test/ui/save-analysis/issue-68621.rs
new file mode 100644
index 00000000000..96af085c5b6
--- /dev/null
+++ b/src/test/ui/save-analysis/issue-68621.rs
@@ -0,0 +1,17 @@
+// compile-flags: -Zsave-analysis
+
+#![feature(type_alias_impl_trait)]
+
+trait Trait {}
+
+trait Service {
+    type Future: Trait;
+}
+
+struct Struct;
+
+impl Service for Struct {
+    type Future = impl Trait; //~ ERROR: could not find defining uses
+}
+
+fn main() {}
diff --git a/src/test/ui/save-analysis/issue-68621.stderr b/src/test/ui/save-analysis/issue-68621.stderr
new file mode 100644
index 00000000000..2c5bbd7782b
--- /dev/null
+++ b/src/test/ui/save-analysis/issue-68621.stderr
@@ -0,0 +1,8 @@
+error: could not find defining uses
+  --> $DIR/issue-68621.rs:14:5
+   |
+LL |     type Future = impl Trait;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.rs b/src/test/ui/type-alias-impl-trait/issue-63279.rs
index 586ff7a3158..b97192a2aed 100644
--- a/src/test/ui/type-alias-impl-trait/issue-63279.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-63279.rs
@@ -1,3 +1,5 @@
+// compile-flags: -Zsave-analysis
+
 #![feature(type_alias_impl_trait)]
 
 type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving
diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr
index 053ccee3785..bef4d01093c 100644
--- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr
@@ -1,5 +1,5 @@
-error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:6:5: 6:28] as std::ops::FnOnce<()>>::Output == ()`
-  --> $DIR/issue-63279.rs:3:1
+error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:8:5: 8:28] as std::ops::FnOnce<()>>::Output == ()`
+  --> $DIR/issue-63279.rs:5:1
    |
 LL | type Closure = impl FnOnce();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `()`
diff --git a/src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs b/src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
index 12eb75ae4c0..26d97cea989 100644
--- a/src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
@@ -1,3 +1,4 @@
+// compile-flags: -Zsave-analysis
 // check-pass
 
 #![feature(type_alias_impl_trait)]