Skip to content

Commit f8ba7cb

Browse files
authored
Auto merge of #36378 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests - Successful merges: #35691, #36045, #36311, #36314, #36326, #36346 - Failed merges:
2 parents a5f4cc5 + 2ded399 commit f8ba7cb

File tree

8 files changed

+161
-18
lines changed

8 files changed

+161
-18
lines changed

Diff for: src/doc/nomicon/ownership.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let mut data = vec![1, 2, 3];
5252
let x = &data[0];
5353
5454
// OH NO! `push` causes the backing storage of `data` to be reallocated.
55-
// Dangling pointer! User after free! Alas!
55+
// Dangling pointer! Use after free! Alas!
5656
// (this does not compile in Rust)
5757
data.push(4);
5858

Diff for: src/librustc_trans/meth.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ pub fn trans_object_shim<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
116116
llfn
117117
}
118118

119-
/// Creates a returns a dynamic vtable for the given type and vtable origin.
119+
/// Creates a dynamic vtable for the given type and vtable origin.
120120
/// This is used only for objects.
121121
///
122+
/// The vtables are cached instead of created on every call.
123+
///
122124
/// The `trait_ref` encodes the erased self type. Hence if we are
123125
/// making an object `Foo<Trait>` from a value of type `Foo<T>`, then
124126
/// `trait_ref` would map `T:Trait`.

Diff for: src/librustc_typeck/check/mod.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -3159,14 +3159,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
31593159
tcx.sess.span_err(span, "union expressions should have exactly one field");
31603160
}
31613161
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
3162-
span_err!(tcx.sess, span, E0063,
3163-
"missing field{} {} in initializer of `{}`",
3164-
if remaining_fields.len() == 1 {""} else {"s"},
3165-
remaining_fields.keys()
3166-
.map(|n| format!("`{}`", n))
3167-
.collect::<Vec<_>>()
3168-
.join(", "),
3169-
adt_ty);
3162+
let len = remaining_fields.len();
3163+
3164+
let mut displayable_field_names = remaining_fields
3165+
.keys()
3166+
.map(|x| x.as_str())
3167+
.collect::<Vec<_>>();
3168+
3169+
displayable_field_names.sort();
3170+
3171+
let truncated_fields_error = if len <= 3 {
3172+
"".to_string()
3173+
} else {
3174+
format!(" and {} other field{}", (len - 3), if len - 3 == 1 {""} else {"s"})
3175+
};
3176+
3177+
let remaining_fields_names = displayable_field_names.iter().take(3)
3178+
.map(|n| format!("`{}`", n))
3179+
.collect::<Vec<_>>()
3180+
.join(", ");
3181+
3182+
struct_span_err!(tcx.sess, span, E0063,
3183+
"missing field{} {}{} in initializer of `{}`",
3184+
if remaining_fields.len() == 1 {""} else {"s"},
3185+
remaining_fields_names,
3186+
truncated_fields_error,
3187+
adt_ty)
3188+
.span_label(span, &format!("missing {}{}",
3189+
remaining_fields_names,
3190+
truncated_fields_error))
3191+
.emit();
31703192
}
31713193
}
31723194

Diff for: src/librustdoc/html/render.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1560,13 +1560,22 @@ impl<'a> fmt::Display for Item<'a> {
15601560
} else {
15611561
write!(fmt, "Module ")?;
15621562
},
1563-
clean::FunctionItem(..) => write!(fmt, "Function ")?,
1563+
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) =>
1564+
write!(fmt, "Function ")?,
15641565
clean::TraitItem(..) => write!(fmt, "Trait ")?,
15651566
clean::StructItem(..) => write!(fmt, "Struct ")?,
15661567
clean::UnionItem(..) => write!(fmt, "Union ")?,
15671568
clean::EnumItem(..) => write!(fmt, "Enum ")?,
1569+
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
1570+
clean::MacroItem(..) => write!(fmt, "Macro ")?,
15681571
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
1569-
_ => {}
1572+
clean::StaticItem(..) | clean::ForeignStaticItem(..) =>
1573+
write!(fmt, "Static ")?,
1574+
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
1575+
_ => {
1576+
// We don't generate pages for any other type.
1577+
unreachable!();
1578+
}
15701579
}
15711580
if !self.item.is_primitive() {
15721581
let cur = &self.cx.current;
@@ -1628,7 +1637,10 @@ impl<'a> fmt::Display for Item<'a> {
16281637
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) =>
16291638
item_static(fmt, self.cx, self.item, i),
16301639
clean::ConstantItem(ref c) => item_constant(fmt, self.cx, self.item, c),
1631-
_ => Ok(())
1640+
_ => {
1641+
// We don't generate pages for any other type.
1642+
unreachable!();
1643+
}
16321644
}
16331645
}
16341646
}

