Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #36373

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a7c671b
rustdoc: Add missing item types to page titles
ollie27 Aug 27, 2016
b99c5cf
doc: we got coercion going on here, so no need to be this explicit
tshepang Sep 7, 2016
102b3a9
Add doc example for `std::time::Instant::elapsed`.
frewsxcv Sep 7, 2016
f6aab5b
Fixed typo in nomicon
JDemler Sep 7, 2016
d951d5d
Handle `ReEmpty` for `impl Trait`
apasel422 Sep 7, 2016
8c95712
Use LLVM_COMPONENTS to run tests just for supported targets
sanxiyn Sep 8, 2016
dd570d6
For size of `struct P<T>(Q<T>)`, don't double-count the prefix added …
pnkfelix Sep 8, 2016
5e9149d
Allow setting --docdir
Sep 9, 2016
0e32d11
Update the wording for E0063. This will truncate the fields to 3.
jaredadobe Aug 5, 2016
1ad0549
Rollup merge of #35691 - jaredwy:update-error-63, r=jonathandturner
Manishearth Sep 10, 2016
af6b8a1
Rollup merge of #36045 - ollie27:rustdoc_titles3, r=steveklabnik
Manishearth Sep 10, 2016
3bf805e
Rollup merge of #36311 - frewsxcv:instant-elapsed-example, r=Guillaum…
Manishearth Sep 10, 2016
37524de
Rollup merge of #36314 - tshepang:not-needed, r=GuillaumeGomez
Manishearth Sep 10, 2016
58d8038
Rollup merge of #36326 - JDemler:master, r=steveklabnik
Manishearth Sep 10, 2016
2666f68
Rollup merge of #36333 - apasel422:issue-35668, r=eddyb
Manishearth Sep 10, 2016
454b1eb
Rollup merge of #36344 - sanxiyn:llvm-components, r=alexcrichton
Manishearth Sep 10, 2016
ec6fe6e
Rollup merge of #36351 - pnkfelix:fix-36278-size-miscalc, r=eddyb
Manishearth Sep 10, 2016
c5f99e7
Rollup merge of #36360 - orbea:docdir, r=alexcrichton
Manishearth Sep 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
valopt_nosave docdir "${CFG_PREFIX}/share/doc/rust" "install man pages in PATH"

# On Windows this determines root of the subtree for target libraries.
# Host runtime libs always go to 'bin'.
Expand Down Expand Up @@ -1120,6 +1121,7 @@ putvar CFG_STDCPP_NAME
# a little post-processing of various config values
CFG_PREFIX=${CFG_PREFIX%/}
CFG_MANDIR=${CFG_MANDIR%/}
CFG_DOCDIR=${CFG_DOCDIR%/}
CFG_HOST="$(echo $CFG_HOST | tr ',' ' ')"
CFG_TARGET="$(echo $CFG_TARGET | tr ',' ' ')"
CFG_SUPPORTED_TARGET=""
Expand Down Expand Up @@ -1801,6 +1803,7 @@ putvar CFG_ARMV7_LINUX_ANDROIDEABI_NDK
putvar CFG_I686_LINUX_ANDROID_NDK
putvar CFG_NACL_CROSS_PATH
putvar CFG_MANDIR
putvar CFG_DOCDIR
putvar CFG_USING_LIBCPP

# Avoid spurious warnings from clang by feeding it original source on
Expand Down
3 changes: 2 additions & 1 deletion mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN_INSTALLER = cd tmp/empty_dir && \
sh ../../tmp/dist/$(1)/install.sh \
--prefix="$(DESTDIR)$(CFG_PREFIX)" \
--libdir="$(DESTDIR)$(CFG_LIBDIR)" \
--mandir="$(DESTDIR)$(CFG_MANDIR)"
--mandir="$(DESTDIR)$(CFG_MANDIR)" \
--docdir="$(DESTDIR)$(CFG_DOCDIR)"

install:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
Expand Down
2 changes: 1 addition & 1 deletion src/doc/nomicon/ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let mut data = vec![1, 2, 3];
let x = &data[0];

// OH NO! `push` causes the backing storage of `data` to be reallocated.
// Dangling pointer! User after free! Alas!
// Dangling pointer! Use after free! Alas!
// (this does not compile in Rust)
data.push(4);

