Skip to content

Commit 69e2f23

Browse files
committed
Auto merge of rust-lang#86080 - GuillaumeGomez:rollup-vb5g14e, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#83433 (Pass --cfg=bootstrap for proc macros built by stage0) - rust-lang#84940 (Don't run sanity checks for `x.py setup`) - rust-lang#85912 (Use `Iterator::any` and `filter_map` instead of open-coding them) - rust-lang#85965 (Remove dead code from `LocalAnalyzer`) - rust-lang#86010 (Fix two ICEs in the parser) - rust-lang#86040 (Fix display for search results) - rust-lang#86058 (Remove `_` from E0121 diagnostic suggestions) - rust-lang#86077 (Fix corrected example in E0759.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 35fff69 + 487200b commit 69e2f23

24 files changed

+232
-121
lines changed

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+4-46
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use rustc_data_structures::graph::dominators::Dominators;
77
use rustc_index::bit_set::BitSet;
88
use rustc_index::vec::{Idx, IndexVec};
99
use rustc_middle::mir::traversal;
10-
use rustc_middle::mir::visit::{
11-
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext, Visitor,
12-
};
10+
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
1311
use rustc_middle::mir::{self, Location, TerminatorKind};
1412
use rustc_middle::ty::layout::HasTyCtxt;
1513
use rustc_target::abi::LayoutOf;
@@ -20,7 +18,9 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2018
let mir = fx.mir;
2119
let mut analyzer = LocalAnalyzer::new(fx);
2220

23-
analyzer.visit_body(&mir);
21+
for (bb, data) in mir.basic_blocks().iter_enumerated() {
22+
analyzer.visit_basic_block_data(bb, data);
23+
}
2424

2525
for (local, decl) in mir.local_decls.iter_enumerated() {
2626
let ty = fx.monomorphize(decl.ty);
@@ -141,36 +141,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
141141

142142
if let mir::ProjectionElem::Deref = elem {
143143
// Deref projections typically only read the pointer.
144-
// (the exception being `VarDebugInfo` contexts, handled below)
145144
base_context = PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy);
146-
147-
// Indirect debuginfo requires going through memory, that only
148-
// the debugger accesses, following our emitted DWARF pointer ops.
149-
//
150-
// FIXME(eddyb) Investigate the possibility of relaxing this, but
151-
// note that `llvm.dbg.declare` *must* be used for indirect places,
152-
// even if we start using `llvm.dbg.value` for all other cases,
153-
// as we don't necessarily know when the value changes, but only
154-
// where it lives in memory.
155-
//
156-
// It's possible `llvm.dbg.declare` could support starting from
157-
// a pointer that doesn't point to an `alloca`, but this would
158-
// only be useful if we know the pointer being `Deref`'d comes
159-
// from an immutable place, and if `llvm.dbg.declare` calls
160-
// must be at the very start of the function, then only function
161-
// arguments could contain such pointers.
162-
if context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) {
163-
// We use `NonUseContext::VarDebugInfo` for the base,
164-
// which might not force the base local to memory,
165-
// so we have to do it manually.
166-
self.visit_local(&place_ref.local, context, location);
167-
}
168-
}
169-
170-
// `NonUseContext::VarDebugInfo` needs to flow all the
171-
// way down to the base local (see `visit_local`).
172-
if context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) {
173-
base_context = context;
174145
}
175146

176147
self.process_place(&place_base, base_context, location);
@@ -185,20 +156,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
185156
);
186157
}
187158
} else {
188-
// FIXME this is super_place code, is repeated here to avoid cloning place or changing
189-
// visit_place API
190-
let mut context = context;
191-
192-
if !place_ref.projection.is_empty() {
193-
context = if context.is_mutating_use() {
194-
PlaceContext::MutatingUse(MutatingUseContext::Projection)
195-
} else {
196-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
197-
};
198-
}
199-
200159
self.visit_local(&place_ref.local, context, location);
201-
self.visit_projection(*place_ref, context, location);
202160
}
203161
}
204162
}

