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 9 pull requests #62215

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6cc42ce
Revert "Set test flag when rustdoc is running with --test option"
ollie27 May 25, 2019
6c747e0
Fix tests after revert of rustdoc cfg(test) feature
ollie27 May 25, 2019
c77024c
Fix more tests after revert of rustdoc cfg(test) feature
ollie27 Jun 9, 2019
a8b2b1c
publish_toolstate: don't use 'new' from inside the loop
RalfJung Jun 21, 2019
fb2f841
give a bit more context in the error message
RalfJung Jun 21, 2019
e02c655
dump the JSON we are going to submit to GH to create the issue
RalfJung Jun 21, 2019
8ceab32
fix long line
RalfJung Jun 21, 2019
e10012d
show HTTP error body
RalfJung Jun 21, 2019
ecca52c
don't make PR author assignee; that break creating the issue when the…
RalfJung Jun 21, 2019
02863a3
do as tidy says
RalfJung Jun 21, 2019
a56a6d7
bootstrap: pass '--pass' on to compiletest.
Centril Jun 11, 2019
54337fa
compiletest: support '--pass check' and '// ignore-pass'.
Centril Jun 12, 2019
e364eb4
add '// ignore-pass' where applicable.
Centril Jun 12, 2019
e4e0f95
promoted_errors: warn -> deny.
Centril Jun 12, 2019
5baac07
lint-type-overflow2: warn -> deny.
Centril Jun 12, 2019
5eaedda
Address review comments.
Centril Jun 24, 2019
a60bbb0
--bless you.
Centril Jun 24, 2019
c877989
Add some #[inline] attributes
Zoxc Jun 25, 2019
11221d1
Inform the query system about properties of queries at compile time
Zoxc Jun 24, 2019
93077f3
Hash force_pass_mode when config.mode == Pretty.
Centril Jun 26, 2019
742e851
Update miri
JohnTitor Jun 24, 2019
3ba1f39
Avoid mem::uninitialized() in std::sys::unix
cuviper Jun 26, 2019
b533aff
Use pointer::write_bytes for android sigemptyset
cuviper Jun 26, 2019
c33ab36
Implement mem::{zeroed,uninitialized} in terms of MaybeUninit.
alex Jun 26, 2019
643ae63
doc(libcore) Fix CS
Hywan Jun 28, 2019
bd10be5
Add Vec::leak
cramertj Jun 27, 2019
3dfca34
Rollup merge of #61199 - ollie27:rustdoc_cfg_test, r=QuietMisdreavus
Centril Jun 28, 2019
49c2a2a
Rollup merge of #61755 - Centril:compiletest-force-check, r=petrochenkov
Centril Jun 28, 2019
0bddcd1
Rollup merge of #62023 - RalfJung:miri-toolstate, r=kennytm
Centril Jun 28, 2019
f381c2c
Rollup merge of #62104 - Zoxc:query-info, r=eddyb
Centril Jun 28, 2019
66e8257
Rollup merge of #62105 - JohnTitor:update-miri, r=RalfJung
Centril Jun 28, 2019
2c0f7eb
Rollup merge of #62150 - alex:mem-uninit-refactor, r=RalfJung,oli-obk…
Centril Jun 28, 2019
c130599
Rollup merge of #62163 - cuviper:unix-uninit, r=RalfJung
Centril Jun 28, 2019
eb3f7e2
Rollup merge of #62196 - cramertj:vec-leak, r=withoutboats,Centril
Centril Jun 28, 2019
9ad8ab8
Rollup merge of #62204 - Hywan:patch-2, r=rkruppe
Centril Jun 28, 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
2 changes: 2 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ fn test_with_no_doc_stage0() {
bless: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
};

let build = Build::new(config);
Expand Down Expand Up @@ -640,6 +641,7 @@ fn test_exclude() {
bless: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
};

