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 11 pull requests #49924

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2a5f3ee
Make --emit=metadata output metadata regardless of link
varkor Mar 22, 2018
8056506
Special-case OutputType::Metadata
varkor Mar 31, 2018
7575d96
Reformat trans skip condition
varkor Apr 10, 2018
7d93920
Implement Chalk lowering rule Normalize-From-Impl
fanzier Apr 3, 2018
0bf3eb6
Improve function name.
fanzier Apr 7, 2018
7e50039
Rebase and update code.
fanzier Apr 11, 2018
34956c8
Don't inject clippy into rls on stable/beta
oli-obk Apr 11, 2018
0b393e0
Ignore copyright year when generating deriving span tests
varkor Apr 11, 2018
2ef8493
Stop duplicating where clauses from impl's.
fanzier Apr 11, 2018
ec3bccb
core: Remove panics from some `Layout` methods
alexcrichton Apr 11, 2018
d554f4c
Add #[no_debug] to trans_fn_attrs() query.
michaelwoerister Apr 12, 2018
f78b8c0
Support #[no_debug] for global variables.
michaelwoerister Apr 12, 2018
f711c05
Clean up attribute handling in create_function_debug_context().
michaelwoerister Apr 12, 2018
f1610ae
Use #[no_debug] to work around LLVM problem with rustc_driver::get_tr…
michaelwoerister Apr 12, 2018
6f10146
Fix test failure in src/tools/rustdoc-themes when rust.rpath = false
chrisccoulson Apr 12, 2018
de34533
Add check builder for Windows to Travis
Mark-Simulacrum Apr 11, 2018
807c1a0
Make OnDiskCache thread-safer
Zoxc Feb 15, 2018
2f60341
improve Atomic*::fetch_update docs
llogiq Apr 12, 2018
35087fc
Remove -Z miri debugging option
f-bro Apr 13, 2018
976a17b
Rollup merge of #49396 - Zoxc:sync-on-disk-cache, r=michaelwoerister
kennytm Apr 13, 2018
509ccd6
Rollup merge of #49626 - fanzier:chalk-lowering, r=scalexm
kennytm Apr 13, 2018
f4ac852
Rollup merge of #49866 - Mark-Simulacrum:pr-travis-windows, r=alexcri…
kennytm Apr 13, 2018
9dbfcb5
Rollup merge of #49876 - oli-obk:no_secret_clippy_on_stable_☹, r=nrc
kennytm Apr 13, 2018
09c321c
Rollup merge of #49884 - alexcrichton:less-unwrap, r=Mark-Simulacrum
kennytm Apr 13, 2018
28bf5a3
Rollup merge of #49886 - varkor:generate-deriving-span-tests-usabilit…
kennytm Apr 13, 2018
451cf7c
Rollup merge of #49904 - michaelwoerister:no-debug-attr, r=alexcrichton
kennytm Apr 13, 2018
0bf5af0
Rollup merge of #49908 - chrisccoulson:fix-rustdoc-themes-test-withou…
kennytm Apr 13, 2018
5d59264
Rollup merge of #49922 - f-bro:zmiri, r=oli-obk
kennytm Apr 13, 2018
ba8be1d
Rollup merge of #49916 - llogiq:doc-atomic-fetch-update, r=kennytm
kennytm Apr 13, 2018
f1da9f4
Rollup merge of #49289 - varkor:emit-metadata-without-link, r=michael…
kennytm Apr 13, 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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ matrix:
if: branch = auto
- env: IMAGE=x86_64-gnu-distcheck
if: branch = auto
- env: IMAGE=mingw-check
if: type = pull_request OR branch = auto

