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 11 pull requests #32454

Merged
merged 24 commits into from
Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
08eaf07
Implement Default for OsString
WiSaGaN Mar 21, 2016
aa5afb0
Implement Default for OsStr
WiSaGaN Mar 21, 2016
b5b1d06
Fix Default for OsString/OsStr
WiSaGaN Mar 21, 2016
9575fe7
Add regression test for Issue 26997.
frewsxcv Mar 22, 2016
00a32b2
Omit `pub` for inlined variant-struct fields
mitaa Mar 22, 2016
7d626e9
doc: small char improvements
tshepang Mar 22, 2016
79da64a
Added version 7.3* for Apple's clang compiler
agbaroni Mar 22, 2016
88506ce
std: Store flowinfo/scope_id in host byte order
alexcrichton Mar 22, 2016
308dc55
Fix const trans
sanxiyn Mar 22, 2016
45c72d5
Simplifying some of the phrasing explaining lifetime elision
nicholasf Mar 22, 2016
4c71347
Consider `doc(no_inline)` in crate-local inlining
mitaa Mar 22, 2016
424fa43
Annotate run-pass/backtrace with #[rustc_no_mir] on MSVC.
eddyb Mar 23, 2016
ea9ae48
Docs: Change "statements" to "expressions" on `match`
tclfs Mar 23, 2016
2de428e
Rollup merge of #32404 - WiSaGaN:feature/osstring-implement-default, …
eddyb Mar 23, 2016
6b4b65a
Rollup merge of #32420 - frewsxcv:regression-test-26997, r=alexcrichton
eddyb Mar 23, 2016
46b2a99
Rollup merge of #32423 - mitaa:rdoc-vstruct-fields, r=alexcrichton
eddyb Mar 23, 2016
0c424f9
Rollup merge of #32425 - ituxbag:master, r=alexcrichton
eddyb Mar 23, 2016
c028b1c
Rollup merge of #32429 - alexcrichton:scope-id-hton, r=aturon
eddyb Mar 23, 2016
12e54bb
Rollup merge of #32430 - sanxiyn:const-trans, r=arielb1
eddyb Mar 23, 2016
d7bf3d3
Rollup merge of #32431 - nicholasf:tweak/improve-expression, r=stevek…
eddyb Mar 23, 2016
2acad9c
Rollup merge of #32434 - mitaa:rdoc-no-inline, r=alexcrichton
eddyb Mar 23, 2016
3fd144d
Rollup merge of #32437 - eddyb:orbital-msvc, r=alexcrichton
eddyb Mar 23, 2016
7f2612e
Rollup merge of #32441 - tshepang:doc-primitive, r=steveklabnik
eddyb Mar 23, 2016
2e9b40f
Rollup merge of #32443 - tclfs:patch-8, r=steveklabnik
eddyb Mar 23, 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
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ then
if [ -n "$CFG_OSX_CLANG_VERSION" ]
then
case $CFG_OSX_CLANG_VERSION in
(7.0* | 7.1* | 7.2*)
(7.0* | 7.1* | 7.2* | 7.3*)
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
;;
(*)
Expand Down
14 changes: 6 additions & 8 deletions src/doc/book/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,12 @@ to it.

## Lifetime Elision

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

When talking about lifetime elision, we use the term *input lifetime* and
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/patterns.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Patterns

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