let build = Build::new(config);
Expand Down
17 changes: 17 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum Subcommand {
/// Whether to automatically update stderr/stdout files
bless: bool,
compare_mode: Option<String>,
pass: Option<String>,
test_args: Vec<String>,
rustc_args: Vec<String>,
fail_fast: bool,
Expand Down Expand Up @@ -199,6 +200,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
"mode describing what file the actual ui output will be compared to",
"COMPARE MODE",
);
opts.optopt(
"",
"pass",
"force {check,build,run}-pass tests to this mode.",
"check | build | run"
);
opts.optflag(
"",
"rustfix-coverage",
Expand Down Expand Up @@ -401,6 +408,7 @@ Arguments:
paths,
bless: matches.opt_present("bless"),
compare_mode: matches.opt_str("compare-mode"),
pass: matches.opt_str("pass"),
test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"),
Expand Down Expand Up @@ -524,6 +532,15 @@ impl Subcommand {
_ => None,
}
}

pub fn pass(&self) -> Option<&str> {
match *self {
Subcommand::Test {
ref pass, ..
} => pass.as_ref().map(|s| &s[..]),
_ => None,
}
}
}

fn split(s: &[String]) -> Vec<String> {
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,11 @@ impl Step for Compiletest {
}
});

if let Some(ref pass) = builder.config.cmd.pass() {
cmd.arg("--pass");
cmd.arg(pass);
}

if let Some(ref nodejs) = builder.config.nodejs {
cmd.arg("--nodejs").arg(nodejs);
}
Expand Down
32 changes: 32 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,38 @@ impl<T> Vec<T> {
self.truncate(new_len);
}
}

/// Consumes and leaks the `Vec`, returning a mutable reference to the contents,
/// `&'a mut [T]`. Note that the type `T` must outlive the chosen lifetime
/// `'a`. If the type has only static references, or none at all, then this
/// may be chosen to be `'static`.
///
/// This function is similar to the `leak` function on `Box`.
///
/// This function is mainly useful for data that lives for the remainder of
/// the program's life. Dropping the returned reference will cause a memory
/// leak.
///
/// # Examples
///
/// Simple usage:
///
/// ```
/// fn main() {
/// let x = vec![1, 2, 3];
/// let static_ref: &'static mut [usize] = Vec::leak(x);
/// static_ref[0] += 1;
/// assert_eq!(static_ref, &[2, 2, 3]);
/// }
/// ```
#[unstable(feature = "vec_leak", issue = "62195")]
#[inline]
pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
where
T: 'a // Technically not needed, but kept to be explicit.
{
Box::leak(vec.into_boxed_slice())
}
}