Expand Down
13 changes: 12 additions & 1 deletion src/librustc_trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,20 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: &BlockAndBuilder<'blk, 'tcx>,
let layout = ccx.layout_of(t);
debug!("DST {} layout: {:?}", t, layout);

// Returns size in bytes of all fields except the last one
// (we will be recursing on the last one).
fn local_prefix_bytes(variant: &ty::layout::Struct) -> u64 {
let fields = variant.offset_after_field.len();
if fields > 1 {
variant.offset_after_field[fields - 2].bytes()
} else {
0
}
}

let (sized_size, sized_align) = match *layout {
ty::layout::Layout::Univariant { ref variant, .. } => {
(variant.min_size().bytes(), variant.align.abi())
(local_prefix_bytes(variant), variant.align.abi())
}
_ => {
bug!("size_and_align_of_dst: expcted Univariant for `{}`, found {:#?}",
Expand Down
38 changes: 30 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3159,14 +3159,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
tcx.sess.span_err(span, "union expressions should have exactly one field");
}
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
span_err!(tcx.sess, span, E0063,
"missing field{} {} in initializer of `{}`",
if remaining_fields.len() == 1 {""} else {"s"},
remaining_fields.keys()
.map(|n| format!("`{}`", n))
.collect::<Vec<_>>()
.join(", "),
adt_ty);
let len = remaining_fields.len();

let mut displayable_field_names = remaining_fields
.keys()
.map(|x| x.as_str())
.collect::<Vec<_>>();

displayable_field_names.sort();

let truncated_fields_error = if len <= 3 {
"".to_string()
} else {
format!(" and {} other field{}", (len - 3), if len - 3 == 1 {""} else {"s"})
};

let remaining_fields_names = displayable_field_names.iter().take(3)
.map(|n| format!("`{}`", n))
.collect::<Vec<_>>()
.join(", ");

struct_span_err!(tcx.sess, span, E0063,
"missing field{} {}{} in initializer of `{}`",
if remaining_fields.len() == 1 {""} else {"s"},
remaining_fields_names,
truncated_fields_error,
adt_ty)
.span_label(span, &format!("missing {}{}",
remaining_fields_names,
truncated_fields_error))
.emit();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
let outside_ty = gcx.fold_regions(&inside_ty, &mut false, |r, _| {
match *r {
// 'static is valid everywhere.
ty::ReStatic => gcx.mk_region(ty::ReStatic),
ty::ReStatic |
ty::ReEmpty => gcx.mk_region(*r),

// Free regions that come from early-bound regions are valid.
ty::ReFree(ty::FreeRegion {
Expand All @@ -341,7 +342,6 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
}

ty::ReVar(_) |
ty::ReEmpty |
ty::ReErased => {
let span = reason.span(self.tcx());
span_bug!(span, "invalid region in impl Trait: {:?}", r);
Expand Down
18 changes: 15 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,13 +1560,22 @@ impl<'a> fmt::Display for Item<'a> {
} else {
write!(fmt, "Module ")?;
},
clean::FunctionItem(..) => write!(fmt, "Function ")?,
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) =>
write!(fmt, "Function ")?,
clean::TraitItem(..) => write!(fmt, "Trait ")?,
clean::StructItem(..) => write!(fmt, "Struct ")?,
clean::UnionItem(..) => write!(fmt, "Union ")?,
clean::EnumItem(..) => write!(fmt, "Enum ")?,
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
clean::MacroItem(..) => write!(fmt, "Macro ")?,
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
_ => {}
clean::StaticItem(..) | clean::ForeignStaticItem(..) =>
write!(fmt, "Static ")?,
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
_ => {
// We don't generate pages for any other type.
unreachable!();
}
}
if !self.item.is_primitive() {
let cur = &self.cx.current;
Expand Down Expand Up @@ -1628,7 +1637,10 @@ impl<'a> fmt::Display for Item<'a> {
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
item_static(fmt, self.cx, self.item, i),
clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
_ => Ok(())
_ => {
// We don't generate pages for any other type.
unreachable!();
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,9 @@ impl PathBuf {
/// let mut p = PathBuf::from("/test/test.rs");
///
/// p.pop();
/// assert_eq!(Path::new("/test"), p.as_path());
/// assert_eq!(Path::new("/test"), p);
/// p.pop();
/// assert_eq!(Path::new("/"), p.as_path());
/// assert_eq!(Path::new("/"), p);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pop(&mut self) -> bool {
Expand Down
12 changes: 12 additions & 0 deletions src/libstd/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ impl Instant {
/// This function may panic if the current time is earlier than this
/// instant, which is something that can happen if an `Instant` is
/// produced synthetically.
///
/// # Examples
///
/// ```no_run
/// use std::thread::sleep;
/// use std::time::{Duration, Instant};
///
/// let instant = Instant::now();
/// let three_secs = Duration::from_secs(3);
/// sleep(three_secs);
/// assert!(instant.elapsed() >= three_secs);
/// ```
#[stable(feature = "time2", since = "1.8.0")]
pub fn elapsed(&self) -> Duration {
Instant::now() - *self
Expand Down
42 changes: 39 additions & 3 deletions src/test/compile-fail/E0063.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,47 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Foo {
// ignore-tidy-linelength

struct SingleFoo {
x: i32
}

struct PluralFoo {
x: i32,
y: i32,
z: i32
}

struct TruncatedFoo {
a: i32,
b: i32,
x: i32,
y: i32
y: i32,
z: i32
}

struct TruncatedPluralFoo {
a: i32,
b: i32,
c: i32,
x: i32,
y: i32,
z: i32
}


fn main() {
let x = Foo { x: 0 }; //~ ERROR E0063
let w = SingleFoo { };
//~^ ERROR missing field `x` in initializer of `SingleFoo`
//~| NOTE missing `x`
let x = PluralFoo {x: 1};
//~^ ERROR missing fields `y`, `z` in initializer of `PluralFoo`
//~| NOTE missing `y`, `z`
let y = TruncatedFoo{x:1};
//~^ missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
//~| NOTE `a`, `b`, `y` and 1 other field
let z = TruncatedPluralFoo{x:1};
//~^ ERROR missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo`
//~| NOTE missing `a`, `b`, `c` and 2 other fields
}
24 changes: 24 additions & 0 deletions src/test/compile-fail/issue-35668.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(conservative_impl_trait)]

fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> {
a.iter().map(|a| a*a)
//~^ ERROR binary operation `*` cannot be applied to type `&T`
}

fn main() {
let a = (0..30).collect::<Vec<_>>();

for k in func(&a) {
println!("{}", k);
}
}
10 changes: 10 additions & 0 deletions src/test/run-make/atomic-lock-free/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@

all:
ifeq ($(UNAME),Linux)
ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
$(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
endif
ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
$(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
endif
ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64)
$(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
endif
ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
$(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
endif
ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc)
$(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
$(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
endif
endif
28 changes: 28 additions & 0 deletions src/test/run-pass/issue-36278-prefix-nesting.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Issue 36278: On an unsized struct with >1 level of nontrivial
// nesting, ensure we are computing dynamic size of prefix correctly.

use std::mem;

const SZ: usize = 100;
struct P<T: ?Sized>([u8; SZ], T);

type Ack<T> = P<P<T>>;

fn main() {
let size_of_sized; let size_of_unsized;
let x: Box<Ack<[u8; 0]>> = Box::new(P([0; SZ], P([0; SZ], [0; 0])));
size_of_sized = mem::size_of_val::<Ack<_>>(&x);
let y: Box<Ack<[u8 ]>> = x;
size_of_unsized = mem::size_of_val::<Ack<_>>(&y);
assert_eq!(size_of_sized, size_of_unsized);
}
59 changes: 59 additions & 0 deletions src/test/rustdoc/titles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![crate_name = "foo"]

// @matches 'foo/index.html' '//h1' 'Crate foo'

// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
pub mod foo_mod {
pub struct __Thing {}
}

extern {
// @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
pub fn foo_ffn();
}

// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn'
pub fn foo_fn() {}

// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait'
pub trait FooTrait {}

// @matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct'
pub struct FooStruct;

// @matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum'
pub enum FooEnum {}

// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType'
pub type FooType = FooStruct;

// @matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro'
#[macro_export]
macro_rules! foo_macro {
() => ();
}

// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
#[doc(primitive = "bool")]
mod bool {}

// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'
pub static FOO_STATIC: FooStruct = FooStruct;

extern {
// @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC'
pub static FOO_FSTATIC: FooStruct;
}

// @matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT'
pub const FOO_CONSTANT: FooStruct = FooStruct;