Skip to content

Commit

Permalink
Auto merge of #63779 - Centril:rollup-sx96dli, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #63721 (Do not emit JSON dumps of diagnostic codes)
 - #63753 (Bump toml dependency.)
 - #63755 (Use dedicated type for spans in pre-expansion gating.)
 - #63759 (Allow 'default async fn' to parse.)
 - #63760 (Update books)
 - #63762 (`async_await` was stabilized in 1.39.0, not 1.38.0.)
 - #63766 (Remove some duplication when resolving constants)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Aug 21, 2019
2 parents bea0372 + b25ec04 commit 7b0085a
Show file tree
Hide file tree
Showing 24 changed files with 177 additions and 239 deletions.
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
24 changes: 3 additions & 21 deletions src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::hir::def_id::DefId;
use crate::ty::subst::{Kind, UnpackedKind, SubstsRef};
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
use crate::ty::error::{ExpectedFound, TypeError};
use crate::mir::interpret::{ConstValue, Scalar, GlobalId};
use crate::mir::interpret::{ConstValue, Scalar};
use std::rc::Rc;
use std::iter;
use rustc_target::spec::abi;
Expand Down Expand Up @@ -551,26 +551,8 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
let tcx = relation.tcx();

let eagerly_eval = |x: &'tcx ty::Const<'tcx>| {
if let ConstValue::Unevaluated(def_id, substs) = x.val {
// FIXME(eddyb) get the right param_env.
let param_env = ty::ParamEnv::empty();
if !substs.has_local_value() {
let instance = ty::Instance::resolve(
tcx.global_tcx(),
param_env,
def_id,
substs,
);
if let Some(instance) = instance {
let cid = GlobalId {
instance,
promoted: None,
};
if let Ok(ct) = tcx.const_eval(param_env.and(cid)) {
return ct.val;
}
}
}
if !x.val.has_local_value() {
return x.eval(tcx, relation.param_env()).val;
}
x.val
};
Expand Down
24 changes: 17 additions & 7 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2299,23 +2299,33 @@ impl<'tcx> Const<'tcx> {
assert_eq!(self.ty, ty);
// if `ty` does not depend on generic parameters, use an empty param_env
let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size;
self.eval(tcx, param_env).val.try_to_bits(size)
}

#[inline]
pub fn eval(
&self,
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
) -> &Const<'tcx> {
// FIXME(const_generics): this doesn't work right now,
// because it tries to relate an `Infer` to a `Param`.
match self.val {
// FIXME(const_generics): this doesn't work right now,
// because it tries to relate an `Infer` to a `Param`.
ConstValue::Unevaluated(did, substs) => {
// if `substs` has no unresolved components, use and empty param_env
let (param_env, substs) = param_env.with_reveal_all().and(substs).into_parts();
// try to resolve e.g. associated constants to their definition on an impl
let instance = ty::Instance::resolve(tcx, param_env, did, substs)?;
let instance = match ty::Instance::resolve(tcx, param_env, did, substs) {
Some(instance) => instance,
None => return self,
};
let gid = GlobalId {
instance,
promoted: None,
};
let evaluated = tcx.const_eval(param_env.and(gid)).ok()?;
evaluated.val.try_to_bits(size)
tcx.const_eval(param_env.and(gid)).unwrap_or(self)
},
// otherwise just extract a `ConstValue`'s bits if possible
_ => self.val.try_to_bits(size),
_ => self,
}
}

Expand Down
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
Loading

0 comments on commit 7b0085a

Please sign in to comment.