Skip to content
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

Rollup of 10 pull requests #65422

Merged
merged 47 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
53e7393
Tweak `tcx` usage in `lub_concrete_regions()`.
nnethercote Oct 9, 2019
59e41ed
Special-case `ReEmpty` in `expand_node()`.
nnethercote Oct 10, 2019
8cd25e7
Remove `tag` from `iterate_until_fixed_point()`.
nnethercote Oct 10, 2019
a14601e
std::fmt: move format string grammar to the bottom
RalfJung Oct 12, 2019
f727f8a
move Formatting Traits down
RalfJung Oct 12, 2019
504cc20
remove confusing and redundant subsection
RalfJung Oct 12, 2019
4d1a5ad
Introduce FuncId backend type
bjorn3 Aug 27, 2019
cf858a8
Remove is_const_integral method from ConstMethods
bjorn3 Aug 27, 2019
41d329c
Remove unused method CodegenBackend::diagnostics
bjorn3 Oct 12, 2019
5f203d5
Move some provides from cg_llvm to rustc_interface
bjorn3 Oct 12, 2019
5f6ddb9
Move span_invalid_monomorphization_error from cg_llvm to cg_ssa
bjorn3 Oct 12, 2019
f1ed3a8
s/FuncId/Function
bjorn3 Oct 13, 2019
dad8ddb
Inline functions from cg_ssa::callee and remove the mod
bjorn3 Oct 13, 2019
bcb01bc
Remove MiscMethods::instances
bjorn3 Oct 13, 2019
ea60335
Add top level provide/provide_extern to cg_ssa and cg_utils
bjorn3 Oct 13, 2019
f0e2fc7
Improve type safety
bjorn3 Oct 13, 2019
5c93492
Remove the `Option` in `TokenStream`.
nnethercote Oct 9, 2019
1ce0347
Use `TokenStream::default()` in more places.
nnethercote Oct 10, 2019
18b48bf
Lazify some `mac_placeholder()` calls.
nnethercote Oct 10, 2019
4bb7716
Bring attention to suggestions when the only difference is capitaliza…
estebank Oct 14, 2019
e8c28e2
rustc_metadata: Privatize private code and remove dead code
petrochenkov Oct 6, 2019
b476f2f
rustc_metadata: Use `CrateSource` where appropriate
petrochenkov Oct 6, 2019
2805553
rustc_metadata: Improve documentation of `CrateMetadata`
petrochenkov Oct 6, 2019
e843d86
rustc_metadata: Crate loader is immutable
petrochenkov Oct 13, 2019
f5baad2
rustc_metadata: Remove resolutions for extern crate items from `CStore`
petrochenkov Oct 13, 2019
29fb07d
syntax: add recovery for intersection patterns `p1 @ p2`
Centril Oct 14, 2019
a77a8aa
syntax: add test for intersection pattern parser recovery
Centril Oct 14, 2019
72ad8f7
syntax: use `PatKind::Wild` as our `::Err` equivalent.
Centril Oct 14, 2019
3a9f8de
recover_intersection_pat: adjust wording
Centril Oct 14, 2019
16266a5
pprust: `p1@p2` -> `p1 @ p2`
Centril Oct 14, 2019
eb68bbb
Include const generic arguments in metadata.
skinnyBat Oct 13, 2019
34bcfca
Remove an outdated test output file
petrochenkov Oct 14, 2019
068a8d1
Minor comment tweaks
spastorino Oct 14, 2019
8356022
Move serial_scope and serial_join to parallel_compiler = false
spastorino Oct 14, 2019
b9bc431
Rename serial_join and serial_scope to join and scope
spastorino Oct 14, 2019
6dd718c
Use heuristics for capitalization warning in suggestions
estebank Oct 14, 2019
8bf6d35
Tweak heuristics for less noise
estebank Oct 14, 2019
d2f87e3
Rollup merge of #65170 - petrochenkov:cload, r=eddyb
tmandry Oct 15, 2019
a9a4d40
Rollup merge of #65260 - nnethercote:optimize-LexicalResolve-expansio…
tmandry Oct 15, 2019
6d28ed1
Rollup merge of #65261 - nnethercote:rm-Option-from-TokenStream, r=pe…
tmandry Oct 15, 2019
e38639f
Rollup merge of #65332 - RalfJung:fmt, r=cramertj
tmandry Oct 15, 2019
6241a4a
Rollup merge of #65340 - bjorn3:cg_ssa_refactor4, r=eddyb
tmandry Oct 15, 2019
8d1123d
Rollup merge of #65365 - skinny121:const-args-metadata, r=varkor
tmandry Oct 15, 2019
a14e35f
Rollup merge of #65398 - estebank:capitalization-only, r=varkor
tmandry Oct 15, 2019
1b18237
Rollup merge of #65410 - Centril:intersection-pat-recover, r=davidtwc…
tmandry Oct 15, 2019
ae5093d
Rollup merge of #65415 - petrochenkov:rmtest, r=varkor
tmandry Oct 15, 2019
9422feb
Rollup merge of #65416 - spastorino:minor-sync-changes, r=Mark-Simula…
tmandry Oct 15, 2019
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
366 changes: 175 additions & 191 deletions src/liballoc/fmt.rs

