Auto merge of #71306 - Dylan-DPC:rollup-kvzc1da, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71271 (Move `MapInPlace` to rustc_data_structures)
 - #71276 (miri-unleashed: test that we detect heap allocations)
 - #71283 (Minor improvements to -Zprofile)
 - #71287 (Explain why we shouldn't add inline attr to into_vec)
 - #71303 (remove build warnings)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-04-18 23:06:08 +00:00
commit 8001b96f48
22 changed files with 71 additions and 27 deletions

View File

@ -140,6 +140,9 @@ mod hack {
use crate::string::ToString; use crate::string::ToString;
use crate::vec::Vec; use crate::vec::Vec;
// We shouldn't add inline attribute to this since this is used in
// `vec!` macro mostly and causes perf regression. See #71204 for
// discussion and perf results.
pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> { pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
unsafe { unsafe {
let len = b.len(); let len = b.len();

View File

@ -33,7 +33,6 @@ pub mod util {
pub mod comments; pub mod comments;
pub mod lev_distance; pub mod lev_distance;
pub mod literal; pub mod literal;
pub mod map_in_place;
pub mod parser; pub mod parser;
} }

View File

@ -11,8 +11,8 @@ use crate::ast::*;
use crate::ptr::P; use crate::ptr::P;
use crate::token::{self, Token}; use crate::token::{self, Token};
use crate::tokenstream::*; use crate::tokenstream::*;
use crate::util::map_in_place::MapInPlace;
use rustc_data_structures::map_in_place::MapInPlace;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_span::source_map::{respan, Spanned}; use rustc_span::source_map::{respan, Spanned};
use rustc_span::Span; use rustc_span::Span;

View File

@ -184,8 +184,8 @@ use std::vec;
use rustc_ast::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; use rustc_ast::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
use rustc_ast::ast::{GenericArg, GenericParamKind, VariantData}; use rustc_ast::ast::{GenericArg, GenericParamKind, VariantData};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::util::map_in_place::MapInPlace;
use rustc_attr as attr; use rustc_attr as attr;
use rustc_data_structures::map_in_place::MapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
use rustc_span::source_map::respan; use rustc_span::source_map::respan;

View File

@ -67,6 +67,7 @@ pub mod fx;
pub mod graph; pub mod graph;
pub mod jobserver; pub mod jobserver;
pub mod macros; pub mod macros;
pub mod map_in_place;
pub mod obligation_forest; pub mod obligation_forest;
pub mod owning_ref; pub mod owning_ref;
pub mod ptr_key; pub mod ptr_key;

View File

@ -1,5 +1,3 @@
// FIXME(Centril): Move to rustc_data_structures.
use smallvec::{Array, SmallVec}; use smallvec::{Array, SmallVec};
use std::ptr; use std::ptr;

View File

@ -4,9 +4,9 @@ use rustc_ast::ast::{self, AttrItem, Attribute, MetaItem};
use rustc_ast::attr::HasAttrs; use rustc_ast::attr::HasAttrs;
use rustc_ast::mut_visit::*; use rustc_ast::mut_visit::*;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::util::map_in_place::MapInPlace;
use rustc_attr as attr; use rustc_attr as attr;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::map_in_place::MapInPlace;
use rustc_errors::{error_code, struct_span_err, Applicability, Handler}; use rustc_errors::{error_code, struct_span_err, Applicability, Handler};
use rustc_feature::{Feature, Features, State as FeatureState}; use rustc_feature::{Feature, Features, State as FeatureState};
use rustc_feature::{ use rustc_feature::{

View File

@ -13,10 +13,10 @@ use rustc_ast::mut_visit::*;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token; use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream; use rustc_ast::tokenstream::TokenStream;
use rustc_ast::util::map_in_place::MapInPlace;
use rustc_ast::visit::{self, AssocCtxt, Visitor}; use rustc_ast::visit::{self, AssocCtxt, Visitor};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, is_builtin_attr, HasAttrs}; use rustc_attr::{self as attr, is_builtin_attr, HasAttrs};
use rustc_data_structures::map_in_place::MapInPlace;
use rustc_errors::{Applicability, PResult}; use rustc_errors::{Applicability, PResult};
use rustc_feature::Features; use rustc_feature::Features;
use rustc_parse::parser::Parser; use rustc_parse::parser::Parser;

View File

@ -686,7 +686,9 @@ impl<'a> CrateLoader<'a> {
} }
fn inject_profiler_runtime(&mut self) { fn inject_profiler_runtime(&mut self) {
if self.sess.opts.debugging_opts.profile || self.sess.opts.cg.profile_generate.enabled() { if (self.sess.opts.debugging_opts.profile || self.sess.opts.cg.profile_generate.enabled())
&& !self.sess.opts.debugging_opts.no_profiler_runtime
{
info!("loading profiler"); info!("loading profiler");
let name = Symbol::intern("profiler_builtins"); let name = Symbol::intern("profiler_builtins");

View File

@ -148,7 +148,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// ///
/// This function would create a label like this: /// This function would create a label like this:
/// ///
/// ``` /// ```text
/// | fn foo(x: &u32) { .. } /// | fn foo(x: &u32) { .. }
/// ------- fully elaborated type of `x` is `&'1 u32` /// ------- fully elaborated type of `x` is `&'1 u32`
/// ``` /// ```
@ -300,7 +300,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// elaborated type, returning something like `'1`. Result looks /// elaborated type, returning something like `'1`. Result looks
/// like: /// like:
/// ///
/// ``` /// ```text
/// | fn foo(x: &u32) { .. } /// | fn foo(x: &u32) { .. }
/// ------- fully elaborated type of `x` is `&'1 u32` /// ------- fully elaborated type of `x` is `&'1 u32`
/// ``` /// ```
@ -347,7 +347,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// that has no type annotation. /// that has no type annotation.
/// For example, we might produce an annotation like this: /// For example, we might produce an annotation like this:
/// ///
/// ``` /// ```text
/// | foo(|a, b| b) /// | foo(|a, b| b)
/// | - - /// | - -
/// | | | /// | | |
@ -396,7 +396,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// that contains the anonymous reference we want to give a name /// that contains the anonymous reference we want to give a name
/// to. For example, we might produce an annotation like this: /// to. For example, we might produce an annotation like this:
/// ///
/// ``` /// ```text
/// | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item = &T>> { /// | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item = &T>> {
/// | - let's call the lifetime of this reference `'1` /// | - let's call the lifetime of this reference `'1`
/// ``` /// ```
@ -600,7 +600,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
/// fully elaborated type, returning something like `'1`. Result /// fully elaborated type, returning something like `'1`. Result
/// looks like: /// looks like:
/// ///
/// ``` /// ```text
/// | let x = Some(&22); /// | let x = Some(&22);
/// - fully elaborated type of `x` is `Option<&'1 u32>` /// - fully elaborated type of `x` is `Option<&'1 u32>`
/// ``` /// ```

View File

@ -13,7 +13,7 @@ use std::fmt;
pub use self::qualifs::Qualif; pub use self::qualifs::Qualif;
pub mod ops; mod ops;
pub mod qualifs; pub mod qualifs;
mod resolver; mod resolver;
pub mod validation; pub mod validation;

View File

@ -113,8 +113,6 @@ impl NonConstOp for FnCallUnstable {
#[derive(Debug)] #[derive(Debug)]
pub struct HeapAllocation; pub struct HeapAllocation;
impl NonConstOp for HeapAllocation { impl NonConstOp for HeapAllocation {
const IS_SUPPORTED_IN_MIRI: bool = false;
fn emit_error(&self, item: &Item<'_, '_>, span: Span) { fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
let mut err = struct_span_err!( let mut err = struct_span_err!(
item.tcx.sess, item.tcx.sess,

View File

@ -579,11 +579,13 @@ impl<'a> Parser<'a> {
/// Keep in mind that given that `outer_op.is_comparison()` holds and comparison ops are left /// Keep in mind that given that `outer_op.is_comparison()` holds and comparison ops are left
/// associative we can infer that we have: /// associative we can infer that we have:
/// ///
/// ```text
/// outer_op /// outer_op
/// / \ /// / \
/// inner_op r2 /// inner_op r2
/// / \ /// / \
/// l1 r1 /// l1 r1
/// ```
pub(super) fn check_no_chained_comparison( pub(super) fn check_no_chained_comparison(
&mut self, &mut self,
inner_op: &Expr, inner_op: &Expr,

View File

@ -8,7 +8,7 @@ use rustc_span::symbol::{kw, sym};
impl<'a> Parser<'a> { impl<'a> Parser<'a> {
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. /// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
/// ///
/// ``` /// ```text
/// BOUND = LT_BOUND (e.g., `'a`) /// BOUND = LT_BOUND (e.g., `'a`)
/// ``` /// ```
fn parse_lt_param_bounds(&mut self) -> GenericBounds { fn parse_lt_param_bounds(&mut self) -> GenericBounds {

View File

@ -743,7 +743,7 @@ impl<'a> Parser<'a> {
/// Parses a `UseTree`. /// Parses a `UseTree`.
/// ///
/// ``` /// ```text
/// USE_TREE = [`::`] `*` | /// USE_TREE = [`::`] `*` |
/// [`::`] `{` USE_TREE_LIST `}` | /// [`::`] `{` USE_TREE_LIST `}` |
/// PATH `::` `*` | /// PATH `::` `*` |
@ -792,7 +792,7 @@ impl<'a> Parser<'a> {
/// Parses a `UseTreeKind::Nested(list)`. /// Parses a `UseTreeKind::Nested(list)`.
/// ///
/// ``` /// ```text
/// USE_TREE_LIST = Ø | (USE_TREE `,`)* USE_TREE [`,`] /// USE_TREE_LIST = Ø | (USE_TREE `,`)* USE_TREE [`,`]
/// ``` /// ```
fn parse_use_tree_list(&mut self) -> PResult<'a, Vec<(UseTree, ast::NodeId)>> { fn parse_use_tree_list(&mut self) -> PResult<'a, Vec<(UseTree, ast::NodeId)>> {

View File

@ -1031,7 +1031,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// Suggest a missing `self::` if that resolves to an correct module. /// Suggest a missing `self::` if that resolves to an correct module.
/// ///
/// ``` /// ```text
/// | /// |
/// LL | use foo::Bar; /// LL | use foo::Bar;
/// | ^^^ did you mean `self::foo`? /// | ^^^ did you mean `self::foo`?
@ -1083,7 +1083,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// Suggests a missing `super::` if that resolves to an correct module. /// Suggests a missing `super::` if that resolves to an correct module.
/// ///
/// ``` /// ```text
/// | /// |
/// LL | use foo::Bar; /// LL | use foo::Bar;
/// | ^^^ did you mean `super::foo`? /// | ^^^ did you mean `super::foo`?
@ -1103,7 +1103,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// Suggests a missing external crate name if that resolves to an correct module. /// Suggests a missing external crate name if that resolves to an correct module.
/// ///
/// ``` /// ```text
/// | /// |
/// LL | use foobar::Baz; /// LL | use foobar::Baz;
/// | ^^^^^^ did you mean `baz::foobar`? /// | ^^^^^^ did you mean `baz::foobar`?

View File

@ -1655,7 +1655,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let output_types = parse_output_types(&debugging_opts, matches, error_format); let output_types = parse_output_types(&debugging_opts, matches, error_format);
let mut cg = build_codegen_options(matches, error_format); let mut cg = build_codegen_options(matches, error_format);
let (disable_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto( let (disable_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto(
&output_types, &output_types,
matches, matches,
error_format, error_format,
@ -1672,6 +1672,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
"can't instrument with gcov profiling when compiling incrementally", "can't instrument with gcov profiling when compiling incrementally",
); );
} }
if debugging_opts.profile {
match codegen_units {
Some(1) => {}
None => codegen_units = Some(1),
Some(_) => early_error(
error_format,
"can't instrument with gcov profiling with multiple codegen units",
),
}
}
if cg.profile_generate.enabled() && cg.profile_use.is_some() { if cg.profile_generate.enabled() && cg.profile_use.is_some() {
early_error( early_error(

View File

@ -890,6 +890,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"extra arguments to prepend to the linker invocation (space separated)"), "extra arguments to prepend to the linker invocation (space separated)"),
profile: bool = (false, parse_bool, [TRACKED], profile: bool = (false, parse_bool, [TRACKED],
"insert profiling code"), "insert profiling code"),
no_profiler_runtime: bool = (false, parse_bool, [TRACKED],
"don't automatically inject the profiler_builtins crate"),
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED], relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
"choose which RELRO level to use"), "choose which RELRO level to use"),
nll_facts: bool = (false, parse_bool, [UNTRACKED], nll_facts: bool = (false, parse_bool, [UNTRACKED],

View File

@ -1045,7 +1045,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
/// Adds an async-await specific note to the diagnostic when the future does not implement /// Adds an async-await specific note to the diagnostic when the future does not implement
/// an auto trait because of a captured type. /// an auto trait because of a captured type.
/// ///
/// ```ignore (diagnostic) /// ```text
/// note: future does not implement `Qux` as this value is used across an await /// note: future does not implement `Qux` as this value is used across an await
/// --> $DIR/issue-64130-3-other.rs:17:5 /// --> $DIR/issue-64130-3-other.rs:17:5
/// | /// |
@ -1060,7 +1060,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
/// When the diagnostic does not implement `Send` or `Sync` specifically, then the diagnostic /// When the diagnostic does not implement `Send` or `Sync` specifically, then the diagnostic
/// is "replaced" with a different message and a more specific error. /// is "replaced" with a different message and a more specific error.
/// ///
/// ```ignore (diagnostic) /// ```text
/// error: future cannot be sent between threads safely /// error: future cannot be sent between threads safely
/// --> $DIR/issue-64130-2-send.rs:21:5 /// --> $DIR/issue-64130-2-send.rs:21:5
/// | /// |

View File

@ -1250,7 +1250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
/// This helper takes a *converted* parameter type (`param_ty`) /// This helper takes a *converted* parameter type (`param_ty`)
/// and an *unconverted* list of bounds: /// and an *unconverted* list of bounds:
/// ///
/// ``` /// ```text
/// fn foo<T: Debug> /// fn foo<T: Debug>
/// ^ ^^^^^ `ast_bounds` parameter, in HIR form /// ^ ^^^^^ `ast_bounds` parameter, in HIR form
/// | /// |
@ -2992,7 +2992,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
/// representations). These lists of bounds occur in many places in /// representations). These lists of bounds occur in many places in
/// Rust's syntax: /// Rust's syntax:
/// ///
/// ``` /// ```text
/// trait Foo: Bar + Baz { } /// trait Foo: Bar + Baz { }
/// ^^^^^^^^^ supertrait list bounding the `Self` type parameter /// ^^^^^^^^^ supertrait list bounding the `Self` type parameter
/// ///

View File

@ -0,0 +1,14 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(const_mut_refs, box_syntax)]
#![deny(const_err)]
use std::mem::ManuallyDrop;
fn main() {}
static TEST_BAD: &mut i32 = {
&mut *(box 0)
//~^ WARN skipping const check
//~| ERROR could not evaluate static initializer
//~| NOTE heap allocations
};

View File

@ -0,0 +1,15 @@
warning: skipping const checks
--> $DIR/box.rs:10:11
|
LL | &mut *(box 0)
| ^^^^^^^
error[E0080]: could not evaluate static initializer
--> $DIR/box.rs:10:11
|
LL | &mut *(box 0)
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.