Diff for: src/libstd/path.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1169,9 +1169,9 @@ impl PathBuf {
11691169
/// let mut p = PathBuf::from("/test/test.rs");
11701170
///
11711171
/// p.pop();
1172-
/// assert_eq!(Path::new("/test"), p.as_path());
1172+
/// assert_eq!(Path::new("/test"), p);
11731173
/// p.pop();
1174-
/// assert_eq!(Path::new("/"), p.as_path());
1174+
/// assert_eq!(Path::new("/"), p);
11751175
/// ```
11761176
#[stable(feature = "rust1", since = "1.0.0")]
11771177
pub fn pop(&mut self) -> bool {

Diff for: src/libstd/time/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ impl Instant {
150150
/// This function may panic if the current time is earlier than this
151151
/// instant, which is something that can happen if an `Instant` is
152152
/// produced synthetically.
153+
///
154+
/// # Examples
155+
///
156+
/// ```no_run
157+
/// use std::thread::sleep;
158+
/// use std::time::{Duration, Instant};
159+
///
160+
/// let instant = Instant::now();
161+
/// let three_secs = Duration::from_secs(3);
162+
/// sleep(three_secs);
163+
/// assert!(instant.elapsed() >= three_secs);
164+
/// ```
153165
#[stable(feature = "time2", since = "1.8.0")]
154166
pub fn elapsed(&self) -> Duration {
155167
Instant::now() - *self

Diff for: src/test/compile-fail/E0063.rs

+39-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,47 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct Foo {
11+
// ignore-tidy-linelength
12+
13+
struct SingleFoo {
14+
x: i32
15+
}
16+
17+
struct PluralFoo {
18+
x: i32,
19+
y: i32,
20+
z: i32
21+
}
22+
23+
struct TruncatedFoo {
24+
a: i32,
25+
b: i32,
1226
x: i32,
13-
y: i32
27+
y: i32,
28+
z: i32
1429
}
1530

31+
struct TruncatedPluralFoo {
32+
a: i32,
33+
b: i32,
34+
c: i32,
35+
x: i32,
36+
y: i32,
37+
z: i32
38+
}
39+
40+
1641
fn main() {
17-
let x = Foo { x: 0 }; //~ ERROR E0063
42+
let w = SingleFoo { };
43+
//~^ ERROR missing field `x` in initializer of `SingleFoo`
44+
//~| NOTE missing `x`
45+
let x = PluralFoo {x: 1};
46+
//~^ ERROR missing fields `y`, `z` in initializer of `PluralFoo`
47+
//~| NOTE missing `y`, `z`
48+
let y = TruncatedFoo{x:1};
49+
//~^ missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
50+
//~| NOTE `a`, `b`, `y` and 1 other field
51+
let z = TruncatedPluralFoo{x:1};
52+
//~^ ERROR missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo`
53+
//~| NOTE missing `a`, `b`, `c` and 2 other fields
1854
}

Diff for: src/test/rustdoc/titles.rs

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "foo"]
12+
13+
// @matches 'foo/index.html' '//h1' 'Crate foo'
14+
15+
// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
16+
pub mod foo_mod {
17+
pub struct __Thing {}
18+
}
19+
20+
extern {
21+
// @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
22+
pub fn foo_ffn();
23+
}
24+
25+
// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn'
26+
pub fn foo_fn() {}
27+
28+
// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait'
29+
pub trait FooTrait {}
30+
31+
// @matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct'
32+
pub struct FooStruct;
33+
34+
// @matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum'
35+
pub enum FooEnum {}
36+
37+
// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType'
38+
pub type FooType = FooStruct;
39+
40+
// @matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro'
41+
#[macro_export]
42+
macro_rules! foo_macro {
43+
() => ();
44+
}
45+
46+
// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
47+
#[doc(primitive = "bool")]
48+
mod bool {}
49+
50+
// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'
51+
pub static FOO_STATIC: FooStruct = FooStruct;
52+
53+
extern {
54+
// @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC'
55+
pub static FOO_FSTATIC: FooStruct;
56+
}
57+
58+
// @matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT'
59+
pub const FOO_CONSTANT: FooStruct = FooStruct;

0 commit comments

Comments
 (0)