Large diffs are not rendered by default.

26 changes: 16 additions & 10 deletions src/librustc/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}

fn expansion(&self, var_values: &mut LexicalRegionResolutions<'tcx>) {
self.iterate_until_fixed_point("Expansion", |constraint| {
self.iterate_until_fixed_point(|constraint| {
debug!("expansion: constraint={:?}", constraint);
let (a_region, b_vid, b_data, retain) = match *constraint {
Constraint::RegSubVar(a_region, b_vid) => {
Expand Down Expand Up @@ -360,13 +360,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
match *b_data {
VarValue::Value(cur_region) => {
// Identical scopes can show up quite often, if the fixed point
// iteration converges slowly, skip them
// iteration converges slowly. Skip them. This is purely an
// optimization.
if let (ReScope(a_scope), ReScope(cur_scope)) = (a_region, cur_region) {
if a_scope == cur_scope {
return false;
}
}

// This is a specialized version of the `lub_concrete_regions`
// check below for a common case, here purely as an
// optimization.
if let ReEmpty = a_region {
return false;
}

let mut lub = self.lub_concrete_regions(a_region, cur_region);
if lub == cur_region {
return false;
Expand Down Expand Up @@ -407,8 +415,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {

/// Returns the smallest region `c` such that `a <= c` and `b <= c`.
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
let tcx = self.tcx();

match (a, b) {
(&ty::ReClosureBound(..), _)
| (_, &ty::ReClosureBound(..))
Expand Down Expand Up @@ -468,15 +474,15 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {

// otherwise, we don't know what the free region is,
// so we must conservatively say the LUB is static:
tcx.lifetimes.re_static
self.tcx().lifetimes.re_static
}

(&ReScope(a_id), &ReScope(b_id)) => {
// The region corresponding to an outer block is a
// subtype of the region corresponding to an inner
// block.
let lub = self.region_rels.region_scope_tree.nearest_common_ancestor(a_id, b_id);
tcx.mk_region(ReScope(lub))
self.tcx().mk_region(ReScope(lub))
}

(&ReEarlyBound(_), &ReEarlyBound(_))
Expand All @@ -490,7 +496,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
if a == b {
a
} else {
tcx.lifetimes.re_static
self.tcx().lifetimes.re_static
}
}
}
Expand Down Expand Up @@ -860,7 +866,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}
}

fn iterate_until_fixed_point<F>(&self, tag: &str, mut body: F)
fn iterate_until_fixed_point<F>(&self, mut body: F)
where
F: FnMut(&Constraint<'tcx>) -> (bool, bool),
{
Expand All @@ -870,7 +876,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
while changed {
changed = false;
iteration += 1;
debug!("---- {} Iteration {}{}", "#", tag, iteration);
debug!("---- Expansion iteration {}", iteration);
constraints.retain(|constraint| {
let (edge_changed, retain) = body(constraint);
if edge_changed {
Expand All @@ -880,7 +886,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
retain
});
}
debug!("---- {} Complete after {} iteration(s)", tag, iteration);
debug!("---- Expansion complete after {} iteration(s)", iteration);
}

fn bound_is_met(
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ pub struct CrateSource {
pub rmeta: Option<(PathBuf, PathKind)>,
}

impl CrateSource {
pub fn paths(&self) -> impl Iterator<Item = &PathBuf> {
self.dylib.iter().chain(self.rlib.iter()).chain(self.rmeta.iter()).map(|p| &p.0)
}
}

#[derive(RustcEncodable, RustcDecodable, Copy, Clone,
Ord, PartialOrd, Eq, PartialEq, Debug, HashStable)]
pub enum DepKind {
Expand Down Expand Up @@ -208,7 +214,6 @@ pub trait CrateStore {
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool;
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator;
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;
fn extern_mod_stmt_cnum_untracked(&self, emod_id: ast::NodeId) -> Option<CrateNum>;
fn item_generics_cloned_untracked(&self, def: DefId, sess: &Session) -> ty::Generics;
fn postorder_cnums_untracked(&self) -> Vec<CrateNum>;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use syntax::feature_gate::UnstableFeatures;
use syntax::source_map::SourceMap;

use errors::emitter::HumanReadableErrorType;
use errors::{ColorConfig, FatalError, Handler};
use errors::{ColorConfig, FatalError, Handler, SourceMapperDyn};

use getopts;

Expand Down Expand Up @@ -1857,6 +1857,7 @@ struct NullEmitter;

impl errors::emitter::Emitter for NullEmitter {
fn emit_diagnostic(&mut self, _: &errors::Diagnostic) {}
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> { None }
}

// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::ty::subst::{UserSubsts, GenericArgKind};
use crate::ty::{BoundVar, BindingMode};
use crate::ty::CanonicalPolyFnSig;
use crate::util::common::ErrorReported;
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet};
use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet, NodeMap};
use crate::util::nodemap::{FxHashMap, FxHashSet};
use crate::util::profiling::SelfProfilerRef;

Expand Down Expand Up @@ -1051,6 +1051,9 @@ pub struct GlobalCtxt<'tcx> {
/// Common consts, pre-interned for your convenience.
pub consts: CommonConsts<'tcx>,

/// Resolutions of `extern crate` items produced by resolver.
extern_crate_map: NodeMap<CrateNum>,

/// Map indicating what traits are in scope for places where this
/// is relevant; generated by resolve.
trait_map: FxHashMap<DefIndex,
Expand Down Expand Up @@ -1274,6 +1277,7 @@ impl<'tcx> TyCtxt<'tcx> {
types: common_types,
lifetimes: common_lifetimes,
consts: common_consts,
extern_crate_map: resolutions.extern_crate_map,
trait_map,
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
let exports: Vec<_> = v.into_iter().map(|e| {
Expand Down Expand Up @@ -2951,7 +2955,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
};
providers.extern_mod_stmt_cnum = |tcx, id| {
let id = tcx.hir().as_local_node_id(id).unwrap();
tcx.cstore.extern_mod_stmt_cnum_untracked(id)
tcx.extern_crate_map.get(&id).cloned()
};
providers.all_crate_nums = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
use crate::ty::util::{IntTypeExt, Discr};
use crate::ty::walk::TypeWalker;
use crate::util::captures::Captures;
use crate::util::nodemap::{NodeSet, DefIdMap, FxHashMap};
use crate::util::nodemap::{NodeMap, NodeSet, DefIdMap, FxHashMap};
use arena::SyncDroplessArena;
use crate::session::DataTypeKind;

Expand Down Expand Up @@ -121,6 +121,7 @@ mod sty;

#[derive(Clone)]
pub struct Resolutions {
pub extern_crate_map: NodeMap<CrateNum>,
pub trait_map: TraitMap,
pub maybe_unused_trait_imports: NodeSet,
pub maybe_unused_extern_crates: Vec<(NodeId, Span)>,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const UNNAMED: *const c_char = EMPTY_C_STR.as_ptr();

impl BackendTypes for Builder<'_, 'll, 'tcx> {
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
type Function = <CodegenCx<'ll, 'tcx> as BackendTypes>::Function;
type BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn get_fn(
assert!(!instance.substs.has_param_types());

let sig = instance.fn_sig(cx.tcx());
if let Some(&llfn) = cx.instances().borrow().get(&instance) {
if let Some(&llfn) = cx.instances.borrow().get(&instance) {
return llfn;
}

Expand Down
42 changes: 20 additions & 22 deletions src/librustc_codegen_llvm/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! Code that is useful in various codegen modules.

use crate::llvm::{self, True, False, Bool, BasicBlock, OperandBundleDef};
use crate::llvm::{self, True, False, Bool, BasicBlock, OperandBundleDef, ConstantInt};
use crate::abi;
use crate::consts;
use crate::type_::Type;
Expand Down Expand Up @@ -86,6 +86,8 @@ impl Funclet<'ll> {

impl BackendTypes for CodegenCx<'ll, 'tcx> {
type Value = &'ll Value;
type Function = &'ll Value;

type BasicBlock = &'ll BasicBlock;
type Type = &'ll Type;
type Funclet = Funclet<'ll>;
Expand Down Expand Up @@ -243,33 +245,23 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
struct_in_context(self.llcx, elts, packed)
}

fn const_to_uint(&self, v: &'ll Value) -> u64 {
unsafe {
fn const_to_opt_uint(&self, v: &'ll Value) -> Option<u64> {
try_as_const_integral(v).map(|v| unsafe {
llvm::LLVMConstIntGetZExtValue(v)
}
}

fn is_const_integral(&self, v: &'ll Value) -> bool {
unsafe {
llvm::LLVMIsAConstantInt(v).is_some()
}
})
}

fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
unsafe {
if self.is_const_integral(v) {
let (mut lo, mut hi) = (0u64, 0u64);
let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
&mut hi, &mut lo);
if success {
Some(hi_lo_to_u128(lo, hi))
} else {
None
}
try_as_const_integral(v).and_then(|v| unsafe {
let (mut lo, mut hi) = (0u64, 0u64);
let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
&mut hi, &mut lo);
if success {
Some(hi_lo_to_u128(lo, hi))
} else {
None
}
}
})
}

fn scalar_to_backend(
Expand Down Expand Up @@ -305,7 +297,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
}
Some(GlobalAlloc::Function(fn_instance)) => {
self.get_fn(fn_instance)
self.get_fn_addr(fn_instance)
}
Some(GlobalAlloc::Static(def_id)) => {
assert!(self.tcx.is_static(def_id));
Expand Down Expand Up @@ -386,3 +378,9 @@ pub fn struct_in_context(
fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
((hi as u128) << 64) | (lo as u128)
}

fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> {
unsafe {
llvm::LLVMIsAConstantInt(v)
}
}
25 changes: 19 additions & 6 deletions src/librustc_codegen_llvm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use rustc::ty::layout::{
use rustc::ty::{self, Ty, TyCtxt, Instance};
use rustc::util::nodemap::FxHashMap;
use rustc_target::spec::{HasTargetSpec, Target};
use rustc_codegen_ssa::callee::resolve_and_get_fn;
use rustc_codegen_ssa::base::wants_msvc_seh;
use crate::callee::get_fn;

Expand Down Expand Up @@ -327,11 +326,11 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
&self.vtables
}

fn instances(&self) -> &RefCell<FxHashMap<Instance<'tcx>, &'ll Value>> {
&self.instances
fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
get_fn(self, instance)
}

fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
fn get_fn_addr(&self, instance: Instance<'tcx>) -> &'ll Value {
get_fn(self, instance)
}

Expand Down Expand Up @@ -362,7 +361,14 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let tcx = self.tcx;
let llfn = match tcx.lang_items().eh_personality() {
Some(def_id) if !wants_msvc_seh(self.sess()) => {
resolve_and_get_fn(self, def_id, tcx.intern_substs(&[]))
self.get_fn_addr(
ty::Instance::resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
tcx.intern_substs(&[]),
).unwrap()
)
}
_ => {
let name = if wants_msvc_seh(self.sess()) {
Expand Down Expand Up @@ -390,7 +396,14 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let tcx = self.tcx;
assert!(self.sess().target.target.options.custom_unwind_resume);
if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
let llfn = resolve_and_get_fn(self, def_id, tcx.intern_substs(&[]));
let llfn = self.get_fn_addr(
ty::Instance::resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
tcx.intern_substs(&[]),
).unwrap()
);
unwresume.set(Some(llfn));
return llfn;
}
Expand Down
38 changes: 0 additions & 38 deletions src/librustc_codegen_llvm/error_codes.rs

This file was deleted.

6 changes: 1 addition & 5 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
use rustc::hir;
use syntax::ast::{self, FloatTy};

use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
use rustc_codegen_ssa::traits::*;

use rustc::session::Session;
use syntax_pos::Span;

use std::cmp::Ordering;
Expand Down Expand Up @@ -1026,10 +1026,6 @@ fn get_rust_try_fn<'ll, 'tcx>(
rust_try
}

fn span_invalid_monomorphization_error(a: &Session, b: Span, c: &str) {
span_err!(a, b, E0511, "{}", c);
}

fn generic_simd_intrinsic(
bx: &mut Builder<'a, 'll, 'tcx>,
name: &str,
Expand Down
Loading