Skip to content

Commit 8001b96

Browse files
committed
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
2 parents 52fa23a + f6fb931 commit 8001b96

File tree

22 files changed

+71
-27
lines changed

22 files changed

+71
-27
lines changed

src/liballoc/slice.rs

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ mod hack {
140140
use crate::string::ToString;
141141
use crate::vec::Vec;
142142

143+
// We shouldn't add inline attribute to this since this is used in
144+
// `vec!` macro mostly and causes perf regression. See #71204 for
145+
// discussion and perf results.
143146
pub fn into_vec<T>(b: Box<[T]>) -> Vec<T> {
144147
unsafe {
145148
let len = b.len();

src/librustc_ast/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub mod util {
3333
pub mod comments;
3434
pub mod lev_distance;
3535
pub mod literal;
36-
pub mod map_in_place;
3736
pub mod parser;
3837
}
3938

src/librustc_ast/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::ast::*;
1111
use crate::ptr::P;
1212
use crate::token::{self, Token};
1313
use crate::tokenstream::*;
14-
use crate::util::map_in_place::MapInPlace;
1514

15+
use rustc_data_structures::map_in_place::MapInPlace;
1616
use rustc_data_structures::sync::Lrc;
1717
use rustc_span::source_map::{respan, Spanned};
1818
use rustc_span::Span;

src/librustc_builtin_macros/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ use std::vec;
184184
use rustc_ast::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
185185
use rustc_ast::ast::{GenericArg, GenericParamKind, VariantData};
186186
use rustc_ast::ptr::P;
187-
use rustc_ast::util::map_in_place::MapInPlace;
188187
use rustc_attr as attr;
188+
use rustc_data_structures::map_in_place::MapInPlace;
189189
use rustc_expand::base::{Annotatable, ExtCtxt};
190190
use rustc_session::parse::ParseSess;
191191
use rustc_span::source_map::respan;

src/librustc_data_structures/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub mod fx;
6767
pub mod graph;
6868
pub mod jobserver;
6969
pub mod macros;
70+
pub mod map_in_place;
7071
pub mod obligation_forest;
7172
pub mod owning_ref;
7273
pub mod ptr_key;

src/librustc_ast/util/map_in_place.rs renamed to src/librustc_data_structures/map_in_place.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// FIXME(Centril): Move to rustc_data_structures.
2-
31
use smallvec::{Array, SmallVec};
42
use std::ptr;
53

src/librustc_expand/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use rustc_ast::ast::{self, AttrItem, Attribute, MetaItem};
44
use rustc_ast::attr::HasAttrs;
55
use rustc_ast::mut_visit::*;
66
use rustc_ast::ptr::P;
7-
use rustc_ast::util::map_in_place::MapInPlace;
87
use rustc_attr as attr;
98
use rustc_data_structures::fx::FxHashMap;
9+
use rustc_data_structures::map_in_place::MapInPlace;
1010
use rustc_errors::{error_code, struct_span_err, Applicability, Handler};
1111
use rustc_feature::{Feature, Features, State as FeatureState};
1212
use rustc_feature::{

src/librustc_expand/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use rustc_ast::mut_visit::*;
1313
use rustc_ast::ptr::P;
1414
use rustc_ast::token;
1515
use rustc_ast::tokenstream::TokenStream;
16-
use rustc_ast::util::map_in_place::MapInPlace;
1716
use rustc_ast::visit::{self, AssocCtxt, Visitor};
1817
use rustc_ast_pretty::pprust;
1918
use rustc_attr::{self as attr, is_builtin_attr, HasAttrs};
19+
use rustc_data_structures::map_in_place::MapInPlace;
2020
use rustc_errors::{Applicability, PResult};
2121
use rustc_feature::Features;
2222
use rustc_parse::parser::Parser;

src/librustc_metadata/creader.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ impl<'a> CrateLoader<'a> {
686686
}
687687

688688
fn inject_profiler_runtime(&mut self) {
689-
if self.sess.opts.debugging_opts.profile || self.sess.opts.cg.profile_generate.enabled() {
689+
if (self.sess.opts.debugging_opts.profile || self.sess.opts.cg.profile_generate.enabled())
690+
&& !self.sess.opts.debugging_opts.no_profiler_runtime
691+
{
690692
info!("loading profiler");
691693

692694
let name = Symbol::intern("profiler_builtins");

src/librustc_mir/borrow_check/diagnostics/region_name.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
148148
///
149149
/// This function would create a label like this:
150150
///
151-
/// ```
151+
/// ```text
152152
/// | fn foo(x: &u32) { .. }
153153
/// ------- fully elaborated type of `x` is `&'1 u32`
154154
/// ```
@@ -300,7 +300,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
300300
/// elaborated type, returning something like `'1`. Result looks
301301
/// like:
302302
///
303-
/// ```
303+
/// ```text
304304
/// | fn foo(x: &u32) { .. }
305305
/// ------- fully elaborated type of `x` is `&'1 u32`
306306
/// ```
@@ -347,7 +347,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
347347
/// that has no type annotation.
348348
/// For example, we might produce an annotation like this:
349349
///
350-
/// ```
350+
/// ```text
351351
/// | foo(|a, b| b)
352352
/// | - -
353353
/// | | |
@@ -396,7 +396,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
396396
/// that contains the anonymous reference we want to give a name
397397
/// to. For example, we might produce an annotation like this:
398398
///
399-
/// ```
399+
/// ```text
400400
/// | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item = &T>> {
401401
/// | - let's call the lifetime of this reference `'1`
402402
/// ```
@@ -600,7 +600,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
600600
/// fully elaborated type, returning something like `'1`. Result
601601
/// looks like:
602602
///
603-
/// ```
603+
/// ```text
604604
/// | let x = Some(&22);
605605
/// - fully elaborated type of `x` is `Option<&'1 u32>`
606606
/// ```

src/librustc_mir/transform/check_consts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313

1414
pub use self::qualifs::Qualif;
1515

16-
pub mod ops;
16+
mod ops;
1717
pub mod qualifs;
1818
mod resolver;
1919
pub mod validation;

src/librustc_mir/transform/check_consts/ops.rs

-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ impl NonConstOp for FnCallUnstable {
113113
#[derive(Debug)]
114114
pub struct HeapAllocation;
115115
impl NonConstOp for HeapAllocation {
116-
const IS_SUPPORTED_IN_MIRI: bool = false;
117-
118116
fn emit_error(&self, item: &Item<'_, '_>, span: Span) {
119117
let mut err = struct_span_err!(
120118
item.tcx.sess,

src/librustc_parse/parser/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,13 @@ impl<'a> Parser<'a> {
579579
/// Keep in mind that given that `outer_op.is_comparison()` holds and comparison ops are left
580580
/// associative we can infer that we have:
581581
///
582+
/// ```text
582583
/// outer_op
583584
/// / \
584585
/// inner_op r2
585586
/// / \
586587
/// l1 r1
588+
/// ```
587589
pub(super) fn check_no_chained_comparison(
588590
&mut self,
589591
inner_op: &Expr,

src/librustc_parse/parser/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_span::symbol::{kw, sym};
88
impl<'a> Parser<'a> {
99
/// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
1010
///
11-
/// ```
11+
/// ```text
1212
/// BOUND = LT_BOUND (e.g., `'a`)
1313
/// ```
1414
fn parse_lt_param_bounds(&mut self) -> GenericBounds {

src/librustc_parse/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ impl<'a> Parser<'a> {
743743

744744
/// Parses a `UseTree`.
745745
///
746-
/// ```
746+
/// ```text
747747
/// USE_TREE = [`::`] `*` |
748748
/// [`::`] `{` USE_TREE_LIST `}` |
749749
/// PATH `::` `*` |
@@ -792,7 +792,7 @@ impl<'a> Parser<'a> {
792792

793793
/// Parses a `UseTreeKind::Nested(list)`.
794794
///
795-
/// ```
795+
/// ```text
796796
/// USE_TREE_LIST = Ø | (USE_TREE `,`)* USE_TREE [`,`]
797797
/// ```
798798
fn parse_use_tree_list(&mut self) -> PResult<'a, Vec<(UseTree, ast::NodeId)>> {

src/librustc_resolve/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
10311031

10321032
/// Suggest a missing `self::` if that resolves to an correct module.
10331033
///
1034-
/// ```
1034+
/// ```text
10351035
/// |
10361036
/// LL | use foo::Bar;
10371037
/// | ^^^ did you mean `self::foo`?
@@ -1083,7 +1083,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
10831083

10841084
/// Suggests a missing `super::` if that resolves to an correct module.
10851085
///
1086-
/// ```
1086+
/// ```text
10871087
/// |
10881088
/// LL | use foo::Bar;
10891089
/// | ^^^ did you mean `super::foo`?
@@ -1103,7 +1103,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
11031103

11041104
/// Suggests a missing external crate name if that resolves to an correct module.
11051105
///
1106-
/// ```
1106+
/// ```text
11071107
/// |
11081108
/// LL | use foobar::Baz;
11091109
/// | ^^^^^^ did you mean `baz::foobar`?

src/librustc_session/config.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
16551655
let output_types = parse_output_types(&debugging_opts, matches, error_format);
16561656

16571657
let mut cg = build_codegen_options(matches, error_format);
1658-
let (disable_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto(
1658+
let (disable_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto(
16591659
&output_types,
16601660
matches,
16611661
error_format,
@@ -1672,6 +1672,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
16721672
"can't instrument with gcov profiling when compiling incrementally",
16731673
);
16741674
}
1675+
if debugging_opts.profile {
1676+
match codegen_units {
1677+
Some(1) => {}
1678+
None => codegen_units = Some(1),
1679+
Some(_) => early_error(
1680+
error_format,
1681+
"can't instrument with gcov profiling with multiple codegen units",
1682+
),
1683+
}
1684+
}
16751685

16761686
if cg.profile_generate.enabled() && cg.profile_use.is_some() {
16771687
early_error(

src/librustc_session/options.rs

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

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

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

src/librustc_typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12501250
/// This helper takes a *converted* parameter type (`param_ty`)
12511251
/// and an *unconverted* list of bounds:
12521252
///
1253-
/// ```
1253+
/// ```text
12541254
/// fn foo<T: Debug>
12551255
/// ^ ^^^^^ `ast_bounds` parameter, in HIR form
12561256
/// |
@@ -2992,7 +2992,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29922992
/// representations). These lists of bounds occur in many places in
29932993
/// Rust's syntax:
29942994
///
2995-
/// ```
2995+
/// ```text
29962996
/// trait Foo: Bar + Baz { }
29972997
/// ^^^^^^^^^ supertrait list bounding the `Self` type parameter
29982998
///
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zunleash-the-miri-inside-of-you
2+
#![feature(const_mut_refs, box_syntax)]
3+
#![deny(const_err)]
4+
5+
use std::mem::ManuallyDrop;
6+
7+
fn main() {}
8+
9+
static TEST_BAD: &mut i32 = {
10+
&mut *(box 0)
11+
//~^ WARN skipping const check
12+
//~| ERROR could not evaluate static initializer
13+
//~| NOTE heap allocations
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
warning: skipping const checks
2+
--> $DIR/box.rs:10:11
3+
|
4+
LL | &mut *(box 0)
5+
| ^^^^^^^
6+
7+
error[E0080]: could not evaluate static initializer
8+
--> $DIR/box.rs:10:11
9+
|
10+
LL | &mut *(box 0)
11+
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
12+
13+
error: aborting due to previous error; 1 warning emitted
14+
15+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)