From c9cb806689a9691e2a29836e2c597751cdbcfdc8 Mon Sep 17 00:00:00 2001 From: kennytm Date: Sat, 2 Jun 2018 05:10:29 +0800 Subject: [PATCH 01/10] Deny #[cfg] and #[cfg_attr] on generic parameters. --- src/libsyntax/attr.rs | 20 ++++++++++++-- src/libsyntax/config.rs | 16 +++++++++++ src/libsyntax/ext/expand.rs | 5 ++++ src/libsyntax/feature_gate.rs | 2 +- src/test/ui/issue-51279.rs | 34 +++++++++++++++++++++++ src/test/ui/issue-51279.stderr | 50 ++++++++++++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/issue-51279.rs create mode 100644 src/test/ui/issue-51279.stderr diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 076b6d1765848..2389ed799cfcc 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -17,7 +17,7 @@ pub use self::IntType::*; use ast; use ast::{AttrId, Attribute, Name, Ident, Path, PathSegment}; use ast::{MetaItem, MetaItemKind, NestedMetaItem, NestedMetaItemKind}; -use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind}; +use ast::{Lit, LitKind, Expr, ExprKind, Item, Local, Stmt, StmtKind, GenericParam}; use codemap::{BytePos, Spanned, respan, dummy_spanned}; use syntax_pos::Span; use errors::{Applicability, Handler}; @@ -1444,6 +1444,22 @@ impl HasAttrs for Stmt { } } +impl HasAttrs for GenericParam { + fn attrs(&self) -> &[ast::Attribute] { + match self { + GenericParam::Lifetime(lifetime) => lifetime.attrs(), + GenericParam::Type(ty) => ty.attrs(), + } + } + + fn map_attrs) -> Vec>(self, f: F) -> Self { + match self { + GenericParam::Lifetime(lifetime) => GenericParam::Lifetime(lifetime.map_attrs(f)), + GenericParam::Type(ty) => GenericParam::Type(ty.map_attrs(f)), + } + } +} + macro_rules! derive_has_attrs { ($($ty:path),*) => { $( impl HasAttrs for $ty { @@ -1463,5 +1479,5 @@ macro_rules! derive_has_attrs { derive_has_attrs! { Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::ImplItem, ast::TraitItem, ast::Arm, - ast::Field, ast::FieldPat, ast::Variant_ + ast::Field, ast::FieldPat, ast::Variant_, ast::LifetimeDef, ast::TyParam } diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 36911683a0e77..3364378913952 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -278,6 +278,22 @@ impl<'a> StripUnconfigured<'a> { pattern }) } + + // deny #[cfg] on generic parameters until we decide what to do with it. + // see issue #51279. + pub fn disallow_cfg_on_generic_param(&mut self, param: &ast::GenericParam) { + for attr in param.attrs() { + let offending_attr = if attr.check_name("cfg") { + "cfg" + } else if attr.check_name("cfg_attr") { + "cfg_attr" + } else { + continue; + }; + let msg = format!("#[{}] cannot be applied on a generic parameter", offending_attr); + self.sess.span_diagnostic.span_err(attr.span, &msg); + } + } } impl<'a> fold::Folder for StripUnconfigured<'a> { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 83e7dd84cbff2..29030783ca6b8 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1412,6 +1412,11 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { } } + fn fold_generic_param(&mut self, param: ast::GenericParam) -> ast::GenericParam { + self.cfg.disallow_cfg_on_generic_param(¶m); + noop_fold_generic_param(param, self) + } + fn fold_attribute(&mut self, at: ast::Attribute) -> Option { // turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename", // contents="file contents")]` attributes diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9b84713b0f90f..785aedd3f3337 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -598,7 +598,7 @@ declare_features! ( // allow `'_` placeholder lifetimes (accepted, underscore_lifetimes, "1.26.0", Some(44524), None), // Allows attributes on lifetime/type formal parameters in generics (RFC 1327) - (accepted, generic_param_attrs, "1.26.0", Some(48848), None), + (accepted, generic_param_attrs, "1.27.0", Some(48848), None), // Allows cfg(target_feature = "..."). (accepted, cfg_target_feature, "1.27.0", Some(29717), None), // Allows #[target_feature(...)] diff --git a/src/test/ui/issue-51279.rs b/src/test/ui/issue-51279.rs new file mode 100644 index 0000000000000..4639d73e44d3d --- /dev/null +++ b/src/test/ui/issue-51279.rs @@ -0,0 +1,34 @@ +// Copyright 2018 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 X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} +//~^ ERROR #[cfg] cannot be applied on a generic parameter +//~^^ ERROR #[cfg] cannot be applied on a generic parameter + +#[cfg(none)] +pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is stripped out + +struct M(*const T); + +unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { + //~^ ERROR #[cfg_attr] cannot be applied on a generic parameter + fn drop(&mut self) {} +} + +type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; +//~^ ERROR #[cfg] cannot be applied on a generic parameter diff --git a/src/test/ui/issue-51279.stderr b/src/test/ui/issue-51279.stderr new file mode 100644 index 0000000000000..38d5a5acc50fe --- /dev/null +++ b/src/test/ui/issue-51279.stderr @@ -0,0 +1,50 @@ +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:11:14 + | +LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:11:31 + | +LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:15:6 + | +LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:15:23 + | +LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:19:10 + | +LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} + | ^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:19:27 + | +LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} + | ^^^^^^^^^^^^ + +error: #[cfg_attr] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:28:13 + | +LL | unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: #[cfg] cannot be applied on a generic parameter + --> $DIR/issue-51279.rs:33:23 + | +LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; + | ^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + From f37557764d0f1ca32d6b0c2525c88e49319e13d3 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 5 Jun 2018 14:36:36 +0100 Subject: [PATCH 02/10] Fix the use of closures within #[panic_implementation] --- src/librustc_typeck/check/mod.rs | 2 +- .../panic_implementation-closures.rs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/panic_implementation-closures.rs diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c2c71d90f0674..0c1c2ab481714 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1131,7 +1131,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !` if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() { - if panic_impl_did == fn_hir_id.owner_def_id() { + if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) { if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() { if declared_ret_ty.sty != ty::TyNever { fcx.tcx.sess.span_err( diff --git a/src/test/compile-fail/panic_implementation-closures.rs b/src/test/compile-fail/panic_implementation-closures.rs new file mode 100644 index 0000000000000..4fa9a639928f9 --- /dev/null +++ b/src/test/compile-fail/panic_implementation-closures.rs @@ -0,0 +1,21 @@ +// Copyright 2018 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-pass + +#![crate_type = "rlib"] +#![no_std] +#![feature(panic_implementation)] + +#[panic_implementation] +pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { + |x: u8| x; + loop {} +} From b1a8088fdb879917a5a47de9ad146c1e9958dcb8 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Tue, 5 Jun 2018 15:55:07 -0600 Subject: [PATCH 03/10] Remove fmt_macros dependency --- src/Cargo.lock | 1 - src/librustc_typeck/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d17faef82b563..78922a858528c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -2307,7 +2307,6 @@ name = "rustc_typeck" version = "0.0.0" dependencies = [ "arena 0.0.0", - "fmt_macros 0.0.0", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml index c426533779c9b..184cb9826ba68 100644 --- a/src/librustc_typeck/Cargo.toml +++ b/src/librustc_typeck/Cargo.toml @@ -13,7 +13,6 @@ test = false log = "0.4" syntax = { path = "../libsyntax" } arena = { path = "../libarena" } -fmt_macros = { path = "../libfmt_macros" } rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_platform_intrinsics = { path = "../librustc_platform_intrinsics" } From e73941a06b8a12d45407395a82589aaabcab1354 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Wed, 6 Jun 2018 04:13:55 +0100 Subject: [PATCH 04/10] rustdoc: Fix missing stability and src links for inlined external macros --- src/librustdoc/visit_ast.rs | 6 ++-- .../rustdoc/inline_cross/auxiliary/macros.rs | 21 ++++++++++++++ src/test/rustdoc/inline_cross/macros.rs | 28 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/test/rustdoc/inline_cross/auxiliary/macros.rs create mode 100644 src/test/rustdoc/inline_cross/macros.rs diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 8c2555c4b3de2..f05cbbfd7a2b6 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -244,10 +244,10 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { def_id, attrs: def.attrs.clone().into(), name: def.ident.name, - whence: def.span, + whence: self.cx.tcx.def_span(def_id), matchers, - stab: self.stability(def.id), - depr: self.deprecation(def.id), + stab: self.cx.tcx.lookup_stability(def_id).cloned(), + depr: self.cx.tcx.lookup_deprecation(def_id), imported_from: Some(imported_from), }) } diff --git a/src/test/rustdoc/inline_cross/auxiliary/macros.rs b/src/test/rustdoc/inline_cross/auxiliary/macros.rs new file mode 100644 index 0000000000000..39b52d68bf1c2 --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/macros.rs @@ -0,0 +1,21 @@ +// Copyright 2018 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(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +/// docs for my_macro +#[unstable(feature = "macro_test", issue = "0")] +#[rustc_deprecated(since = "1.2.3", reason = "text")] +#[macro_export] +macro_rules! my_macro { + () => () +} diff --git a/src/test/rustdoc/inline_cross/macros.rs b/src/test/rustdoc/inline_cross/macros.rs new file mode 100644 index 0000000000000..8d2f7d15d7d7f --- /dev/null +++ b/src/test/rustdoc/inline_cross/macros.rs @@ -0,0 +1,28 @@ +// Copyright 2018 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:macros.rs +// build-aux-docs + +#![feature(macro_test)] +#![feature(use_extern_macros)] + +#![crate_name = "foo"] + +extern crate macros; + +// @has foo/index.html '//*[@class="docblock-short"]' '[Deprecated] [Experimental]' + +// @has foo/macro.my_macro.html +// @has - '//*[@class="docblock"]' 'docs for my_macro' +// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' +// @has - '//*[@class="stab unstable"]' 'macro_test' +// @has - '//a/@href' '../src/macros/macros.rs.html#19-21' +pub use macros::my_macro; From f1c92476634485c6a2fb17d33046cedddaa150a2 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 6 Jun 2018 17:31:22 +0200 Subject: [PATCH 05/10] NLL performance boost --- .../borrow_check/nll/type_check/liveness.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index d19fd2bb5969d..76320c6a2eacc 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -104,13 +104,15 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo location, live_local ); - self.flow_inits.each_state_bit(|mpi_init| { - debug!( - "add_liveness_constraints: location={:?} initialized={:?}", - location, - &self.flow_inits.operator().move_data().move_paths[mpi_init] - ); - }); + if log_enabled!(::log::Level::Debug) { + self.flow_inits.each_state_bit(|mpi_init| { + debug!( + "add_liveness_constraints: location={:?} initialized={:?}", + location, + &self.flow_inits.operator().move_data().move_paths[mpi_init] + ); + }); + } let mpi = self.move_data.rev_lookup.find_local(live_local); if let Some(initialized_child) = self.flow_inits.has_any_child_of(mpi) { From 50224ec1a90eff7a3c475fcd1a19c99e10ee5b26 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 29 May 2018 23:25:53 +0200 Subject: [PATCH 06/10] It turns out that the diagnostics generated from NLL for these cases are now exactly the same as that produced by AST borrowck. Bravo! --- .../ui/generator/pattern-borrow.nll.stderr | 11 ------ src/test/ui/issue-45697.nll.stderr | 34 ------------------- 2 files changed, 45 deletions(-) delete mode 100644 src/test/ui/generator/pattern-borrow.nll.stderr delete mode 100644 src/test/ui/issue-45697.nll.stderr diff --git a/src/test/ui/generator/pattern-borrow.nll.stderr b/src/test/ui/generator/pattern-borrow.nll.stderr deleted file mode 100644 index 48f23486a317c..0000000000000 --- a/src/test/ui/generator/pattern-borrow.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/pattern-borrow.rs:19:24 - | -LL | if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - | ^^^^^^ -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/issue-45697.nll.stderr b/src/test/ui/issue-45697.nll.stderr deleted file mode 100644 index a85972fcd7a1c..0000000000000 --- a/src/test/ui/issue-45697.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ use of borrowed `y` -... -LL | *z.pointer += 1; - | --------------- borrow later used here - -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) - --> $DIR/issue-45697.rs:30:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here -... -LL | *z.pointer += 1; - | --------------- borrow later used here - -error: aborting due to 3 previous errors - -Some errors occurred: E0503, E0506. -For more information about an error, try `rustc --explain E0503`. From acd4fe8974539d385829d08c26fe15ce5a65017b Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 7 Jun 2018 15:14:49 +1200 Subject: [PATCH 07/10] Update RLS and Rustfmt --- src/Cargo.lock | 202 +++++++++++++++++++++++++++++++++++++--------- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 3 files changed, 166 insertions(+), 40 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index ed6f51093a757..1d34c76fe4057 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1688,6 +1688,7 @@ dependencies = [ "clippy_lints 0.0.205 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "languageserver-types 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1699,10 +1700,10 @@ dependencies = [ "rls-analysis 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rls-data 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-rustc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-rustc 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.8.2", + "rustfmt-nightly 0.8.2 (git+https://github.com/rust-lang-nursery/rustfmt?rev=f3906267)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1741,7 +1742,7 @@ dependencies = [ [[package]] name = "rls-rustc" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1804,24 +1805,58 @@ dependencies = [ [[package]] name = "rustc-ap-arena" -version = "147.0.0" +version = "149.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-ap-rustc_data_structures 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-arena" +version = "156.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_cratesio_shim" -version = "147.0.0" +version = "149.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-ap-rustc_cratesio_shim" +version = "156.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-rustc_data_structures" +version = "149.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc-ap-rustc_data_structures" -version = "147.0.0" +version = "156.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1829,65 +1864,122 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_errors" -version = "147.0.0" +version = "149.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-ap-rustc_errors" +version = "156.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-rustc_target" +version = "149.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc-ap-rustc_target" -version = "147.0.0" +version = "156.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-serialize" -version = "147.0.0" +version = "149.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-ap-serialize" +version = "156.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-ap-syntax" -version = "147.0.0" +version = "149.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-syntax" +version = "156.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-syntax_pos" +version = "149.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-ap-arena 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-syntax_pos" -version = "147.0.0" +version = "156.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-arena 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-arena 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2362,6 +2454,31 @@ dependencies = [ "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustfmt-nightly" +version = "0.8.2" +source = "git+https://github.com/rust-lang-nursery/rustfmt?rev=f3906267#f390626778c1bbb13911556d585850eb2fa67923" +dependencies = [ + "cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "isatty 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustfmt-nightly" version = "0.8.2" @@ -2378,8 +2495,8 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3206,17 +3323,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rls-analysis 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da9794cd1f80f2cb888c00641a32f9855d0226c954ee31cef145784914c7142e" "checksum rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a9cc2545ccb7e05b355bfe047b8039a6ec12270d5f3c996b766b340a50f7d2" "checksum rls-data 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dd20763e1c60ae8945384c8a8fa4ac44f8afa7b0a817511f5e8927e5d24f988" -"checksum rls-rustc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ed5342b2bbbe8663c04600af506c8902b6b4d3e627b006eb1bd65aa14805f4d" +"checksum rls-rustc 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c8c09117ae2887baaa4b17fe1cb572f9b22e4d2c6a5cda04093d8b366b0be99" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be231e1e559c315bc60ced5ad2cc2d7a9c208ed7d4e2c126500149836fda19bb" -"checksum rustc-ap-arena 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1304956fbbdd070e4478672d040f0453374604a12a0938aaba4b38a2bd124667" -"checksum rustc-ap-rustc_cratesio_shim 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d1dcd0fafa3c7875b76e33feaf69b332870180475ba3eb8dd003bcc2a2dc069" -"checksum rustc-ap-rustc_data_structures 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76c1a3fe4a0104b922ffc8080bd7c703dc20f2874b7c982638f6adb6c378b77a" -"checksum rustc-ap-rustc_errors 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2812e295d2930bf3b3c22dbe8ef0bb8ae98a497ae6ad379d0709434387a9004b" -"checksum rustc-ap-rustc_target 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bd371121f16da666f6d6d5e6ff57cd972cc8206cc80377ba411b99607d49cbd" -"checksum rustc-ap-serialize 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bde493c1c16d724e42536117c385b69f2eae9b2ec38bab841c45373bce4a9d8f" -"checksum rustc-ap-syntax 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "402c1f402e6d47defcd884d3f715aaa8c6f2cbdd5f13cb06fea70486d512426b" -"checksum rustc-ap-syntax_pos 147.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb707a229093791dc3fc35aca61d9bf0e3708f23da4536683527857bc624b061" +"checksum rustc-ap-arena 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e794b25832224eea9252ebfa9f94ab7070d0a60c977793112c611501cb56b48d" +"checksum rustc-ap-arena 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83e91a01cd6c5a9e4f68c2b5c81b62b172aa9e00fc2fec862c0899e3fac1fd32" +"checksum rustc-ap-rustc_cratesio_shim 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a78241b2ecb82ebb9221b4b7d37c024ff1f2e43f1b099f38a997f030fc7894b0" +"checksum rustc-ap-rustc_cratesio_shim 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e8ea8fadc5d66c1527771816e83f7e7599543bd2e1583e279855370ab2f18e5" +"checksum rustc-ap-rustc_data_structures 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5529c3927f32b0b56d1f6449a34f2218dc2160c6a6dde0cf47954d83a9a45764" +"checksum rustc-ap-rustc_data_structures 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "742ba74bc7d0f3ded56148329650f137fa5b90f7f0ecc4b4952150f32c66b147" +"checksum rustc-ap-rustc_errors 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1fef44a7d63f5d204c981adb26a14e85fe7ee5962050a4f664df6f425f9b48" +"checksum rustc-ap-rustc_errors 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3714046c6f8c1c259822aefcca21b1862710a6cec24fd34c0796117f074c6769" +"checksum rustc-ap-rustc_target 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3939a9f7bf063536dd646894ca43b1378ec6a56ac5b2698cc6ba0b42bfadbdc" +"checksum rustc-ap-rustc_target 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b982c4517c18080895b06149ce8aa8279fd013f629030bb7a179bfcff6d74ef2" +"checksum rustc-ap-serialize 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "692169d0bac8a4547f9778039460799e162664477a1eaec15d31507705f8c736" +"checksum rustc-ap-serialize 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "27c7700595bff1a64ddb6f593c69db3f6d66b76b059b26137236c7e21e36db70" +"checksum rustc-ap-syntax 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22e93ee3817b007d56b5c5b151e6cd7c7063455a1facaf9e0ca01f9d9365b716" +"checksum rustc-ap-syntax 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e6482d98c8be57d3cfe55dab744dd1a87f8462dc2ea0a8a4960f7bb1565be049" +"checksum rustc-ap-syntax_pos 149.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe5d24a137d6e202cd6eb96cb74f8cb4a2b257c42b74dd624e136b4e19f0a47d" +"checksum rustc-ap-syntax_pos 156.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20af5e200b61a3e5ba4f58ed3cbd7593569faf8f0956d5233f4f27fee51b4c81" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306" @@ -3224,6 +3349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" "checksum rustfix 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9da3cf9b79dc889a2c9879643f26d7a53e37e9361c7566b7d2787d5ace0d8396" +"checksum rustfmt-nightly 0.8.2 (git+https://github.com/rust-lang-nursery/rustfmt?rev=f3906267)" = "" "checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637" "checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade" "checksum scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8674d439c964889e2476f474a3bf198cc9e199e77499960893bac5de7e9218a4" diff --git a/src/tools/rls b/src/tools/rls index 453f5e4dec279..7d0bc550b0899 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 453f5e4dec279167aed825b7ad043d06aa17c667 +Subproject commit 7d0bc550b0899a13a56c81eb2d5064abd0bcf385 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 173ae0d7b9222..08da30d72c9ab 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 173ae0d7b92227c7fec4bce67c944dce953256dc +Subproject commit 08da30d72c9abfff4d41f6f081e31fd2929b820d From 1df781712297270c74d175552e420ae055a7f193 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 7 Jun 2018 17:07:05 +0200 Subject: [PATCH 08/10] Revert "Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov" This reverts commit d6ba1b9b021c408fcad60ee52acf8af5e1b2eb00, reversing changes made to 8de5353f75dcde04abe947e0560dc5edd861cf3a. --- src/libsyntax/ext/tt/quoted.rs | 89 ++++++++++++++----- src/test/run-pass/macro-at-most-once-rep.rs | 29 ++++-- .../ui/macros/macro-at-most-once-rep-ambig.rs | 34 +++---- .../macro-at-most-once-rep-ambig.stderr | 76 ++++++++++------ 4 files changed, 156 insertions(+), 72 deletions(-) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 77c6afa1c64a6..01b971976a763 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -386,26 +386,72 @@ where { // We basically look at two token trees here, denoted as #1 and #2 below let span = match parse_kleene_op(input, span) { - // #1 is any KleeneOp (`?`) - Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { - if !features.macro_at_most_once_rep - && !attr::contains_name(attrs, "allow_internal_unstable") - { - let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; - emit_feature_err( - sess, - "macro_at_most_once_rep", - span, - GateIssue::Language, - explain, - ); + // #1 is a `+` or `*` KleeneOp + // + // `?` is ambiguous: it could be a separator or a Kleene::ZeroOrOne, so we need to look + // ahead one more token to be sure. + Ok(Ok(op)) if op != KleeneOp::ZeroOrOne => return (None, op), + + // #1 is `?` token, but it could be a Kleene::ZeroOrOne without a separator or it could + // be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to + // find out which. + Ok(Ok(op)) => { + assert_eq!(op, KleeneOp::ZeroOrOne); + + // Lookahead at #2. If it is a KleenOp, then #1 is a separator. + let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() { + kleene_op(tok2).is_some() + } else { + false + }; + + if is_1_sep { + // #1 is a separator and #2 should be a KleepeOp::* + // (N.B. We need to advance the input iterator.) + match parse_kleene_op(input, span) { + // #2 is a KleeneOp (this is the only valid option) :) + Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { + if !features.macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; + emit_feature_err( + sess, + "macro_at_most_once_rep", + span, + GateIssue::Language, + explain, + ); + } + return (Some(token::Question), op); + } + Ok(Ok(op)) => return (Some(token::Question), op), + + // #2 is a random token (this is an error) :( + Ok(Err((_, span))) => span, + + // #2 is not even a token at all :( + Err(span) => span, + } + } else { + if !features.macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; + emit_feature_err( + sess, + "macro_at_most_once_rep", + span, + GateIssue::Language, + explain, + ); + } + + // #2 is a random tree and #1 is KleeneOp::ZeroOrOne + return (None, op); } - return (None, op); } - // #1 is any KleeneOp (`+`, `*`) - Ok(Ok(op)) => return (None, op), - // #1 is a separator followed by #2, a KleeneOp Ok(Err((tok, span))) => match parse_kleene_op(input, span) { // #2 is a KleeneOp :D @@ -421,11 +467,8 @@ where GateIssue::Language, explain, ); - } else { - sess.span_diagnostic - .span_err(span, "`?` macro repetition does not allow a separator"); } - return (None, op); + return (Some(tok), op); } Ok(Ok(op)) => return (Some(tok), op), @@ -440,7 +483,9 @@ where Err(span) => span, }; - if !features.macro_at_most_once_rep && !attr::contains_name(attrs, "allow_internal_unstable") { + if !features.macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { sess.span_diagnostic .span_err(span, "expected one of: `*`, `+`, or `?`"); } else { diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs index c08effe549328..b7e942f938321 100644 --- a/src/test/run-pass/macro-at-most-once-rep.rs +++ b/src/test/run-pass/macro-at-most-once-rep.rs @@ -32,13 +32,25 @@ macro_rules! foo { } } } +macro_rules! baz { + ($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?` + let mut x = 0; + + $( + x += $a; + )? + + assert_eq!(x, $num); + } } +} + macro_rules! barplus { ($($a:ident)?+ ; $num:expr) => { { let mut x = 0; $( x += $a; - )? + )+ assert_eq!(x, $num); } } @@ -50,7 +62,7 @@ macro_rules! barstar { $( x += $a; - )? + )* assert_eq!(x, $num); } } @@ -62,10 +74,15 @@ pub fn main() { // accept 0 or 1 repetitions foo!( ; 0); foo!(a ; 1); + baz!( ; 0); + baz!(a ; 1); // Make sure using ? as a separator works as before - barplus!(+ ; 0); - barplus!(a + ; 1); - barstar!(* ; 0); - barstar!(a * ; 1); + barplus!(a ; 1); + barplus!(a?a ; 2); + barplus!(a?a?a ; 3); + barstar!( ; 0); + barstar!(a ; 1); + barstar!(a?a ; 2); + barstar!(a?a?a ; 3); } diff --git a/src/test/ui/macros/macro-at-most-once-rep-ambig.rs b/src/test/ui/macros/macro-at-most-once-rep-ambig.rs index e25c3ccfcd980..a5660f8b41f8d 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-ambig.rs +++ b/src/test/ui/macros/macro-at-most-once-rep-ambig.rs @@ -8,26 +8,30 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Tests the behavior of various Kleene operators in macros with respect to `?` terminals. In -// particular, `?` in the position of a separator and of a Kleene operator is tested. +// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. +// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the +// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to +// exercise that logic in the macro parser. +// +// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but +// included for consistency with `+` and `*`. +// +// This test focuses on error cases. #![feature(macro_at_most_once_rep)] -// should match `` and `a` macro_rules! foo { ($(a)?) => {} } macro_rules! baz { - ($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator + ($(a),?) => {} // comma separator is meaningless for `?` } -// should match `+` and `a+` macro_rules! barplus { ($(a)?+) => {} } -// should match `*` and `a*` macro_rules! barstar { ($(a)?*) => {} } @@ -36,14 +40,14 @@ pub fn main() { foo!(a?a?a); //~ ERROR no rules expected the token `?` foo!(a?a); //~ ERROR no rules expected the token `?` foo!(a?); //~ ERROR no rules expected the token `?` + baz!(a?a?a); //~ ERROR no rules expected the token `?` + baz!(a?a); //~ ERROR no rules expected the token `?` + baz!(a?); //~ ERROR no rules expected the token `?` + baz!(a,); //~ ERROR unexpected end of macro invocation + baz!(a?a?a,); //~ ERROR no rules expected the token `?` + baz!(a?a,); //~ ERROR no rules expected the token `?` + baz!(a?,); //~ ERROR no rules expected the token `?` barplus!(); //~ ERROR unexpected end of macro invocation - barstar!(); //~ ERROR unexpected end of macro invocation - barplus!(a?); //~ ERROR no rules expected the token `?` - barplus!(a); //~ ERROR unexpected end of macro invocation - barstar!(a?); //~ ERROR no rules expected the token `?` - barstar!(a); //~ ERROR unexpected end of macro invocation - barplus!(+); // ok - barstar!(*); // ok - barplus!(a+); // ok - barstar!(a*); // ok + barplus!(a?); //~ ERROR unexpected end of macro invocation + barstar!(a?); //~ ERROR unexpected end of macro invocation } diff --git a/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr b/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr index cb1e360471cc8..d382082a57585 100644 --- a/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr +++ b/src/test/ui/macros/macro-at-most-once-rep-ambig.stderr @@ -1,62 +1,80 @@ -error: `?` macro repetition does not allow a separator - --> $DIR/macro-at-most-once-rep-ambig.rs:22:10 - | -LL | ($(a),?) => {} //~ ERROR `?` macro repetition does not allow a separator - | ^ - error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:36:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:40:11 | LL | foo!(a?a?a); //~ ERROR no rules expected the token `?` | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:37:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:41:11 | LL | foo!(a?a); //~ ERROR no rules expected the token `?` | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:38:11 + --> $DIR/macro-at-most-once-rep-ambig.rs:42:11 | LL | foo!(a?); //~ ERROR no rules expected the token `?` | ^ -error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:39:5 +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:43:11 | -LL | barplus!(); //~ ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | baz!(a?a?a); //~ ERROR no rules expected the token `?` + | ^ -error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:40:5 +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:44:11 | -LL | barstar!(); //~ ERROR unexpected end of macro invocation - | ^^^^^^^^^^^ +LL | baz!(a?a); //~ ERROR no rules expected the token `?` + | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:41:15 + --> $DIR/macro-at-most-once-rep-ambig.rs:45:11 | -LL | barplus!(a?); //~ ERROR no rules expected the token `?` - | ^ +LL | baz!(a?); //~ ERROR no rules expected the token `?` + | ^ error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:42:14 + --> $DIR/macro-at-most-once-rep-ambig.rs:46:11 + | +LL | baz!(a,); //~ ERROR unexpected end of macro invocation + | ^ + +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:47:11 + | +LL | baz!(a?a?a,); //~ ERROR no rules expected the token `?` + | ^ + +error: no rules expected the token `?` + --> $DIR/macro-at-most-once-rep-ambig.rs:48:11 | -LL | barplus!(a); //~ ERROR unexpected end of macro invocation - | ^ +LL | baz!(a?a,); //~ ERROR no rules expected the token `?` + | ^ error: no rules expected the token `?` - --> $DIR/macro-at-most-once-rep-ambig.rs:43:15 + --> $DIR/macro-at-most-once-rep-ambig.rs:49:11 + | +LL | baz!(a?,); //~ ERROR no rules expected the token `?` + | ^ + +error: unexpected end of macro invocation + --> $DIR/macro-at-most-once-rep-ambig.rs:50:5 + | +LL | barplus!(); //~ ERROR unexpected end of macro invocation + | ^^^^^^^^^^^ + +error: unexpected end of macro invocation + --> $DIR/macro-at-most-once-rep-ambig.rs:51:15 | -LL | barstar!(a?); //~ ERROR no rules expected the token `?` +LL | barplus!(a?); //~ ERROR unexpected end of macro invocation | ^ error: unexpected end of macro invocation - --> $DIR/macro-at-most-once-rep-ambig.rs:44:14 + --> $DIR/macro-at-most-once-rep-ambig.rs:52:15 | -LL | barstar!(a); //~ ERROR unexpected end of macro invocation - | ^ +LL | barstar!(a?); //~ ERROR unexpected end of macro invocation + | ^ -error: aborting due to 10 previous errors +error: aborting due to 13 previous errors From 6e7affffacb37b79c61e10c894964d934495da44 Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 8 Jun 2018 04:31:30 +0800 Subject: [PATCH 09/10] Remove the `gem update` from `.travis.yml` It has no effect on deployment error and may cause further network issues. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e62b895ed21e..c154f3d8e251f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -301,7 +301,6 @@ before_deploy: rm -rf obj/build/dist/doc && cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT; fi - - travis_retry gem update --system - ls -la deploy/$TRAVIS_COMMIT deploy: From 32e8bda4e35ada92beab7236d62520e6c6df8596 Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 8 Jun 2018 04:33:46 +0800 Subject: [PATCH 10/10] Use public DNS server instead of 169.254.169.254 on CI. Tries to workaround travis-ci/travis-ci#9696. --- src/ci/docker/run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 3465e386cd925..8913fdaa888e7 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -118,6 +118,10 @@ fi # goes ahead and sets it for all builders. args="$args --privileged" +if [ "$CI" != "" ]; then + args="$args --dns 8.8.8.8 --dns 8.8.4.4 --dns 1.1.1.1 --dns 1.0.0.1" +fi + exec docker \ run \ --volume "$root_dir:/checkout:ro" \