impl<T: Clone> Vec<T> {
Expand Down
10 changes: 1 addition & 9 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,17 +700,9 @@ extern "rust-intrinsic" {
/// which is unsafe unless `T` is `Copy`. Also, even if T is
/// `Copy`, an all-zero value may not correspond to any legitimate
/// state for the type in question.
// FIXME: deprecate once clippy's tests are fixed
pub fn init<T>() -> T;

/// Creates an uninitialized value.
///
/// `uninit` is unsafe because there is no guarantee of what its
/// contents are. In particular its drop-flag may be set to any
/// state, which means it may claim either dropped or
/// undropped. In the general case one must use `ptr::write` to
/// initialize memory previous set to the result of `uninit`.
pub fn uninit<T>() -> T;

/// Moves a value out of scope without running drop glue.
pub fn forget<T: ?Sized>(_: T);

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub trait FromIterator<A>: Sized {
/// ```rust
/// fn collect_as_strings<T>(collection: T) -> Vec<String>
/// where T: IntoIterator,
/// T::Item : std::fmt::Debug,
/// T::Item: std::fmt::Debug,
/// {
/// collection
/// .into_iter()
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ impl<T: ?Sized> !Send for *mut T { }
/// impl Foo for Impl { }
/// impl Bar for Impl { }
///
/// let x: &Foo = &Impl; // OK
/// // let y: &Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// let x: &dyn Foo = &Impl; // OK
/// // let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
/// // be made into an object
/// ```
///
/// [trait object]: ../../book/ch17-02-trait-objects.html
Expand Down
11 changes: 6 additions & 5 deletions src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ pub const fn needs_drop<T>() -> bool {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn zeroed<T>() -> T {
intrinsics::panic_if_uninhabited::<T>();
intrinsics::init()
MaybeUninit::zeroed().assume_init()
}

/// Bypasses Rust's normal memory-initialization checks by pretending to
Expand All @@ -476,8 +475,7 @@ pub unsafe fn zeroed<T>() -> T {
#[rustc_deprecated(since = "1.38.0", reason = "use `mem::MaybeUninit` instead")]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn uninitialized<T>() -> T {
intrinsics::panic_if_uninhabited::<T>();
intrinsics::uninit()
MaybeUninit::uninit().assume_init()
}

/// Swaps the values at two mutable locations, without deinitializing either one.
Expand Down Expand Up @@ -510,6 +508,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// A simple example:
///
/// ```
/// #![feature(mem_take)]
///
/// use std::mem;
///
/// let mut v: Vec<i32> = vec![1, 2];
Expand Down Expand Up @@ -540,7 +540,8 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// `self`, allowing it to be returned:
///
/// ```
/// # #![allow(dead_code)]
/// #![feature(mem_take)]
///
/// use std::mem;
///
/// # struct Buffer<T> { buf: Vec<T> }
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/// let value: i32 = 123;
///
/// // let the compiler make a trait object
/// let object: &Foo = &value;
/// let object: &dyn Foo = &value;
///
/// // look at the raw representation
/// let raw_object: raw::TraitObject = unsafe { mem::transmute(object) };
Expand All @@ -65,7 +65,7 @@
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// let synthesized: &dyn Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable,
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ macro_rules! define_dep_nodes {
}
}

// FIXME: Make `is_anon`, `is_eval_always` and `has_params` properties
// of queries
#[inline(always)]
pub fn is_anon(&self) -> bool {
match *self {
$(
Expand All @@ -163,7 +160,6 @@ macro_rules! define_dep_nodes {
}

#[allow(unreachable_code)]
#[inline(always)]
pub fn has_params(&self) -> bool {
match *self {
$(
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/ty/query/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::dep_graph::SerializedDepNodeIndex;
use crate::dep_graph::DepNode;
use crate::dep_graph::{DepKind, DepNode};
use crate::hir::def_id::{CrateNum, DefId};
use crate::ty::TyCtxt;
use crate::ty::query::queries;
Expand Down Expand Up @@ -28,13 +28,18 @@ pub trait QueryConfig<'tcx> {
}

pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
const ANON: bool;
const EVAL_ALWAYS: bool;

fn query(key: Self::Key) -> Query<'tcx>;

// Don't use this method to access query results, instead use the methods on TyCtxt
fn query_cache<'a>(tcx: TyCtxt<'tcx>) -> &'a Lock<QueryCache<'tcx, Self>>;

fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;

fn dep_kind() -> DepKind;

// Don't use this method to compute query results, instead use the methods on TyCtxt
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ pub use self::on_disk_cache::OnDiskCache;
rustc_query_append! { [define_queries!][ <'tcx>
Other {
/// Runs analysis passes on the crate.
[] fn analysis: Analysis(CrateNum) -> Result<(), ErrorReported>,
[eval_always] fn analysis: Analysis(CrateNum) -> Result<(), ErrorReported>,
},
]}
57 changes: 45 additions & 12 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,13 @@ impl<'tcx> TyCtxt<'tcx> {
return self.force_query_with_job::<Q>(key, job, null_dep_node).0;
}

let dep_node = Q::to_dep_node(self, &key);

if dep_node.kind.is_anon() {
if Q::ANON {
profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
self.sess.profiler(|p| p.start_query(Q::NAME));

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
self.start_query(job.job.clone(), diagnostics, |tcx| {
tcx.dep_graph.with_anon_task(dep_node.kind, || {
tcx.dep_graph.with_anon_task(Q::dep_kind(), || {
Q::compute(tcx.global_tcx(), key)
})
})
Expand All @@ -405,7 +403,9 @@ impl<'tcx> TyCtxt<'tcx> {
return result;
}

if !dep_node.kind.is_eval_always() {
let dep_node = Q::to_dep_node(self, &key);

if !Q::EVAL_ALWAYS {
// The diagnostics for this query will be
// promoted to the current session during
// try_mark_green(), so we can ignore them here.
Expand Down Expand Up @@ -546,7 +546,7 @@ impl<'tcx> TyCtxt<'tcx> {

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
self.start_query(job.job.clone(), diagnostics, |tcx| {
if dep_node.kind.is_eval_always() {
if Q::EVAL_ALWAYS {
tcx.dep_graph.with_eval_always_task(dep_node,
tcx,
key,
Expand All @@ -569,8 +569,8 @@ impl<'tcx> TyCtxt<'tcx> {
self.dep_graph.mark_loaded_from_cache(dep_node_index, false);
}

if dep_node.kind != crate::dep_graph::DepKind::Null {
if unlikely!(!diagnostics.is_empty()) {
if unlikely!(!diagnostics.is_empty()) {
if dep_node.kind != crate::dep_graph::DepKind::Null {
self.queries.on_disk_cache
.store_diagnostics(dep_node_index, diagnostics);
}
Expand All @@ -589,15 +589,16 @@ impl<'tcx> TyCtxt<'tcx> {
///
/// Note: The optimization is only available during incr. comp.
pub(super) fn ensure_query<Q: QueryDescription<'tcx>>(self, key: Q::Key) -> () {
let dep_node = Q::to_dep_node(self, &key);

if dep_node.kind.is_eval_always() {
if Q::EVAL_ALWAYS {
let _ = self.get_query::<Q>(DUMMY_SP, key);
return;
}

// Ensuring an anonymous query makes no sense
assert!(!dep_node.kind.is_anon());
assert!(!Q::ANON);

let dep_node = Q::to_dep_node(self, &key);

if self.dep_graph.try_mark_green_and_read(self, &dep_node).is_none() {
// A None return from `try_mark_green_and_read` means that this is either
// a new dep node or that the dep node has already been marked red.
Expand Down Expand Up @@ -653,6 +654,30 @@ macro_rules! handle_cycle_error {
};
}

macro_rules! is_anon {
([]) => {{
false
}};
([anon$(, $modifiers:ident)*]) => {{
true
}};
([$other:ident$(, $modifiers:ident)*]) => {
is_anon!([$($modifiers),*])
};
}

macro_rules! is_eval_always {
([]) => {{
false
}};
([eval_always$(, $modifiers:ident)*]) => {{
true
}};
([$other:ident$(, $modifiers:ident)*]) => {
is_eval_always!([$($modifiers),*])
};
}

macro_rules! hash_result {
([][$hcx:expr, $result:expr]) => {{
dep_graph::hash_result($hcx, &$result)
Expand Down Expand Up @@ -933,6 +958,9 @@ macro_rules! define_queries_inner {
}

impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
const ANON: bool = is_anon!([$($modifiers)*]);
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);

#[inline(always)]
fn query(key: Self::Key) -> Query<'tcx> {
Query::$name(key)
Expand All @@ -951,6 +979,11 @@ macro_rules! define_queries_inner {
DepNode::new(tcx, $node(*key))
}

#[inline(always)]
fn dep_kind() -> dep_graph::DepKind {
dep_graph::DepKind::$node
}

#[inline]
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
__query_compute::$name(move || {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
return;
}
// Effectively no-ops
"uninit" | "forget" => {
"forget" => {
return;
}
"needs_drop" => {
Expand Down
Loading