Skip to content

Commit b613c98

Browse files
committed
Auto merge of rust-lang#71549 - Dylan-DPC:rollup-j6jlp9l, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#71364 (Ignore -Zprofile when building compiler_builtins) - rust-lang#71494 (Fix span of while (let) expressions after lowering) - rust-lang#71517 ( Quick and dirty fix of the unused_braces lint) - rust-lang#71523 (Take a single root node in range_search) - rust-lang#71533 (Revert PR 70566 for const validation fix) Failed merges: r? @ghost
2 parents a58b1ed + 4b5b6cb commit b613c98

File tree

13 files changed

+176
-164
lines changed

13 files changed

+176
-164
lines changed

src/liballoc/collections/btree/map.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
10341034
R: RangeBounds<T>,
10351035
{
10361036
if let Some(root) = &self.root {
1037-
let root1 = root.as_ref();
1038-
let root2 = root.as_ref();
1039-
let (f, b) = range_search(root1, root2, range);
1037+
let (f, b) = range_search(root.as_ref(), range);
10401038

10411039
Range { front: Some(f), back: Some(b) }
10421040
} else {
@@ -1082,9 +1080,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
10821080
R: RangeBounds<T>,
10831081
{
10841082
if let Some(root) = &mut self.root {
1085-
let root1 = root.as_mut();
1086-
let root2 = unsafe { ptr::read(&root1) };
1087-
let (f, b) = range_search(root1, root2, range);
1083+
let (f, b) = range_search(root.as_mut(), range);
10881084

10891085
RangeMut { front: Some(f), back: Some(b), _marker: PhantomData }
10901086
} else {
@@ -2043,8 +2039,7 @@ where
20432039
}
20442040

20452041
fn range_search<BorrowType, K, V, Q: ?Sized, R: RangeBounds<Q>>(
2046-
root1: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
2047-
root2: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
2042+
root: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
20482043
range: R,
20492044
) -> (
20502045
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge>,
@@ -2064,8 +2059,10 @@ where
20642059
_ => {}
20652060
};
20662061

2067-
let mut min_node = root1;
2068-
let mut max_node = root2;
2062+
// We duplicate the root NodeRef here -- we will never access it in a way
2063+
// that overlaps references obtained from the root.
2064+
let mut min_node = unsafe { ptr::read(&root) };
2065+
let mut max_node = root;
20692066
let mut min_found = false;
20702067
let mut max_found = false;
20712068

src/librustc_ast_lowering/expr.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
397397
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));
398398

399399
// `match <scrutinee> { ... }`
400-
let match_expr = self.expr_match(
401-
scrutinee.span,
402-
scrutinee,
403-
arena_vec![self; then_arm, else_arm],
404-
desugar,
405-
);
400+
let match_expr =
401+
self.expr_match(span, scrutinee, arena_vec![self; then_arm, else_arm], desugar);
406402

407403
// `[opt_ident]: loop { ... }`
408404
hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source)

src/librustc_codegen_ssa/back/write.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ pub struct ModuleConfig {
119119
}
120120

