diff --git a/configure b/configure index 34132b7e5f535..9a0143a353275 100755 --- a/configure +++ b/configure @@ -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" ;; (*) diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md index 4193c93c894c4..e7a4045d9b249 100644 --- a/src/doc/book/lifetimes.md +++ b/src/doc/book/lifetimes.md @@ -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 diff --git a/src/doc/book/patterns.md b/src/doc/book/patterns.md index 7325d448962cf..7ecfdcfcc1e02 100644 --- a/src/doc/book/patterns.md +++ b/src/doc/book/patterns.md @@ -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 diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index dd6856916f603..a1ba05840a1ae 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -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; diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 49091a6c2bcfc..e9c55c56a9d72 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -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; } @@ -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 } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 54821bd1161ee..cca027ca17a01 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -418,7 +418,7 @@ impl Clean 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] { @@ -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 { @@ -1535,7 +1535,7 @@ impl PrimitiveType { } fn find(attrs: &[Attribute]) -> Option { - 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) { @@ -1885,7 +1885,7 @@ impl<'tcx> Clean 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 diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9e74702e06c96..071e3dd6bd010 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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) @@ -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('/') @@ -1845,6 +1845,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 diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index cde472a3b20bd..90cb78f46a67c 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -384,7 +384,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; diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 2eb82dec6daa4..154b812cdff3e 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -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 { - 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); diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 4c03abac9e867..e4ef0c1a4d630 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -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 { @@ -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 } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 46f2d3a64181b..de840457a01f4 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -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> { @@ -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 { @@ -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(); @@ -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); + } } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 273a2004fc0f2..a915872d8ac94 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -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() } }, } @@ -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; } } diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 65ed879c4ada4..c8ea28c5ca39f 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -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']; @@ -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: ❤️"); diff --git a/src/test/auxiliary/variant-struct.rs b/src/test/auxiliary/variant-struct.rs new file mode 100644 index 0000000000000..d846c0adf6171 --- /dev/null +++ b/src/test/auxiliary/variant-struct.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Foo { + Bar { + qux: (), + } +} diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 3fb52f8c8b4dc..2a98706351a8b 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -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 @@ -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]; @@ -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; diff --git a/src/test/run-pass/issue-26997.rs b/src/test/run-pass/issue-26997.rs new file mode 100644 index 0000000000000..e7ecf68f10897 --- /dev/null +++ b/src/test/run-pass/issue-26997.rs @@ -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 or the MIT license +// , 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() {} diff --git a/src/test/run-pass/issue-30615.rs b/src/test/run-pass/issue-30615.rs new file mode 100644 index 0000000000000..a26509d19829c --- /dev/null +++ b/src/test/run-pass/issue-30615.rs @@ -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 or the MIT license +// , 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; + &[0u8] as *const [u8; 1] as *const [u8]; +} diff --git a/src/test/rustdoc/inline_local/issue-32343.rs b/src/test/rustdoc/inline_local/issue-32343.rs new file mode 100644 index 0000000000000..a045c9624b1a1 --- /dev/null +++ b/src/test/rustdoc/inline_local/issue-32343.rs @@ -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 or the MIT license +// , 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; +} diff --git a/src/test/rustdoc/issue-32395.rs b/src/test/rustdoc/issue-32395.rs new file mode 100644 index 0000000000000..fba2a6ad4877c --- /dev/null +++ b/src/test/rustdoc/issue-32395.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:variant-struct.rs +// build-aux-docs +// ignore-cross-compile + +// @has variant_struct/enum.Foo.html +// @!has - 'pub qux' +extern crate variant_struct; + +// @has issue_32395/enum.Foo.html +// @!has - 'pub qux' +pub use variant_struct::Foo;