Skip to content

Rollup of 9 pull requests #51426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c9cb806
Deny #[cfg] and #[cfg_attr] on generic parameters.
kennytm Jun 1, 2018
f375577
Fix the use of closures within #[panic_implementation]
varkor Jun 5, 2018
b1a8088
Remove fmt_macros dependency
Mark-Simulacrum Jun 5, 2018
e73941a
rustdoc: Fix missing stability and src links for inlined external macros
ollie27 Jun 6, 2018
f1c9247
NLL performance boost
ngg Jun 6, 2018
50224ec
It turns out that the diagnostics generated from NLL for these cases …
pnkfelix May 29, 2018
acd4fe8
Update RLS and Rustfmt
nrc Jun 7, 2018
1df7817
Revert "Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov"
pietroalbini Jun 7, 2018
6e7afff
Remove the `gem update` from `.travis.yml`
kennytm Jun 7, 2018
32e8bda
Use public DNS server instead of 169.254.169.254 on CI.
kennytm Jun 7, 2018
0bc15ed
Rollup merge of #51186 - pnkfelix:remove-unneccessary-nll-stderr-file…
kennytm Jun 7, 2018
26a9d58
Rollup merge of #51283 - kennytm:fix-51279-preempt-the-warning-song-a…
kennytm Jun 7, 2018
6c73943
Rollup merge of #51368 - varkor:panic_implementation-closures, r=eddyb
kennytm Jun 7, 2018
b94b89b
Rollup merge of #51380 - Mark-Simulacrum:remove-fmt-macros, r=oli-obk
kennytm Jun 7, 2018
d5759da
Rollup merge of #51389 - ollie27:rustdoc_cross_macro_src_stab, r=Quie…
kennytm Jun 7, 2018
326331c
Rollup merge of #51399 - ngg:nll-performance, r=nikomatsakis
kennytm Jun 7, 2018
c843607
Rollup merge of #51407 - nrc:update, r=Mark-Simulacrum
kennytm Jun 7, 2018
e46ef1b
Rollup merge of #51417 - pietroalbini:revert-49719, r=nikomatsakis
kennytm Jun 7, 2018
34cd36e
Rollup merge of #51420 - kennytm:some-network-issues, r=Mark-Simulacrum
kennytm Jun 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
203 changes: 164 additions & 39 deletions src/Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
16 changes: 9 additions & 7 deletions src/librustc_mir/borrow_check/nll/type_check/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_typeck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}
Expand Down
20 changes: 18 additions & 2 deletions src/libsyntax/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(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 {
Expand All @@ -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
}
16 changes: 16 additions & 0 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&param);
noop_fold_generic_param(param, self)
}

fn fold_attribute(&mut self, at: ast::Attribute) -> Option<ast::Attribute> {
// turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename",
// contents="file contents")]` attributes
Expand Down
89 changes: 67 additions & 22 deletions src/libsyntax/ext/tt/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,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(...)]
Expand Down
21 changes: 21 additions & 0 deletions src/test/compile-fail/panic_implementation-closures.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-pass

#![crate_type = "rlib"]
#![no_std]
#![feature(panic_implementation)]

#[panic_implementation]
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
|x: u8| x;
loop {}
}
29 changes: 23 additions & 6 deletions src/test/run-pass/macro-at-most-once-rep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
} }
Expand All @@ -50,7 +62,7 @@ macro_rules! barstar {

$(
x += $a;
)?
)*

assert_eq!(x, $num);
} }
Expand All @@ -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);
}
21 changes: 21 additions & 0 deletions src/test/rustdoc/inline_cross/auxiliary/macros.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![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 {
() => ()
}
28 changes: 28 additions & 0 deletions src/test/rustdoc/inline_cross/macros.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// 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;
Loading