Skip to content

Rollup of 7 pull requests #63763

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 9 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ dependencies = [
"serde",
"serde_json",
"time",
"toml 0.4.10",
"toml",
]

[[package]]
Expand All @@ -202,7 +202,7 @@ name = "build-manifest"
version = "0.1.0"
dependencies = [
"serde",
"toml 0.4.10",
"toml",
]

[[package]]
Expand Down Expand Up @@ -316,7 +316,7 @@ dependencies = [
"tar",
"tempfile",
"termcolor",
"toml 0.5.3",
"toml",
"unicode-width",
"url 2.1.0",
"walkdir",
Expand Down Expand Up @@ -442,7 +442,7 @@ dependencies = [
"semver",
"serde",
"smallvec",
"toml 0.5.3",
"toml",
"unicode-normalization",
"url 2.1.0",
]
Expand Down Expand Up @@ -946,6 +946,7 @@ name = "error_index_generator"
version = "0.0.0"
dependencies = [
"rustdoc",
"walkdir",
]

[[package]]
Expand Down Expand Up @@ -1785,7 +1786,7 @@ dependencies = [
"serde_json",
"shlex",
"tempfile",
"toml 0.5.3",
"toml",
"toml-query",
]

Expand Down Expand Up @@ -2760,7 +2761,7 @@ dependencies = [
"tokio",
"tokio-process",
"tokio-timer",
"toml 0.5.3",
"toml",
"url 1.7.2",
"walkdir",
]
Expand Down Expand Up @@ -3590,7 +3591,7 @@ dependencies = [
"serde_json",
"structopt",
"term 0.6.0",
"toml 0.5.3",
"toml",
"unicode-segmentation",
"unicode-width",
"unicode_categories",
Expand Down Expand Up @@ -4382,15 +4383,6 @@ dependencies = [
"tokio-reactor",
]

[[package]]
name = "toml"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
dependencies = [
"serde",
]

[[package]]
name = "toml"
version = "0.5.3"
Expand All @@ -4411,7 +4403,7 @@ dependencies = [
"is-match",
"lazy_static 1.3.0",
"regex",
"toml 0.5.3",
"toml",
"toml-query_derive",
]

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cc = "1.0.35"
libc = "0.2"
serde = { version = "1.0.8", features = ["derive"] }
serde_json = "1.0.2"
toml = "0.4"
toml = "0.5"
lazy_static = "1.3.0"
time = "0.1"
petgraph = "0.4.13"
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,7 @@ impl Step for ErrorIndex {
index.arg(crate::channel::CFG_RELEASE_NUM);

// FIXME: shouldn't have to pass this env var
index.env("CFG_BUILD", &builder.config.build)
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
index.env("CFG_BUILD", &builder.config.build);

builder.run(&mut index);
}
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,7 @@ impl Step for ErrorIndex {
);
tool.arg("markdown")
.arg(&output)
.env("CFG_BUILD", &builder.config.build)
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
.env("CFG_BUILD", &builder.config.build);

builder.info(&format!("Testing error-index stage{}", compiler.stage));
let _time = util::timeit(&builder);
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/reference
93 changes: 0 additions & 93 deletions src/libsyntax/diagnostics/metadata.rs

This file was deleted.

34 changes: 4 additions & 30 deletions src/libsyntax/diagnostics/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::env;

use crate::ast::{self, Ident, Name};
use crate::source_map;
Expand All @@ -12,8 +11,6 @@ use crate::tokenstream::{TokenTree};
use smallvec::smallvec;
use syntax_pos::Span;

use crate::diagnostics::metadata::output_metadata;

pub use errors::*;

// Maximum width of any line in an extended error description (inclusive).
Expand Down Expand Up @@ -127,36 +124,13 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt<'_>,
token_tree: &[TokenTree])
-> Box<dyn MacResult+'cx> {
assert_eq!(token_tree.len(), 3);
let (crate_name, ident) = match (&token_tree[0], &token_tree[2]) {
(
// Crate name.
&TokenTree::Token(Token { kind: token::Ident(crate_name, _), .. }),
// DIAGNOSTICS ident.
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
) => (crate_name, Ident::new(name, span)),
let ident = match &token_tree[2] {
// DIAGNOSTICS ident.
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
=> Ident::new(name, span),
_ => unreachable!()
};

// Output error metadata to `tmp/extended-errors/<target arch>/<crate name>.json`
if let Ok(target_triple) = env::var("CFG_COMPILER_HOST_TRIPLE") {
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {
if let Err(e) = output_metadata(ecx,
&target_triple,
&crate_name.as_str(),
diagnostics) {
ecx.span_bug(span, &format!(
"error writing metadata for triple `{}` and crate `{}`, error: {}, \
cause: {:?}",
target_triple, crate_name, e.description(), e.source()
));
}
});
} else {
ecx.span_err(span, &format!(
"failed to write metadata for crate `{}` because $CFG_COMPILER_HOST_TRIPLE is not set",
crate_name));
}

// Construct the output expression.
let (count, expr) =
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {
Expand Down
17 changes: 10 additions & 7 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ declare_features! (
// Allows `const _: TYPE = VALUE`.
(accepted, underscore_const_names, "1.37.0", Some(54912), None),
// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
(accepted, async_await, "1.38.0", Some(50547), None),
(accepted, async_await, "1.39.0", Some(50547), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down Expand Up @@ -2423,16 +2423,19 @@ pub fn check_crate(krate: &ast::Crate,
};

macro_rules! gate_all {
($gate:ident, $msg:literal) => { gate_all!($gate, $gate, $msg); };
($spans:ident, $gate:ident, $msg:literal) => {
for span in &*sess.$spans.borrow() { gate_feature!(&ctx, $gate, *span, $msg); }
for span in &*sess.gated_spans.$spans.borrow() {
gate_feature!(&ctx, $gate, *span, $msg);
}
}
}

gate_all!(param_attr_spans, param_attrs, "attributes on function parameters are unstable");
gate_all!(let_chains_spans, let_chains, "`let` expressions in this position are experimental");
gate_all!(async_closure_spans, async_closure, "async closures are unstable");
gate_all!(yield_spans, generators, "yield syntax is experimental");
gate_all!(or_pattern_spans, or_patterns, "or-patterns syntax is experimental");
gate_all!(param_attrs, "attributes on function parameters are unstable");
gate_all!(let_chains, "`let` expressions in this position are experimental");
gate_all!(async_closure, "async closures are unstable");
gate_all!(yields, generators, "yield syntax is experimental");
gate_all!(or_patterns, "or-patterns syntax is experimental");

let visitor = &mut PostExpansionVisitor {
context: &ctx,
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub mod diagnostics {
#[macro_use]
pub mod macros;
pub mod plugin;
pub mod metadata;
}

// N.B., this module needs to be declared first so diagnostics are
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \
impl<'a> Parser<'a> {
crate fn parse_arg_attributes(&mut self) -> PResult<'a, Vec<ast::Attribute>> {
let attrs = self.parse_outer_attributes()?;
attrs.iter().for_each(|a|
self.sess.param_attr_spans.borrow_mut().push(a.span)
);
self.sess.gated_spans.param_attrs.borrow_mut()
.extend(attrs.iter().map(|a| a.span));
Ok(attrs)
}

Expand Down
32 changes: 18 additions & 14 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ crate mod unescape_error_reporting;

pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>;

/// Collected spans during parsing for places where a certain feature was
/// used and should be feature gated accordingly in `check_crate`.
#[derive(Default)]
pub struct GatedSpans {
/// Spans collected for gating `param_attrs`, e.g. `fn foo(#[attr] x: u8) {}`.
pub param_attrs: Lock<Vec<Span>>,
/// Spans collected for gating `let_chains`, e.g. `if a && let b = c {}`.
pub let_chains: Lock<Vec<Span>>,
/// Spans collected for gating `async_closure`, e.g. `async || ..`.
pub async_closure: Lock<Vec<Span>>,
/// Spans collected for gating `yield e?` expressions (`generators` gate).
pub yields: Lock<Vec<Span>>,
/// Spans collected for gating `or_patterns`, e.g. `Some(Foo | Bar)`.
pub or_patterns: Lock<Vec<Span>>,
}

/// Info about a parsing session.
pub struct ParseSess {
pub span_diagnostic: Handler,
Expand All @@ -58,16 +74,8 @@ pub struct ParseSess {
/// operation token that followed it, but that the parser cannot identify without further
/// analysis.
pub ambiguous_block_expr_parse: Lock<FxHashMap<Span, Span>>,
pub param_attr_spans: Lock<Vec<Span>>,
// Places where `let` exprs were used and should be feature gated according to `let_chains`.
pub let_chains_spans: Lock<Vec<Span>>,
// Places where `async || ..` exprs were used and should be feature gated.
pub async_closure_spans: Lock<Vec<Span>>,
// Places where `yield e?` exprs were used and should be feature gated.
pub yield_spans: Lock<Vec<Span>>,
pub injected_crate_name: Once<Symbol>,
// Places where or-patterns e.g. `Some(Foo | Bar)` were used and should be feature gated.
pub or_pattern_spans: Lock<Vec<Span>>,
pub gated_spans: GatedSpans,
}

impl ParseSess {
Expand All @@ -93,12 +101,8 @@ impl ParseSess {
buffered_lints: Lock::new(vec![]),
edition: ExpnId::root().expn_data().edition,
ambiguous_block_expr_parse: Lock::new(FxHashMap::default()),
param_attr_spans: Lock::new(Vec::new()),
let_chains_spans: Lock::new(Vec::new()),
async_closure_spans: Lock::new(Vec::new()),
yield_spans: Lock::new(Vec::new()),
injected_crate_name: Once::new(),
or_pattern_spans: Lock::new(Vec::new()),
gated_spans: GatedSpans::default(),
}
}

Expand Down
Loading