diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d42476bc4130d..cec891b4ee502 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -12,13 +12,13 @@ A version of this document [can be found online](https://www.rust-lang.org/condu * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. * Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. * We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behaviour. We interpret the term "harassment" as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. -* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team](/team.html#Moderation) immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. +* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. * Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome. ## Moderation -These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, please contact the [Rust moderation team](/team.html#Moderation). +These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, please contact the [Rust moderation team][mod_team]. 1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) 2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed. @@ -36,3 +36,5 @@ And if someone takes issue with something you said or did, resist the urge to be The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. *Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](http://contributor-covenant.org/version/1/3/0/).* + +[mod_team]: https://www.rust-lang.org/team.html#Moderation-team diff --git a/src/Cargo.lock b/src/Cargo.lock index c22187ee13e8e..e7297147081f5 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -287,14 +287,14 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.174" +version = "0.0.177" dependencies = [ "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy-mini-macro-test 0.1.0", - "clippy_lints 0.0.174", + "clippy-mini-macro-test 0.2.0", + "clippy_lints 0.0.177", "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -302,15 +302,15 @@ dependencies = [ [[package]] name = "clippy-mini-macro-test" -version = "0.1.0" +version = "0.2.0" [[package]] name = "clippy_lints" -version = "0.0.174" +version = "0.0.177" dependencies = [ "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -967,6 +967,11 @@ name = "lazy_static" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazy_static" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lazycell" version = "0.5.1" @@ -2813,6 +2818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum kuchiki 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e03098e8e719c92b7794515dfd5c1724e2b12f5ce1788e61cfa4663f82eba8d8" "checksum languageserver-types 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "773e175c945800aeea4c21c04090bcb9db987b1a566ad9c6f569972299950e3e" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" "checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0" "checksum libgit2-sys 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "6f74b4959cef96898f5123148724fc7dee043b9a6b99f219d948851bfbe53cb2" diff --git a/src/etc/platform-intrinsics/x86/avx2.json b/src/etc/platform-intrinsics/x86/avx2.json index 4e006c1c4cf41..dc055b583c568 100644 --- a/src/etc/platform-intrinsics/x86/avx2.json +++ b/src/etc/platform-intrinsics/x86/avx2.json @@ -174,7 +174,7 @@ "intrinsic": "256_sad_epu8", "width": [256], "llvm": "psad.bw", - "ret": "u8", + "ret": "u64", "args": ["0", "0"] }, { diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 18bb13d847a87..ab574c9f7e769 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -699,7 +699,7 @@ impl [T] { core_slice::SliceExt::split_at(self, mid) } - /// Divides one `&mut` into two at an index. + /// Divides one mutable slice into two at an index. /// /// The first will contain all indices from `[0, mid)` (excluding /// the index `mid` itself) and the second will contain all diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 43d38926c9718..7f758f2a23b19 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -8,7 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for 32-bits floats (`f32` type) +//! This module provides constants which are specific to the implementation +//! of the `f32` floating point data type. +//! +//! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! *[See also the `f32` primitive type](../../std/primitive.f32.html).* #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 4ff80a2f05d41..b9db4990a7e5f 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -8,7 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for 64-bits floats (`f64` type) +//! This module provides constants which are specific to the implementation +//! of the `f64` floating point data type. +//! +//! Mathematically significant numbers are provided in the `consts` sub-module. +//! +//! *[See also the `f64` primitive type](../../std/primitive.f64.html).* #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 0de1c20dbde1e..54bcc64d0685d 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -791,10 +791,7 @@ impl Session { // As a result 16 was chosen here! Mostly because it was a power of 2 // and most benchmarks agreed it was roughly a local optimum. Not very // scientific. - match self.opts.optimize { - config::OptLevel::No => 16, - _ => 1, // FIXME(#46346) this should be 16 - } + 16 } /// Returns whether ThinLTO is enabled for this compilation diff --git a/src/librustc_back/target/aarch64_unknown_cloudabi.rs b/src/librustc_back/target/aarch64_unknown_cloudabi.rs new file mode 100644 index 0000000000000..d5e8194c3f79b --- /dev/null +++ b/src/librustc_back/target/aarch64_unknown_cloudabi.rs @@ -0,0 +1,32 @@ +// Copyright 2017 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. + +use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::cloudabi_base::opts(); + base.max_atomic_width = Some(128); + base.abi_blacklist = super::arm_base::abi_blacklist(); + + Ok(Target { + llvm_target: "aarch64-unknown-cloudabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), + arch: "aarch64".to_string(), + target_os: "cloudabi".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs b/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs new file mode 100644 index 0000000000000..4dad8e1713b43 --- /dev/null +++ b/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs @@ -0,0 +1,34 @@ +// Copyright 2017 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. + +use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::cloudabi_base::opts(); + base.cpu = "cortex-a8".to_string(); + base.max_atomic_width = Some(64); + base.features = "+v7,+vfp3,+neon".to_string(); + base.abi_blacklist = super::arm_base::abi_blacklist(); + + Ok(Target { + llvm_target: "armv7-unknown-cloudabi-eabihf".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "cloudabi".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_back/target/cloudabi_base.rs b/src/librustc_back/target/cloudabi_base.rs new file mode 100644 index 0000000000000..c29130bdf8e96 --- /dev/null +++ b/src/librustc_back/target/cloudabi_base.rs @@ -0,0 +1,34 @@ +// Copyright 2017 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. + +use LinkerFlavor; +use target::{LinkArgs, TargetOptions, RelroLevel}; +use std::default::Default; + +pub fn opts() -> TargetOptions { + let mut args = LinkArgs::new(); + args.insert(LinkerFlavor::Gcc, vec![ + "-Wl,-Bstatic".to_string(), + "-Wl,--no-dynamic-linker".to_string(), + "-Wl,--eh-frame-hdr".to_string(), + "-Wl,--gc-sections".to_string(), + ]); + + TargetOptions { + executables: true, + target_family: Some("unix".to_string()), + linker_is_gnu: true, + pre_link_args: args, + position_independent_executables: true, + relro_level: RelroLevel::Full, + exe_allocation_crate: super::maybe_jemalloc(), + .. Default::default() + } +} diff --git a/src/librustc_back/target/i686_unknown_cloudabi.rs b/src/librustc_back/target/i686_unknown_cloudabi.rs new file mode 100644 index 0000000000000..b9aa6176d8768 --- /dev/null +++ b/src/librustc_back/target/i686_unknown_cloudabi.rs @@ -0,0 +1,34 @@ +// Copyright 2017 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. + +use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::cloudabi_base::opts(); + base.cpu = "pentium4".to_string(); + base.max_atomic_width = Some(64); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); + base.stack_probes = true; + + Ok(Target { + llvm_target: "i686-unknown-cloudabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(), + arch: "x86".to_string(), + target_os: "cloudabi".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 6f9ba5dada2d8..5c18e82fe3a92 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -57,6 +57,7 @@ mod apple_base; mod apple_ios_base; mod arm_base; mod bitrig_base; +mod cloudabi_base; mod dragonfly_base; mod emscripten_base; mod freebsd_base; @@ -227,6 +228,11 @@ supported_targets! { ("thumbv7em-none-eabihf", thumbv7em_none_eabihf), ("msp430-none-elf", msp430_none_elf), + + ("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi), + ("armv7-unknown-cloudabi-eabihf", armv7_unknown_cloudabi_eabihf), + ("i686-unknown-cloudabi", i686_unknown_cloudabi), + ("x86_64-unknown-cloudabi", x86_64_unknown_cloudabi), } /// Everything `rustc` knows about how to compile for a specific target. diff --git a/src/librustc_back/target/x86_64_unknown_cloudabi.rs b/src/librustc_back/target/x86_64_unknown_cloudabi.rs new file mode 100644 index 0000000000000..f9a563174d4a9 --- /dev/null +++ b/src/librustc_back/target/x86_64_unknown_cloudabi.rs @@ -0,0 +1,34 @@ +// Copyright 2017 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. + +use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::cloudabi_base::opts(); + base.cpu = "x86-64".to_string(); + base.max_atomic_width = Some(64); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); + base.stack_probes = true; + + Ok(Target { + llvm_target: "x86_64-unknown-cloudabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(), + arch: "x86_64".to_string(), + target_os: "cloudabi".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_platform_intrinsics/x86.rs b/src/librustc_platform_intrinsics/x86.rs index acb69423ffee3..e23222ad50b80 100644 --- a/src/librustc_platform_intrinsics/x86.rs +++ b/src/librustc_platform_intrinsics/x86.rs @@ -354,7 +354,7 @@ pub fn find(name: &str) -> Option { }, "_mm256_sad_epu8" => Intrinsic { inputs: { static INPUTS: [&'static Type; 2] = [&::U8x32, &::U8x32]; &INPUTS }, - output: &::U8x32, + output: &::U64x4, definition: Named("llvm.x86.avx2.psad.bw") }, "_mm256_shuffle_epi8" => Intrinsic { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index dc157f682fcea..10cb2e5f3fdaf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -33,7 +33,6 @@ use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc::traits::Reveal; use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, AdtKind}; use rustc::middle::stability; @@ -2062,7 +2061,7 @@ impl Clean for hir::Ty { TySlice(ref ty) => Slice(box ty.clean(cx)), TyArray(ref ty, n) => { let def_id = cx.tcx.hir.body_owner_def_id(n); - let param_env = ty::ParamEnv::empty(Reveal::UserFacing); + let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap(); let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { @@ -2191,6 +2190,11 @@ impl<'tcx> Clean for Ty<'tcx> { ty::TyStr => Primitive(PrimitiveType::Str), ty::TySlice(ty) => Slice(box ty.clean(cx)), ty::TyArray(ty, n) => { + let mut n = cx.tcx.lift(&n).unwrap(); + if let ConstVal::Unevaluated(def_id, substs) = n.val { + let param_env = cx.tcx.param_env(def_id); + n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap() + }; let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() } else if let ConstVal::Unevaluated(def_id, _) = n.val { diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index e5b1394f0709a..6d76c7e722c45 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -13,7 +13,7 @@ //! //! Mathematically significant numbers are provided in the `consts` sub-module. //! -//! *[See also the `f32` primitive type](../primitive.f32.html).* +//! *[See also the `f32` primitive type](../../std/primitive.f32.html).* #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index f4d804fd50823..dee9566f1fc68 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -13,7 +13,7 @@ //! //! Mathematically significant numbers are provided in the `consts` sub-module. //! -//! *[See also the `f64` primitive type](../primitive.f64.html).* +//! *[See also the `f64` primitive type](../../std/primitive.f64.html).* #![stable(feature = "rust1", since = "1.0.0")] #![allow(missing_docs)] diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 2335695ae42d4..c75a42442b241 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1584,7 +1584,7 @@ mod tests { = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "mkdir ."]).output().unwrap() } else { - Command::new("mkdir").arg(".").output().unwrap() + Command::new("mkdir").arg("./").output().unwrap() }; assert!(status.code() == Some(1)); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2d47382ac0fae..f8d6b419f7ada 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -441,6 +441,9 @@ declare_features! ( // `foo.rs` as an alternative to `foo/mod.rs` (active, non_modrs_mods, "1.24.0", Some(44660)), + + // Nested `impl Trait` + (active, nested_impl_trait, "1.24.0", Some(34511)), ); declare_features! ( @@ -1314,8 +1317,73 @@ fn contains_novel_literal(item: &ast::MetaItem) -> bool { } } +// Bans nested `impl Trait`, e.g. `impl Into`. +// Nested `impl Trait` _is_ allowed in associated type position, +// e.g `impl Iterator` +struct NestedImplTraitVisitor<'a> { + context: &'a Context<'a>, + is_in_impl_trait: bool, +} + +impl<'a> NestedImplTraitVisitor<'a> { + fn with_impl_trait(&mut self, is_in_impl_trait: bool, f: F) + where F: FnOnce(&mut NestedImplTraitVisitor<'a>) + { + let old_is_in_impl_trait = self.is_in_impl_trait; + self.is_in_impl_trait = is_in_impl_trait; + f(self); + self.is_in_impl_trait = old_is_in_impl_trait; + } +} + + +impl<'a> Visitor<'a> for NestedImplTraitVisitor<'a> { + fn visit_ty(&mut self, t: &'a ast::Ty) { + if let ast::TyKind::ImplTrait(_) = t.node { + if self.is_in_impl_trait { + gate_feature_post!(&self, nested_impl_trait, t.span, + "nested `impl Trait` is experimental" + ); + } + self.with_impl_trait(true, |this| visit::walk_ty(this, t)); + } else { + visit::walk_ty(self, t); + } + } + fn visit_path_parameters(&mut self, _: Span, path_parameters: &'a ast::PathParameters) { + match *path_parameters { + ast::PathParameters::AngleBracketed(ref params) => { + for type_ in ¶ms.types { + self.visit_ty(type_); + } + for type_binding in ¶ms.bindings { + // Type bindings such as `Item=impl Debug` in `Iterator` + // are allowed to contain nested `impl Trait`. + self.with_impl_trait(false, |this| visit::walk_ty(this, &type_binding.ty)); + } + } + ast::PathParameters::Parenthesized(ref params) => { + for type_ in ¶ms.inputs { + self.visit_ty(type_); + } + if let Some(ref type_) = params.output { + // `-> Foo` syntax is essentially an associated type binding, + // so it is also allowed to contain nested `impl Trait`. + self.with_impl_trait(false, |this| visit::walk_ty(this, type_)); + } + } + } + } +} + impl<'a> PostExpansionVisitor<'a> { - fn whole_crate_feature_gates(&mut self) { + fn whole_crate_feature_gates(&mut self, krate: &ast::Crate) { + visit::walk_crate( + &mut NestedImplTraitVisitor { + context: self.context, + is_in_impl_trait: false, + }, krate); + for &(ident, span) in &*self.context.parse_sess.non_modrs_mods.borrow() { if !span.allows_unstable() { let cx = &self.context; @@ -1889,7 +1957,7 @@ pub fn check_crate(krate: &ast::Crate, plugin_attributes, }; let visitor = &mut PostExpansionVisitor { context: &ctx }; - visitor.whole_crate_feature_gates(); + visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); } diff --git a/src/test/compile-fail/E0657.rs b/src/test/compile-fail/E0657.rs index b72a8f03089b2..4595e413081a5 100644 --- a/src/test/compile-fail/E0657.rs +++ b/src/test/compile-fail/E0657.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(warnings)] -#![feature(conservative_impl_trait)] +#![feature(conservative_impl_trait, nested_impl_trait)] trait Id {} trait Lt<'a> {} diff --git a/src/test/compile-fail/feature-gate-nested_impl_trait.rs b/src/test/compile-fail/feature-gate-nested_impl_trait.rs new file mode 100644 index 0000000000000..7c35263d05dd7 --- /dev/null +++ b/src/test/compile-fail/feature-gate-nested_impl_trait.rs @@ -0,0 +1,39 @@ +// Copyright 2017 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. +#![feature(conservative_impl_trait, universal_impl_trait)] + +use std::fmt::Debug; + +fn fine(x: impl Into) -> impl Into { x } + +fn bad_in_ret_position(x: impl Into) -> impl Into { x } +//~^ ERROR nested `impl Trait` is experimental + +fn bad_in_fn_syntax(x: fn() -> impl Into) {} +//~^ ERROR nested `impl Trait` is experimental + +fn bad_in_arg_position(_: impl Into) { } +//~^ ERROR nested `impl Trait` is experimental + +struct X; +impl X { + fn bad(x: impl Into) -> impl Into { x } + //~^ ERROR nested `impl Trait` is experimental +} + +fn allowed_in_assoc_type() -> impl Iterator { + vec![|| println!("woot")].into_iter() +} + +fn allowed_in_ret_type() -> impl Fn() -> impl Into { + || 5 +} + +fn main() {} diff --git a/src/test/compile-fail/impl-trait/where-allowed.rs b/src/test/compile-fail/impl-trait/where-allowed.rs index af83a2d0a2337..a9fe1e04664e9 100644 --- a/src/test/compile-fail/impl-trait/where-allowed.rs +++ b/src/test/compile-fail/impl-trait/where-allowed.rs @@ -10,7 +10,7 @@ //! A simple test for testing many permutations of allowedness of //! impl Trait -#![feature(conservative_impl_trait, universal_impl_trait, dyn_trait)] +#![feature(conservative_impl_trait, nested_impl_trait, universal_impl_trait, dyn_trait)] use std::fmt::Debug; // Allowed diff --git a/src/test/run-pass/impl-trait/lifetimes.rs b/src/test/run-pass/impl-trait/lifetimes.rs index a56f083e08f2f..1f2d76f289472 100644 --- a/src/test/run-pass/impl-trait/lifetimes.rs +++ b/src/test/run-pass/impl-trait/lifetimes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(conservative_impl_trait, underscore_lifetimes, universal_impl_trait)] +#![feature(conservative_impl_trait, underscore_lifetimes, universal_impl_trait, nested_impl_trait)] #![allow(warnings)] use std::fmt::Debug; diff --git a/src/test/rustdoc/auxiliary/issue-46727.rs b/src/test/rustdoc/auxiliary/issue-46727.rs new file mode 100644 index 0000000000000..f0869f016e666 --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-46727.rs @@ -0,0 +1,17 @@ +// Copyright 2017 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. + +// compile-flags: -Cmetadata=aux + +pub trait Foo {} + +pub struct Bar { x: T } + +impl Foo for Bar<[T; 1 + 1 + 1]> {} diff --git a/src/test/rustdoc/issue-46727.rs b/src/test/rustdoc/issue-46727.rs new file mode 100644 index 0000000000000..5b202d8c4fe88 --- /dev/null +++ b/src/test/rustdoc/issue-46727.rs @@ -0,0 +1,17 @@ +// Copyright 2017 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:issue-46727.rs + +extern crate issue_46727; + +// @has issue_46727/trait.Foo.html +// @has - '//code' 'impl Foo for Bar<[T; 3]>' +pub use issue_46727::{Foo, Bar}; diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 371bbd16a5e92..fc2759df44748 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -46,8 +46,9 @@ static HOSTS: &'static [&'static str] = &[ static TARGETS: &'static [&'static str] = &[ "aarch64-apple-ios", - "aarch64-unknown-fuchsia", "aarch64-linux-android", + "aarch64-unknown-cloudabi", + "aarch64-unknown-fuchsia", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "arm-linux-androideabi", @@ -58,6 +59,7 @@ static TARGETS: &'static [&'static str] = &[ "armv5te-unknown-linux-gnueabi", "armv7-apple-ios", "armv7-linux-androideabi", + "armv7-unknown-cloudabi-eabihf", "armv7-unknown-linux-gnueabihf", "armv7-unknown-linux-musleabihf", "armv7s-apple-ios", @@ -69,6 +71,7 @@ static TARGETS: &'static [&'static str] = &[ "i686-linux-android", "i686-pc-windows-gnu", "i686-pc-windows-msvc", + "i686-unknown-cloudabi", "i686-unknown-freebsd", "i686-unknown-linux-gnu", "i686-unknown-linux-musl", @@ -86,13 +89,14 @@ static TARGETS: &'static [&'static str] = &[ "sparcv9-sun-solaris", "wasm32-unknown-emscripten", "wasm32-unknown-unknown", - "x86_64-linux-android", "x86_64-apple-darwin", "x86_64-apple-ios", + "x86_64-linux-android", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-rumprun-netbsd", "x86_64-sun-solaris", + "x86_64-unknown-cloudabi", "x86_64-unknown-freebsd", "x86_64-unknown-fuchsia", "x86_64-unknown-linux-gnu", diff --git a/src/tools/clippy b/src/tools/clippy index 7d7fef1690218..4daa4e38e2727 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 7d7fef1690218bbb406cf3bcadf7bb29dbb40cc5 +Subproject commit 4daa4e38e2727a58b5ae28f1563e9458306b096f