Skip to content

Commit 98f0a91

Browse files
committed
Auto merge of #32454 - eddyb:rollup, r=eddyb
Rollup of 11 pull requests - Successful merges: #32404, #32420, #32423, #32425, #32429, #32430, #32431, #32434, #32437, #32441, #32443 - Failed merges:
2 parents b76f818 + 2e9b40f commit 98f0a91

File tree

19 files changed

+173
-32
lines changed

19 files changed

+173
-32
lines changed

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ then
10341034
if [ -n "$CFG_OSX_CLANG_VERSION" ]
10351035
then
10361036
case $CFG_OSX_CLANG_VERSION in
1037-
(7.0* | 7.1* | 7.2*)
1037+
(7.0* | 7.1* | 7.2* | 7.3*)
10381038
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
10391039
;;
10401040
(*)

src/doc/book/lifetimes.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,12 @@ to it.
282282

283283
## Lifetime Elision
284284

285-
Rust supports powerful local type inference in function bodies, but it’s
286-
forbidden in item signatures to allow reasoning about the types based on
287-
the item signature alone. However, for ergonomic reasons a very restricted
288-
secondary inference algorithm called “lifetime elision” applies in function
289-
signatures. It infers only based on the signature components themselves and not
290-
based on the body of the function, only infers lifetime parameters, and does
291-
this with only three easily memorizable and unambiguous rules. This makes
292-
lifetime elision a shorthand for writing an item signature, while not hiding
285+
Rust supports powerful local type inference in the bodies of functions but not in their item signatures.
286+
It's forbidden to allow reasoning about types based on the item signature alone.
287+
However, for ergonomic reasons, a very restricted secondary inference algorithm called
288+
“lifetime elision” does apply when judging lifetimes. Lifetime elision is concerned solely to infer
289+
lifetime parameters using three easily memorizable and unambiguous rules. This means lifetime elision
290+
acts as a shorthand for writing an item signature, while not hiding
293291
away the actual types involved as full local inference would if applied to it.
294292

295293
When talking about lifetime elision, we use the term *input lifetime* and

src/doc/book/patterns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Patterns
22

33
Patterns are quite common in Rust. We use them in [variable
4-
bindings][bindings], [match statements][match], and other places, too. Let’s go
4+
bindings][bindings], [match expressions][match], and other places, too. Let’s go
55
on a whirlwind tour of all of the things patterns can do!
66

77
[bindings]: variable-bindings.html