[bindings]: variable-bindings.html
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
llconst = addr_of(cx, llconst, type_of::align_of(cx, ty), "autoref");
ty = cx.tcx().mk_imm_ref(cx.tcx().mk_region(ty::ReStatic), ty);
}
} else {
} else if adj.autoderefs > 0 {
let (dv, dt) = const_deref(cx, llconst, ty);
llconst = dv;

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub fn build_impls(cx: &DocContext,
cstore::DlImpl(did) => build_impl(cx, tcx, did, impls),
cstore::DlDef(Def::Mod(did)) => {
// Don't recurse if this is a #[doc(hidden)] module
if load_attrs(cx, tcx, did).list_def("doc").has_word("hidden") {
if load_attrs(cx, tcx, did).list("doc").has_word("hidden") {
return;
}

Expand Down Expand Up @@ -299,7 +299,7 @@ pub fn build_impl(cx: &DocContext,
if let Some(ref t) = associated_trait {
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline
let trait_attrs = load_attrs(cx, tcx, t.def_id);
if trait_attrs.list_def("doc").has_word("hidden") {
if trait_attrs.list("doc").has_word("hidden") {
return
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl Clean<Item> for doctree::Module {
pub trait Attributes {
fn has_word(&self, &str) -> bool;
fn value<'a>(&'a self, &str) -> Option<&'a str>;
fn list_def<'a>(&'a self, &str) -> &'a [Attribute];
fn list<'a>(&'a self, &str) -> &'a [Attribute];
}

impl Attributes for [Attribute] {
Expand Down Expand Up @@ -447,7 +447,7 @@ impl Attributes for [Attribute] {
}

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

fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
for attr in attrs.list_def("doc") {
for attr in attrs.list("doc") {
if let NameValue(ref k, ref v) = *attr {
if "primitive" == *k {
if let ret@Some(..) = PrimitiveType::from_str(v) {
Expand Down Expand Up @@ -1885,7 +1885,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
source: Span::empty(),
name: Some(field.name.clean(cx)),
attrs: Vec::new(),
visibility: Some(hir::Public),
visibility: Some(field.vis),
// FIXME: this is not accurate, we need an id for
// the specific field but we're using the id
// for the whole variant. Thus we read the
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ pub fn run(mut krate: clean::Crate,

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

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

fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
f: &clean::Function) -> fmt::Result {
// FIXME(#24111): remove when `const_fn` is stabilized
let vis_constness = match get_unstable_features_setting() {
UnstableFeatures::Allow => f.constness,
_ => hir::Constness::NotConst
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche

// Process all of the crate attributes, extracting plugin metadata along
// with the passes which we are supposed to run.
for attr in krate.module.as_ref().unwrap().attrs.list_def("doc") {
for attr in krate.module.as_ref().unwrap().attrs.list("doc") {
match *attr {
clean::Word(ref w) if "no_default_passes" == *w => {
default_passes = false;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
}
impl<'a> fold::DocFolder for Stripper<'a> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
if i.attrs.list_def("doc").has_word("hidden") {
if i.attrs.list("doc").has_word("hidden") {
debug!("found one in strip_hidden; removing");
self.stripped.insert(i.def_id);

Expand Down
7 changes: 5 additions & 2 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
while let Some(id) = cx.map.get_enclosing_scope(node) {
node = id;
let attrs = cx.map.attrs(node).clean(cx);
if attrs.list_def("doc").has_word("hidden") {
if attrs.list("doc").has_word("hidden") {
return true;
}
if node == ast::CRATE_NODE_ID {
Expand All @@ -251,11 +251,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
Some(analysis) => analysis, None => return false
};

let use_attrs = tcx.map.attrs(id).clean(self.cx);

let is_private = !analysis.access_levels.is_public(def);
let is_hidden = inherits_doc_hidden(self.cx, def_node_id);
let is_no_inline = use_attrs.list("doc").has_word("no_inline");

// Only inline if requested or if the item would otherwise be stripped
if !please_inline && !is_private && !is_hidden {
if (!please_inline && !is_private && !is_hidden) || is_no_inline {
return false
}

Expand Down
28 changes: 28 additions & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ impl ops::Deref for OsString {
}
}

#[stable(feature = "osstring_default", since = "1.9.0")]
impl Default for OsString {
#[inline]
fn default() -> OsString {
OsString::new()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for OsString {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
Expand Down Expand Up @@ -302,6 +310,14 @@ impl OsStr {
}
}

#[stable(feature = "osstring_default", since = "1.9.0")]
impl<'a> Default for &'a OsStr {
#[inline]
fn default() -> &'a OsStr {
OsStr::new("")
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for OsStr {
fn eq(&self, other: &OsStr) -> bool {
Expand Down Expand Up @@ -554,6 +570,12 @@ mod tests {
assert!(os_string.capacity() >= 33)
}

#[test]
fn test_os_string_default() {
let os_string: OsString = Default::default();
assert_eq!("", &os_string);
}

#[test]
fn test_os_str_is_empty() {
let mut os_string = OsString::new();
Expand All @@ -577,4 +599,10 @@ mod tests {
os_string.clear();
assert_eq!(0, os_string.len());
}

#[test]
fn test_os_str_default() {
let os_str: &OsStr = Default::default();
assert_eq!("", os_str);
}
}
12 changes: 6 additions & 6 deletions src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ impl SocketAddrV6 {
sin6_family: c::AF_INET6 as c::sa_family_t,
sin6_port: hton(port),
sin6_addr: *ip.as_inner(),
sin6_flowinfo: hton(flowinfo),
sin6_scope_id: hton(scope_id),
sin6_flowinfo: flowinfo,
sin6_scope_id: scope_id,
.. unsafe { mem::zeroed() }
},
}
Expand Down Expand Up @@ -173,23 +173,23 @@ impl SocketAddrV6 {
/// Returns the flow information associated with this address,
/// corresponding to the `sin6_flowinfo` field in C.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
pub fn flowinfo(&self) -> u32 { self.inner.sin6_flowinfo }

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod prim_bool { }
/// # Representation
///
/// `char` is always four bytes in size. This is a different representation than
/// a given character would have as part of a [`String`], for example:
/// a given character would have as part of a [`String`]. For example:
///
/// ```
/// let v = vec!['h', 'e', 'l', 'l', 'o'];
Expand Down Expand Up @@ -116,8 +116,8 @@ mod prim_bool { }
/// ^~
/// ```
///
/// Another implication of the 4-byte fixed size of a `char`, is that
/// per-`char`acter processing can end up using a lot more memory:
/// Another implication of the 4-byte fixed size of a `char` is that
/// per-`char` processing can end up using a lot more memory:
///
/// ```
/// let s = String::from("love: ❤️");
Expand Down
15 changes: 15 additions & 0 deletions src/test/auxiliary/variant-struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

pub enum Foo {
Bar {
qux: (),
}
}
6 changes: 6 additions & 0 deletions src/test/run-pass/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(rustc_attrs)]

// no-pretty-expanded FIXME #15189
// ignore-android FIXME #17520
// compile-flags:-g
Expand All @@ -16,6 +18,8 @@ use std::env;
use std::process::{Command, Stdio};
use std::str;

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

// FIXME #31005 MIR missing debuginfo currently.
#[cfg_attr(target_env = "msvc", rustc_no_mir)]
#[inline(never)]
fn double() {
struct Double;
Expand Down
22 changes: 22 additions & 0 deletions src/test/run-pass/issue-26997.rs
Original file line number Diff line number Diff line change
@@ -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 <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.

pub struct Foo {
x: isize,
y: isize
}

impl Foo {
pub extern fn foo_new() -> Foo {
Foo { x: 21, y: 33 }
}
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/run-pass/issue-30615.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

fn main() {
&0u8 as *const u8 as *const PartialEq<u8>;
&[0u8] as *const [u8; 1] as *const [u8];
}
33 changes: 33 additions & 0 deletions src/test/rustdoc/inline_local/issue-32343.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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.

// @!has issue_32343/struct.Foo.html
// @has issue_32343/index.html
// @has - '//code' 'pub use foo::Foo'
// @!has - '//code/a' 'Foo'
#[doc(no_inline)]
pub use foo::Foo;

// @!has issue_32343/struct.Bar.html
// @has issue_32343/index.html
// @has - '//code' 'pub use foo::Bar'
// @has - '//code/a' 'Bar'
#[doc(no_inline)]
pub use foo::Bar;

mod foo {
pub struct Foo;
pub struct Bar;
}

pub mod bar {
// @has issue_32343/bar/struct.Bar.html
pub use ::foo::Bar;
}
Loading