121121
impl ModuleConfig {
122-
fn new(kind: ModuleKind, sess: &Session, no_builtins: bool) -> ModuleConfig {
122+
fn new(
123+
kind: ModuleKind,
124+
sess: &Session,
125+
no_builtins: bool,
126+
is_compiler_builtins: bool,
127+
) -> ModuleConfig {
123128
// If it's a regular module, use `$regular`, otherwise use `$other`.
124129
// `$regular` and `$other` are evaluated lazily.
125130
macro_rules! if_regular {
@@ -160,7 +165,10 @@ impl ModuleConfig {
160165
passes: if_regular!(
161166
{
162167
let mut passes = sess.opts.cg.passes.clone();
163-
if sess.opts.debugging_opts.profile {
168+
// compiler_builtins overrides the codegen-units settings,
169+
// which is incompatible with -Zprofile which requires that
170+
// only a single codegen unit is used per crate.
171+
if sess.opts.debugging_opts.profile && !is_compiler_builtins {
164172
passes.push("insert-gcov-profiling".to_owned());
165173
}
166174
passes
@@ -406,6 +414,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
406414
let crate_name = tcx.crate_name(LOCAL_CRATE);
407415
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
408416
let no_builtins = attr::contains_name(&tcx.hir().krate().item.attrs, sym::no_builtins);
417+
let is_compiler_builtins =
418+
attr::contains_name(&tcx.hir().krate().item.attrs, sym::compiler_builtins);
409419
let subsystem =
410420
attr::first_attr_value_str_by_name(&tcx.hir().krate().item.attrs, sym::windows_subsystem);
411421
let windows_subsystem = subsystem.map(|subsystem| {
@@ -422,9 +432,12 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
422432
let linker_info = LinkerInfo::new(tcx);
423433
let crate_info = CrateInfo::new(tcx);
424434

425-
let regular_config = ModuleConfig::new(ModuleKind::Regular, sess, no_builtins);
426-
let metadata_config = ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins);
427-
let allocator_config = ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins);
435+
let regular_config =
436+
ModuleConfig::new(ModuleKind::Regular, sess, no_builtins, is_compiler_builtins);
437+
let metadata_config =
438+
ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins, is_compiler_builtins);
439+
let allocator_config =
440+
ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins, is_compiler_builtins);
428441

429442
let (shared_emitter, shared_emitter_main) = SharedEmitter::new();
430443
let (codegen_worker_send, codegen_worker_receive) = channel();

src/librustc_lint/unused.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::ty::{self, Ty};
1616
use rustc_session::lint::builtin::UNUSED_ATTRIBUTES;
1717
use rustc_span::symbol::Symbol;
1818
use rustc_span::symbol::{kw, sym};
19-
use rustc_span::{BytePos, Span};
19+
use rustc_span::{BytePos, Span, DUMMY_SP};
2020

2121
use log::debug;
2222

@@ -415,6 +415,12 @@ trait UnusedDelimLint {
415415
msg: &str,
416416
keep_space: (bool, bool),
417417
) {
418+
// FIXME(flip1995): Quick and dirty fix for #70814. This should be fixed in rustdoc
419+
// properly.
420+
if span == DUMMY_SP {
421+
return;
422+
}
423+
418424
cx.struct_span_lint(self.lint(), span, |lint| {
419425
let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg);
420426
let mut err = lint.build(&span_msg);

src/librustc_mir/transform/const_prop.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
596596
return None;
597597
}
598598

599+
// FIXME we need to revisit this for #67176
600+
if rvalue.needs_subst() {
601+
return None;
602+
}
603+
599604
// Perform any special handling for specific Rvalue types.
600605
// Generally, checks here fall into one of two categories:
601606
// 1. Additional checking to provide useful lints to the user
@@ -636,11 +641,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
636641
_ => {}
637642
}
638643

639-
// FIXME we need to revisit this for #67176
640-
if rvalue.needs_subst() {
641-
return None;
642-
}
643-
644644
self.use_ecx(|this| {
645645
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
646646
this.ecx.eval_rvalue_into_place(rvalue, place)?;

src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn while_loop(_1: bool) -> () {
5757

5858
bb5: {
5959
StorageDead(_4); // bb5[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
60-
StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
60+
StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
6161
goto -> bb0; // bb5[2]: scope 0 at $DIR/while-storage.rs:10:5: 14:6
6262
}
6363

@@ -74,7 +74,7 @@ fn while_loop(_1: bool) -> () {
7474
}
7575

7676
bb7: {
77-
StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
77+
StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
7878
return; // bb7[1]: scope 0 at $DIR/while-storage.rs:15:2: 15:2
7979
}
8080
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
// This tests the bug in #70814, where the unused_braces lint triggered on the following code
4+
// without providing a span.
5+
6+
#![deny(unused_braces)]
7+
8+
fn main() {
9+
{
10+
{
11+
use std;
12+
}
13+
}
14+
}

src/test/ui/block-result/block-must-not-have-result-while.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ LL | while true {
99
error[E0308]: mismatched types
1010
--> $DIR/block-must-not-have-result-while.rs:3:9
1111
|
12-
LL | true
13-
| ^^^^ expected `()`, found `bool`
12+
LL | / while true {
13+
LL | | true
14+
| | ^^^^ expected `()`, found `bool`
15+
LL | |
16+
LL | | }
17+
| | -- help: consider using a semicolon here
18+
| |_____|
19+
| expected this to be `()`
1420

1521
error: aborting due to previous error; 1 warning emitted
1622

src/test/ui/consts/const-eval/ice-generic-assoc-const.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// check-pass
1+
// build-pass (tests post-monomorphisation failure)
2+
#![crate_type = "lib"]
23

34
pub trait Nullable {
45
const NULL: Self;
@@ -13,6 +14,3 @@ impl<T> Nullable for *const T {
1314
*self == Self::NULL
1415
}
1516
}
16-
17-
fn main() {
18-
}

0 commit comments

Comments
 (0)