src/librustc_trans/trans/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
381381
llconst = addr_of(cx, llconst, type_of::align_of(cx, ty), "autoref");
382382
ty = cx.tcx().mk_imm_ref(cx.tcx().mk_region(ty::ReStatic), ty);
383383
}
384-
} else {
384+
} else if adj.autoderefs > 0 {
385385
let (dv, dt) = const_deref(cx, llconst, ty);
386386
llconst = dv;
387387

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub fn build_impls(cx: &DocContext,
256256
cstore::DlImpl(did) => build_impl(cx, tcx, did, impls),
257257
cstore::DlDef(Def::Mod(did)) => {
258258
// Don't recurse if this is a #[doc(hidden)] module
259-
if load_attrs(cx, tcx, did).list_def("doc").has_word("hidden") {
259+
if load_attrs(cx, tcx, did).list("doc").has_word("hidden") {
260260
return;
261261
}
262262

@@ -299,7 +299,7 @@ pub fn build_impl(cx: &DocContext,
299299
if let Some(ref t) = associated_trait {
300300
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline
301301
let trait_attrs = load_attrs(cx, tcx, t.def_id);
302-
if trait_attrs.list_def("doc").has_word("hidden") {
302+
if trait_attrs.list("doc").has_word("hidden") {
303303
return
304304
}
305305
}

src/librustdoc/clean/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ impl Clean<Item> for doctree::Module {
418418
pub trait Attributes {
419419
fn has_word(&self, &str) -> bool;
420420
fn value<'a>(&'a self, &str) -> Option<&'a str>;
421-
fn list_def<'a>(&'a self, &str) -> &'a [Attribute];
421+
fn list<'a>(&'a self, &str) -> &'a [Attribute];
422422
}
423423

424424
impl Attributes for [Attribute] {
@@ -447,7 +447,7 @@ impl Attributes for [Attribute] {
447447
}
448448

449449
/// Finds an attribute as List and returns the list of attributes nested inside.
450-
fn list_def<'a>(&'a self, name: &str) -> &'a [Attribute] {
450+
fn list<'a>(&'a self, name: &str) -> &'a [Attribute] {
451451
for attr in self {
452452
if let List(ref x, ref list) = *attr {
453453
if name == *x {
@@ -1535,7 +1535,7 @@ impl PrimitiveType {
15351535
}
15361536

15371537
fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
1538-
for attr in attrs.list_def("doc") {
1538+
for attr in attrs.list("doc") {
15391539
if let NameValue(ref k, ref v) = *attr {
15401540
if "primitive" == *k {
15411541
if let ret@Some(..) = PrimitiveType::from_str(v) {
@@ -1885,7 +1885,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
18851885
source: Span::empty(),
18861886
name: Some(field.name.clean(cx)),
18871887
attrs: Vec::new(),
1888-
visibility: Some(hir::Public),
1888+
visibility: Some(field.vis),
18891889
// FIXME: this is not accurate, we need an id for
18901890
// the specific field but we're using the id
18911891
// for the whole variant. Thus we read the

src/librustdoc/html/render.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ pub fn run(mut krate: clean::Crate,
432432

433433
// Crawl the crate attributes looking for attributes which control how we're
434434
// going to emit HTML
435-
if let Some(attrs) = krate.module.as_ref().map(|m| m.attrs.list_def("doc")) {
435+
if let Some(attrs) = krate.module.as_ref().map(|m| m.attrs.list("doc")) {
436436
for attr in attrs {
437437
match *attr {
438438
clean::NameValue(ref x, ref s)
@@ -832,7 +832,7 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
832832

833833
// Failing that, see if there's an attribute specifying where to find this
834834
// external crate
835-
e.attrs.list_def("doc").value("html_root_url").map(|url| {
835+
e.attrs.list("doc").value("html_root_url").map(|url| {
836836
let mut url = url.to_owned();
837837
if !url.ends_with("/") {
838838
url.push('/')
@@ -1845,6 +1845,7 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18451845

18461846
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
18471847
f: &clean::Function) -> fmt::Result {
1848+
// FIXME(#24111): remove when `const_fn` is stabilized
18481849
let vis_constness = match get_unstable_features_setting() {
18491850
UnstableFeatures::Allow => f.constness,
18501851
_ => hir::Constness::NotConst

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
384384

385385
// Process all of the crate attributes, extracting plugin metadata along
386386
// with the passes which we are supposed to run.
387-
for attr in krate.module.as_ref().unwrap().attrs.list_def("doc") {
387+
for attr in krate.module.as_ref().unwrap().attrs.list("doc") {
388388
match *attr {
389389
clean::Word(ref w) if "no_default_passes" == *w => {
390390
default_passes = false;

src/librustdoc/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
3333
}
3434
impl<'a> fold::DocFolder for Stripper<'a> {
3535
fn fold_item(&mut self, i: Item) -> Option<Item> {
36-
if i.attrs.list_def("doc").has_word("hidden") {
36+
if i.attrs.list("doc").has_word("hidden") {
3737
debug!("found one in strip_hidden; removing");
3838
self.stripped.insert(i.def_id);
3939

src/librustdoc/visit_ast.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
229229
while let Some(id) = cx.map.get_enclosing_scope(node) {
230230
node = id;
231231
let attrs = cx.map.attrs(node).clean(cx);
232-
if attrs.list_def("doc").has_word("hidden") {
232+
if attrs.list("doc").has_word("hidden") {
233233
return true;
234234
}
235235
if node == ast::CRATE_NODE_ID {
@@ -251,11 +251,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
251251
Some(analysis) => analysis, None => return false
252252
};
253253

254+
let use_attrs = tcx.map.attrs(id).clean(self.cx);
255+
254256
let is_private = !analysis.access_levels.is_public(def);
255257
let is_hidden = inherits_doc_hidden(self.cx, def_node_id);
258+
let is_no_inline = use_attrs.list("doc").has_word("no_inline");
256259

257260
// Only inline if requested or if the item would otherwise be stripped
258-
if !please_inline && !is_private && !is_hidden {
261+
if (!please_inline && !is_private && !is_hidden) || is_no_inline {
259262
return false
260263
}
261264

src/libstd/ffi/os_str.rs

+28
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ impl ops::Deref for OsString {
173173
}
174174
}
175175

176+
#[stable(feature = "osstring_default", since = "1.9.0")]
177+
impl Default for OsString {
178+
#[inline]
179+
fn default() -> OsString {
180+
OsString::new()
181+
}
182+
}
183+
176184
#[stable(feature = "rust1", since = "1.0.0")]
177185
impl Debug for OsString {
178186
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
@@ -302,6 +310,14 @@ impl OsStr {
302310
}
303311
}
304312

313+
#[stable(feature = "osstring_default", since = "1.9.0")]
314+
impl<'a> Default for &'a OsStr {
315+
#[inline]
316+
fn default() -> &'a OsStr {
317+
OsStr::new("")
318+
}
319+
}
320+
305321
#[stable(feature = "rust1", since = "1.0.0")]
306322
impl PartialEq for OsStr {
307323
fn eq(&self, other: &OsStr) -> bool {
@@ -554,6 +570,12 @@ mod tests {
554570
assert!(os_string.capacity() >= 33)
555571
}
556572

573+
#[test]
574+
fn test_os_string_default() {
575+
let os_string: OsString = Default::default();
576+
assert_eq!("", &os_string);
577+
}
578+
557579
#[test]
558580
fn test_os_str_is_empty() {
559581
let mut os_string = OsString::new();
@@ -577,4 +599,10 @@ mod tests {
577599
os_string.clear();
578600
assert_eq!(0, os_string.len());
579601
}
602+
603+
#[test]
604+
fn test_os_str_default() {
605+
let os_str: &OsStr = Default::default();
606+
assert_eq!("", os_str);
607+
}
580608
}

src/libstd/net/addr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ impl SocketAddrV6 {
143143
sin6_family: c::AF_INET6 as c::sa_family_t,
144144
sin6_port: hton(port),
145145
sin6_addr: *ip.as_inner(),
146-
sin6_flowinfo: hton(flowinfo),
147-
sin6_scope_id: hton(scope_id),
146+
sin6_flowinfo: flowinfo,
147+
sin6_scope_id: scope_id,
148148
.. unsafe { mem::zeroed() }
149149
},
150150
}
@@ -173,23 +173,23 @@ impl SocketAddrV6 {
173173
/// Returns the flow information associated with this address,
174174
/// corresponding to the `sin6_flowinfo` field in C.
175175
#[stable(feature = "rust1", since = "1.0.0")]
176-
pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
176+
pub fn flowinfo(&self) -> u32 { self.inner.sin6_flowinfo }
177177

178178
/// Change the flow information associated with this socket address.
179179
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
180180
pub fn set_flowinfo(&mut self, new_flowinfo: u32) {
181-
self.inner.sin6_flowinfo = hton(new_flowinfo)
181+
self.inner.sin6_flowinfo = new_flowinfo;
182182
}
183183

184184
/// Returns the scope ID associated with this address,
185185
/// corresponding to the `sin6_scope_id` field in C.
186186
#[stable(feature = "rust1", since = "1.0.0")]
187-
pub fn scope_id(&self) -> u32 { ntoh(self.inner.sin6_scope_id) }
187+
pub fn scope_id(&self) -> u32 { self.inner.sin6_scope_id }
188188

189189
/// Change the scope ID associated with this socket address.
190190
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
191191
pub fn set_scope_id(&mut self, new_scope_id: u32) {
192-
self.inner.sin6_scope_id = hton(new_scope_id)
192+
self.inner.sin6_scope_id = new_scope_id;
193193
}
194194
}
195195

src/libstd/primitive_docs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mod prim_bool { }
7777
/// # Representation
7878
///
7979
/// `char` is always four bytes in size. This is a different representation than
80-
/// a given character would have as part of a [`String`], for example:
80+
/// a given character would have as part of a [`String`]. For example:
8181
///
8282
/// ```
8383
/// let v = vec!['h', 'e', 'l', 'l', 'o'];
@@ -116,8 +116,8 @@ mod prim_bool { }
116116
/// ^~
117117
/// ```
118118
///
119-
/// Another implication of the 4-byte fixed size of a `char`, is that
120-
/// per-`char`acter processing can end up using a lot more memory:
119+
/// Another implication of the 4-byte fixed size of a `char` is that
120+
/// per-`char` processing can end up using a lot more memory:
121121
///
122122
/// ```
123123
/// let s = String::from("love: ❤️");

src/test/auxiliary/variant-struct.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
pub enum Foo {
12+
Bar {
13+
qux: (),
14+
}
15+
}

src/test/run-pass/backtrace.rs

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

11+
#![feature(rustc_attrs)]
12+
1113
// no-pretty-expanded FIXME #15189
1214
// ignore-android FIXME #17520
1315
// compile-flags:-g
@@ -16,6 +18,8 @@ use std::env;
1618
use std::process::{Command, Stdio};
1719
use std::str;
1820

21+
// FIXME #31005 MIR missing debuginfo currently.
22+
#[cfg_attr(target_env = "msvc", rustc_no_mir)]
1923
#[inline(never)]
2024
fn foo() {
2125
let _v = vec![1, 2, 3];
@@ -24,6 +28,8 @@ fn foo() {
2428
}
2529
}
2630

31+
// FIXME #31005 MIR missing debuginfo currently.
32+
#[cfg_attr(target_env = "msvc", rustc_no_mir)]
2733
#[inline(never)]
2834
fn double() {
2935
struct Double;

src/test/run-pass/issue-26997.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
pub struct Foo {
12+
x: isize,
13+
y: isize
14+
}
15+
16+
impl Foo {
17+
pub extern fn foo_new() -> Foo {
18+
Foo { x: 21, y: 33 }
19+
}
20+
}
21+
22+
fn main() {}

src/test/run-pass/issue-30615.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
fn main() {
12+
&0u8 as *const u8 as *const PartialEq<u8>;
13+
&[0u8] as *const [u8; 1] as *const [u8];
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// @!has issue_32343/struct.Foo.html
12+
// @has issue_32343/index.html
13+
// @has - '//code' 'pub use foo::Foo'
14+
// @!has - '//code/a' 'Foo'
15+
#[doc(no_inline)]
16+
pub use foo::Foo;
17+
18+
// @!has issue_32343/struct.Bar.html
19+
// @has issue_32343/index.html
20+
// @has - '//code' 'pub use foo::Bar'
21+
// @has - '//code/a' 'Bar'
22+
#[doc(no_inline)]
23+
pub use foo::Bar;
24+
25+
mod foo {
26+
pub struct Foo;
27+
pub struct Bar;
28+
}
29+
30+
pub mod bar {
31+
// @has issue_32343/bar/struct.Bar.html
32+
pub use ::foo::Bar;
33+
}

0 commit comments

Comments
 (0)