compiler/rustc_error_codes/src/error_codes/E0759.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ fn bar(x: &i32) -> Box<dyn Debug> { // error!
1616

1717
Add `'static` requirement to fix them:
1818

19-
```compile_fail,E0759
19+
```
2020
# use std::fmt::Debug;
21-
fn foo(x: &i32) -> impl Debug + 'static { // ok!
21+
fn foo(x: &'static i32) -> impl Debug + 'static { // ok!
2222
x
2323
}
2424
25-
fn bar(x: &i32) -> Box<dyn Debug + 'static> { // ok!
25+
fn bar(x: &'static i32) -> Box<dyn Debug + 'static> { // ok!
2626
Box::new(x)
2727
}
2828
```

compiler/rustc_lint/src/types.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -711,15 +711,10 @@ fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKi
711711
return false;
712712
}
713713

714-
for variant in &def.variants {
715-
if let Some(field) = transparent_newtype_field(cx.tcx, variant) {
716-
if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) {
717-
return true;
718-
}
719-
}
720-
}
721-
722-
false
714+
def.variants
715+
.iter()
716+
.filter_map(|variant| transparent_newtype_field(cx.tcx, variant))
717+
.any(|field| ty_is_known_nonnull(cx, field.ty(tcx, substs), mode))
723718
}
724719
_ => false,
725720
}

compiler/rustc_parse/src/parser/path.rs

+47-37
Original file line numberDiff line numberDiff line change
@@ -352,49 +352,59 @@ impl<'a> Parser<'a> {
352352
debug!("parse_generic_args_with_leading_angle_bracket_recovery: (snapshotting)");
353353
match self.parse_angle_args() {
354354
Ok(args) => Ok(args),
355-
Err(ref mut e) if is_first_invocation && self.unmatched_angle_bracket_count > 0 => {
356-
// Cancel error from being unable to find `>`. We know the error
357-
// must have been this due to a non-zero unmatched angle bracket
358-
// count.
359-
e.cancel();
360-
355+
Err(mut e) if is_first_invocation && self.unmatched_angle_bracket_count > 0 => {
361356
// Swap `self` with our backup of the parser state before attempting to parse
362357
// generic arguments.
363358
let snapshot = mem::replace(self, snapshot.unwrap());
364359

365-
debug!(
366-
"parse_generic_args_with_leading_angle_bracket_recovery: (snapshot failure) \
367-
snapshot.count={:?}",
368-
snapshot.unmatched_angle_bracket_count,
369-
);
370-
371360
// Eat the unmatched angle brackets.
372-
for _ in 0..snapshot.unmatched_angle_bracket_count {
373-
self.eat_lt();
374-
}
375-
376-
// Make a span over ${unmatched angle bracket count} characters.
377-
let span = lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
378-
self.struct_span_err(
379-
span,
380-
&format!(
381-
"unmatched angle bracket{}",
382-
pluralize!(snapshot.unmatched_angle_bracket_count)
383-
),
384-
)
385-
.span_suggestion(
386-
span,
387-
&format!(
388-
"remove extra angle bracket{}",
389-
pluralize!(snapshot.unmatched_angle_bracket_count)
390-
),
391-
String::new(),
392-
Applicability::MachineApplicable,
393-
)
394-
.emit();
361+
let all_angle_brackets = (0..snapshot.unmatched_angle_bracket_count)
362+
.fold(true, |a, _| a && self.eat_lt());
363+
364+
if !all_angle_brackets {
365+
// If there are other tokens in between the extraneous `<`s, we cannot simply
366+
// suggest to remove them. This check also prevents us from accidentally ending
367+
// up in the middle of a multibyte character (issue #84104).
368+
let _ = mem::replace(self, snapshot);
369+
Err(e)
370+
} else {
371+
// Cancel error from being unable to find `>`. We know the error
372+
// must have been this due to a non-zero unmatched angle bracket
373+
// count.
374+
e.cancel();
375+
376+
debug!(
377+
"parse_generic_args_with_leading_angle_bracket_recovery: (snapshot failure) \
378+
snapshot.count={:?}",
379+
snapshot.unmatched_angle_bracket_count,
380+
);
381+
382+
// Make a span over ${unmatched angle bracket count} characters.
383+
// This is safe because `all_angle_brackets` ensures that there are only `<`s,
384+
// i.e. no multibyte characters, in this range.
385+
let span =
386+
lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
387+
self.struct_span_err(
388+
span,
389+
&format!(
390+
"unmatched angle bracket{}",
391+
pluralize!(snapshot.unmatched_angle_bracket_count)
392+
),
393+
)
394+
.span_suggestion(
395+
span,
396+
&format!(
397+
"remove extra angle bracket{}",
398+
pluralize!(snapshot.unmatched_angle_bracket_count)
399+
),
400+
String::new(),
401+
Applicability::MachineApplicable,
402+
)
403+
.emit();
395404

396-
// Try again without unmatched angle bracket characters.
397-
self.parse_angle_args()
405+
// Try again without unmatched angle bracket characters.
406+
self.parse_angle_args()
407+
}
398408
}
399409
Err(e) => Err(e),
400410
}

compiler/rustc_parse/src/parser/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ impl<'a> Parser<'a> {
334334
mut bounds: GenericBounds,
335335
plus: bool,
336336
) -> PResult<'a, TyKind> {
337-
assert_ne!(self.token, token::Question);
338337
if plus {
339338
self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded
340339
bounds.append(&mut self.parse_generic_bounds(Some(self.prev_token.span))?);

compiler/rustc_typeck/src/collect/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ fn infer_placeholder_type(
766766
if !ty.references_error() {
767767
diag.span_suggestion(
768768
span,
769-
"replace `_` with the correct type",
769+
"replace with the correct type",
770770
ty.to_string(),
771771
Applicability::MaybeIncorrect,
772772
);

src/bootstrap/bin/rustc.rs

+7
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ fn main() {
124124
cmd.arg("-C").arg("target-feature=-crt-static");
125125
}
126126
}
127+
128+
if stage == "0" {
129+
// Cargo doesn't pass RUSTFLAGS to proc_macros:
130+
// https://github.com/rust-lang/cargo/issues/4423
131+
// Set `--cfg=bootstrap` explicitly instead.
132+
cmd.arg("--cfg=bootstrap");
133+
}
127134
}
128135

129136
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {

src/bootstrap/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,13 @@ impl Build {
444444

445445
build.verbose("finding compilers");
446446
cc_detect::find(&mut build);
447-
build.verbose("running sanity check");
448-
sanity::check(&mut build);
447+
// When running `setup`, the profile is about to change, so any requirements we have now may
448+
// be different on the next invocation. Don't check for them until the next time x.py is
449+
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
450+
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
451+
build.verbose("running sanity check");
452+
sanity::check(&mut build);
453+
}
449454

450455
// If local-rust is the same major.minor as the current version, then force a
451456
// local-rebuild

src/librustdoc/html/static/rustdoc.css

+2
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@ a {
800800

801801
.search-results .result-name > span {
802802
display: inline-block;
803+
margin: 0;
804+
font-weight: normal;
803805
}
804806

805807
body.blur > :not(#help) {

src/test/ui/error-codes/E0121.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | static BAR: _ = "test";
1414
| ^
1515
| |
1616
| not allowed in type signatures
17-
| help: replace `_` with the correct type: `&str`
17+
| help: replace with the correct type: `&str`
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LL | const A = "A".$fn();
3737
| ^
3838
| |
3939
| not allowed in type signatures
40-
| help: replace `_` with the correct type: `bool`
40+
| help: replace with the correct type: `bool`
4141
...
4242
LL | / suite! {
4343
LL | | len;

src/test/ui/parser/issue-84104.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// error-pattern: this file contains an unclosed delimiter
2+
// error-pattern: expected one of
3+
#[i=i::<ښܖ<

src/test/ui/parser/issue-84104.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: this file contains an unclosed delimiter
2+
--> $DIR/issue-84104.rs:3:13
3+
|
4+
LL | #[i=i::<ښܖ<
5+
| - ^
6+
| |
7+
| unclosed delimiter
8+
9+
error: expected one of `>`, a const expression, lifetime, or type, found `]`
10+
--> $DIR/issue-84104.rs:3:13
11+
|
12+
LL | #[i=i::<ښܖ<
13+
| ^ expected one of `>`, a const expression, lifetime, or type
14+
15+
error: aborting due to 2 previous errors
16+

src/test/ui/parser/issue-84148-1.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn f(t:for<>t?)
2+
//~^ ERROR: expected parameter name
3+
//~| ERROR: expected one of
4+
//~| ERROR: expected one of
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: expected parameter name, found `?`
2+
--> $DIR/issue-84148-1.rs:1:14
3+
|
4+
LL | fn f(t:for<>t?)
5+
| ^ expected parameter name
6+
7+
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
8+
--> $DIR/issue-84148-1.rs:1:14
9+
|
10+
LL | fn f(t:for<>t?)
11+
| ^
12+
| |
13+
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
14+
| help: missing `,`
15+
16+
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
17+
--> $DIR/issue-84148-1.rs:1:15
18+
|
19+
LL | fn f(t:for<>t?)
20+
| ^ expected one of `->`, `;`, `where`, or `{`
21+
22+
error: aborting due to 3 previous errors
23+

src/test/ui/parser/issue-84148-2.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// error-pattern: this file contains an unclosed delimiter
2+
// error-pattern: expected parameter name
3+
// error-pattern: expected one of
4+
fn f(t:for<>t?
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: this file contains an unclosed delimiter
2+
--> $DIR/issue-84148-2.rs:4:16
3+
|
4+
LL | fn f(t:for<>t?
5+
| - ^
6+
| |
7+
| unclosed delimiter
8+
9+
error: expected parameter name, found `?`
10+
--> $DIR/issue-84148-2.rs:4:14
11+
|
12+
LL | fn f(t:for<>t?
13+
| ^ expected parameter name
14+
15+
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
16+
--> $DIR/issue-84148-2.rs:4:14
17+
|
18+
LL | fn f(t:for<>t?
19+
| ^
20+
| |
21+
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
22+
| help: missing `,`
23+
24+
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
25+
--> $DIR/issue-84148-2.rs:4:16
26+
|
27+
LL | fn f(t:for<>t?
28+
| ^ expected one of `->`, `;`, `where`, or `{`
29+
30+
error: aborting due to 4 previous errors
31+
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Check that a suggestion is issued if there are too many `<`s in a
2+
// generic argument list, and that the parser recovers properly.
3+
4+
fn main() {
5+
foo::<<<<Ty<i32>>();
6+
//~^ ERROR: unmatched angle brackets
7+
//~| ERROR: cannot find function `foo` in this scope [E0425]
8+
//~| ERROR: cannot find type `Ty` in this scope [E0412]
9+
}

0 commit comments

Comments
 (0)