- stage: publish toolstate
if: branch = master AND type = push
Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ fn main() {
// When running miri tests, we need to generate MIR for all libraries
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
cmd.arg("-Zalways-encode-mir");
if stage != "0" {
cmd.arg("-Zmiri");
}
cmd.arg("-Zmir-emit-validate=1");
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ impl Step for RustdocTheme {
}

fn run(self, builder: &Builder) {
let rustdoc = builder.rustdoc(self.compiler.host);
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
cmd.arg(rustdoc.to_str().unwrap())
.arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
Expand Down Expand Up @@ -875,7 +875,7 @@ impl Step for Compiletest {
if build.config.rust_debuginfo_tests {
flags.push("-g".to_string());
}
flags.push("-Zmiri -Zunstable-options".to_string());
flags.push("-Zunstable-options".to_string());
flags.push(build.config.cmd.rustc_args().join(" "));

if let Some(linker) = build.linker(target) {
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ tool_extended!((self, builder),
target: self.target,
extra_features: Vec::new(),
});
if clippy.is_some() {
let channel = &builder.config.channel;
if clippy.is_some() && channel != "stable" && channel != "beta" {
self.extra_features.push("clippy".to_owned());
}
builder.ensure(native::Openssl {
Expand Down
22 changes: 22 additions & 0 deletions src/ci/docker/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python2.7 \
git \
cmake \
sudo \
gdb \
xz-utils \
libssl-dev \
pkg-config \
mingw-w64

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV SCRIPT python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu
25 changes: 19 additions & 6 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
sample usage: src/etc/generate-deriving-span-tests.py
"""

import sys, os, datetime, stat
import sys, os, datetime, stat, re

TEST_DIR = os.path.abspath(
os.path.join(os.path.dirname(__file__), '../test/compile-fail'))
Expand Down Expand Up @@ -87,16 +87,25 @@ def create_test_case(type, trait, super_traits, error_count):
def write_file(name, string):
test_file = os.path.join(TEST_DIR, 'derives-span-%s.rs' % name)

with open(test_file) as f:
old_str = f.read()
old_str_ignoring_date = re.sub(r'^// Copyright \d+',
'// Copyright {year}'.format(year = YEAR), old_str)
if old_str_ignoring_date == string:
# if all we're doing is updating the copyright year, ignore it
return 0

# set write permission if file exists, so it can be changed
if os.path.exists(test_file):
os.chmod(test_file, stat.S_IWUSR)

with open(test_file, 'wt') as f:
with open(test_file, 'w') as f:
f.write(string)

# mark file read-only
os.chmod(test_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)

return 1


ENUM = 1
Expand All @@ -120,11 +129,15 @@ def write_file(name, string):
('Hash', [], 1)]:
traits[trait] = (ALL, supers, errs)

files = 0

for (trait, (types, super_traits, error_count)) in traits.items():
mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
if types & ENUM:
write_file(trait + '-enum', mk(ENUM_TUPLE))
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
files += write_file(trait + '-enum', mk(ENUM_TUPLE))
files += write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
if types & STRUCT:
write_file(trait + '-struct', mk(STRUCT_FIELDS))
write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
files += write_file(trait + '-struct', mk(STRUCT_FIELDS))
files += write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))

print('Generated {files} deriving span test{}.'.format('s' if files != 1 else '', files = files))
22 changes: 14 additions & 8 deletions src/libcore/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,26 @@ impl Layout {
/// Constructs a `Layout` suitable for holding a value of type `T`.
pub fn new<T>() -> Self {
let (size, align) = size_align::<T>();
Layout::from_size_align(size, align).unwrap()
// Note that the align is guaranteed by rustc to be a power of two and
// the size+align combo is guaranteed to fit in our address space. As a
// result use the unchecked constructor here to avoid inserting code
// that panics if it isn't optimized well enough.
debug_assert!(Layout::from_size_align(size, align).is_some());
unsafe {
Layout::from_size_align_unchecked(size, align)
}
}

/// Produces layout describing a record that could be used to
/// allocate backing structure for `T` (which could be a trait
/// or other unsized type like a slice).
pub fn for_value<T: ?Sized>(t: &T) -> Self {
let (size, align) = (mem::size_of_val(t), mem::align_of_val(t));
Layout::from_size_align(size, align).unwrap()
// See rationale in `new` for why this us using an unsafe variant below
debug_assert!(Layout::from_size_align(size, align).is_some());
unsafe {
Layout::from_size_align_unchecked(size, align)
}
}

/// Creates a layout describing the record that can hold a value
Expand Down Expand Up @@ -212,12 +223,7 @@ impl Layout {
pub fn repeat(&self, n: usize) -> Option<(Self, usize)> {
let padded_size = self.size.checked_add(self.padding_needed_for(self.align))?;
let alloc_size = padded_size.checked_mul(n)?;

// We can assume that `self.align` is a power-of-two.
// Furthermore, `alloc_size` has already been rounded up
// to a multiple of `self.align`; therefore, the call to
// `Layout::from_size_align` below should never panic.
Some((Layout::from_size_align(alloc_size, self.align).unwrap(), padded_size))
Some((Layout::from_size_align(alloc_size, self.align)?, padded_size))
}

/// Creates a layout describing the record for `self` followed by
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,8 @@ assert_eq!(foo.load(Ordering::SeqCst), 0b011110);

doc_comment! {
concat!("Fetches the value, and applies a function to it that returns an optional
new value. Returns a `Result` (`Ok(_)` if the function returned `Some(_)`, else `Err(_)`) of the
previous value.
new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else
`Err(previous_value)`.

Note: This may call the function multiple times if the value has been changed from other threads in
the meantime, as long as the function returns `Some(_)`, but the function will have been applied
Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,7 @@ bitflags! {
const NAKED = 0b0001_0000;
const NO_MANGLE = 0b0010_0000;
const RUSTC_STD_INTERNAL_SYMBOL = 0b0100_0000;
const NO_DEBUG = 0b1000_0000;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::DomainGoal<'tcx>
FromEnv(where_clause) => where_clause.hash_stable(hcx, hasher),

WellFormedTy(ty) => ty.hash_stable(hcx, hasher),
Normalize(projection) => projection.hash_stable(hcx, hasher),
FromEnvTy(ty) => ty.hash_stable(hcx, hasher),
RegionOutlives(predicate) => predicate.hash_stable(hcx, hasher),
TypeOutlives(predicate) => predicate.hash_stable(hcx, hasher),
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"print some statistics about MIR"),
always_encode_mir: bool = (false, parse_bool, [TRACKED],
"encode MIR of all functions into the crate metadata"),
miri: bool = (false, parse_bool, [TRACKED],
"check the miri const evaluator against the old ctfe"),
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
"pass `-install_name @rpath/...` to the macOS linker"),
sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
Expand Down
1 change: 1 addition & 0 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ pub enum DomainGoal<'tcx> {
WellFormed(WhereClauseAtom<'tcx>),
FromEnv(WhereClauseAtom<'tcx>),
WellFormedTy(Ty<'tcx>),
Normalize(ty::ProjectionPredicate<'tcx>),
FromEnvTy(Ty<'tcx>),
RegionOutlives(ty::RegionOutlivesPredicate<'tcx>),
TypeOutlives(ty::TypeOutlivesPredicate<'tcx>),
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> {
FromEnv(Implemented(trait_ref)) => write!(fmt, "FromEnv({})", trait_ref),
FromEnv(ProjectionEq(projection)) => write!(fmt, "FromEnv({})", projection),
WellFormedTy(ty) => write!(fmt, "WellFormed({})", ty),
Normalize(projection) => write!(fmt, "Normalize({})", projection),
FromEnvTy(ty) => write!(fmt, "FromEnv({})", ty),
RegionOutlives(predicate) => write!(fmt, "RegionOutlives({})", predicate),
TypeOutlives(predicate) => write!(fmt, "TypeOutlives({})", predicate),
Expand Down Expand Up @@ -537,6 +538,7 @@ EnumTypeFoldableImpl! {
(traits::DomainGoal::WellFormed)(wc),
(traits::DomainGoal::FromEnv)(wc),
(traits::DomainGoal::WellFormedTy)(ty),
(traits::DomainGoal::Normalize)(projection),
(traits::DomainGoal::FromEnvTy)(ty),
(traits::DomainGoal::RegionOutlives)(predicate),
(traits::DomainGoal::TypeOutlives)(predicate),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::sync::{Lrc, Lock};
use std::any::Any;
use std::borrow::Borrow;
use std::cell::{Cell, RefCell};
use std::cell::Cell;
use std::cmp::Ordering;
use std::collections::hash_map::{self, Entry};
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -890,7 +890,7 @@ pub struct GlobalCtxt<'tcx> {
maybe_unused_extern_crates: Vec<(DefId, Span)>,

// Internal cache for metadata decoding. No need to track deps on this.
pub rcache: RefCell<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
pub rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,

/// Caches the results of trait selection. This cache is used
/// for things that do not have to do with the parameters in scope.
Expand Down Expand Up @@ -1286,7 +1286,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
hir,
def_path_hash_to_def_id,
maps: maps::Maps::new(providers),
rcache: RefCell::new(FxHashMap()),
rcache: Lock::new(FxHashMap()),
selection_cache: traits::SelectionCache::new(),
evaluation_cache: traits::EvaluationCache::new(),
crate_name: Symbol::intern(crate_name),
Expand Down
45 changes: 22 additions & 23 deletions src/librustc/ty/maps/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use hir::map::definitions::DefPathHash;
use ich::{CachingCodemapView, Fingerprint};
use mir::{self, interpret};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once};
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
SpecializedDecoder, SpecializedEncoder,
Expand Down Expand Up @@ -57,17 +57,17 @@ pub struct OnDiskCache<'sess> {

// This field collects all Diagnostics emitted during the current
// compilation session.
current_diagnostics: RefCell<FxHashMap<DepNodeIndex, Vec<Diagnostic>>>,
current_diagnostics: Lock<FxHashMap<DepNodeIndex, Vec<Diagnostic>>>,

prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
cnum_map: RefCell<Option<IndexVec<CrateNum, Option<CrateNum>>>>,
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,

codemap: &'sess CodeMap,
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,

// These two fields caches that are populated lazily during decoding.
file_index_to_file: RefCell<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
synthetic_expansion_infos: RefCell<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
file_index_to_file: Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,

// A map from dep-node to the position of the cached query result in
// `serialized_data`.
Expand Down Expand Up @@ -140,14 +140,14 @@ impl<'sess> OnDiskCache<'sess> {
OnDiskCache {
serialized_data: data,
file_index_to_stable_id: footer.file_index_to_stable_id,
file_index_to_file: RefCell::new(FxHashMap()),
file_index_to_file: Lock::new(FxHashMap()),
prev_cnums: footer.prev_cnums,
cnum_map: RefCell::new(None),
cnum_map: Once::new(),
codemap: sess.codemap(),
current_diagnostics: RefCell::new(FxHashMap()),
current_diagnostics: Lock::new(FxHashMap()),
query_result_index: footer.query_result_index.into_iter().collect(),
prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(),
synthetic_expansion_infos: RefCell::new(FxHashMap()),
synthetic_expansion_infos: Lock::new(FxHashMap()),
interpret_alloc_cache: RefCell::new(FxHashMap::default()),
interpret_alloc_size: RefCell::new(FxHashMap::default()),
}
Expand All @@ -157,14 +157,14 @@ impl<'sess> OnDiskCache<'sess> {
OnDiskCache {
serialized_data: Vec::new(),
file_index_to_stable_id: FxHashMap(),
file_index_to_file: RefCell::new(FxHashMap()),
file_index_to_file: Lock::new(FxHashMap()),
prev_cnums: vec![],
cnum_map: RefCell::new(None),
cnum_map: Once::new(),
codemap,
current_diagnostics: RefCell::new(FxHashMap()),
current_diagnostics: Lock::new(FxHashMap()),
query_result_index: FxHashMap(),
prev_diagnostics_index: FxHashMap(),
synthetic_expansion_infos: RefCell::new(FxHashMap()),
synthetic_expansion_infos: Lock::new(FxHashMap()),
interpret_alloc_cache: RefCell::new(FxHashMap::default()),
interpret_alloc_size: RefCell::new(FxHashMap::default()),
}
Expand Down Expand Up @@ -383,18 +383,16 @@ impl<'sess> OnDiskCache<'sess> {
return None
};

// Initialize the cnum_map if it is not initialized yet.
if self.cnum_map.borrow().is_none() {
let mut cnum_map = self.cnum_map.borrow_mut();
*cnum_map = Some(Self::compute_cnum_map(tcx, &self.prev_cnums[..]));
}
let cnum_map = self.cnum_map.borrow();
// Initialize the cnum_map using the value from the thread which finishes the closure first
self.cnum_map.init_nonlocking_same(|| {
Self::compute_cnum_map(tcx, &self.prev_cnums[..])
});

let mut decoder = CacheDecoder {
tcx,
opaque: opaque::Decoder::new(&self.serialized_data[..], pos.to_usize()),
codemap: self.codemap,
cnum_map: cnum_map.as_ref().unwrap(),
cnum_map: self.cnum_map.get(),
file_index_to_file: &self.file_index_to_file,
file_index_to_stable_id: &self.file_index_to_stable_id,
synthetic_expansion_infos: &self.synthetic_expansion_infos,
Expand Down Expand Up @@ -458,8 +456,8 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> {
opaque: opaque::Decoder<'x>,
codemap: &'x CodeMap,
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
synthetic_expansion_infos: &'x RefCell<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
file_index_to_file: &'x RefCell<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
file_index_to_stable_id: &'x FxHashMap<FileMapIndex, StableFilemapId>,
interpret_alloc_cache: &'x RefCell<FxHashMap<usize, interpret::AllocId>>,
interpret_alloc_size: &'x RefCell<FxHashMap<usize, usize>>,
Expand Down Expand Up @@ -557,7 +555,8 @@ impl<'a, 'tcx: 'a, 'x> ty_codec::TyDecoder<'a, 'tcx> for CacheDecoder<'a, 'tcx,
}

let ty = or_insert_with(self)?;
tcx.rcache.borrow_mut().insert(cache_key, ty);
// This may overwrite the entry, but it should overwrite with the same value
tcx.rcache.borrow_mut().insert_same(cache_key, ty);
Ok(ty)
}

Expand Down
4 changes: 4 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#![feature(slice_sort_by_cached_key)]
#![feature(set_stdio)]
#![feature(rustc_stack_internals)]
#![feature(no_debug)]

extern crate arena;
extern crate getopts;
Expand Down Expand Up @@ -230,6 +231,9 @@ fn load_backend_from_dylib(path: &Path) -> fn() -> Box<TransCrate> {

pub fn get_trans(sess: &Session) -> Box<TransCrate> {
static INIT: Once = ONCE_INIT;

#[allow(deprecated)]
#[no_debug]
static mut LOAD: fn() -> Box<TransCrate> = || unreachable!();

INIT.call_once(|| {
Expand Down
Loading