Skip to content

Rollup of 8 pull requests #86080

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

Merged
merged 18 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0933fbd
Use `Iterator::any` and `filter_map` instead of open-coding them
LingMan Jun 1, 2021
59b6583
Remove unused support for `VarDebugInfo`
tmiasko Jun 2, 2021
624c693
Remove check for projections in a branch without any
tmiasko Jun 3, 2021
3aefd77
Don't run sanity checks for `x.py setup`
jyn514 May 5, 2021
4e219e6
Remove incorrect assertion in type parsing code
FabianWolff Jun 4, 2021
6a6a605
Fix handling of unmatched angle brackets in parser
FabianWolff Jun 4, 2021
dc30258
Pass --cfg=bootstrap for proc_macros or build scripts built by stage0
jyn514 Mar 24, 2021
d963084
Remove `_` from E0121 diagnostic suggestions
fee1-dead Jun 5, 2021
c01bd56
Fix display for search results
GuillaumeGomez Jun 5, 2021
31eee59
Fix corrected example in E0759.md
FabianWolff Jun 6, 2021
85fec06
Rollup merge of #83433 - jyn514:cfg-bootstrap-macro, r=Mark-Simulacrum
GuillaumeGomez Jun 6, 2021
83664bd
Rollup merge of #84940 - jyn514:ninja, r=Mark-Simulacrum
GuillaumeGomez Jun 6, 2021
b71bc91
Rollup merge of #85912 - LingMan:iter_any, r=nagisa
GuillaumeGomez Jun 6, 2021
a3c76f6
Rollup merge of #85965 - tmiasko:a, r=nagisa
GuillaumeGomez Jun 6, 2021
1bef90f
Rollup merge of #86010 - FabianWolff:ICE-parser, r=varkor
GuillaumeGomez Jun 6, 2021
00a704f
Rollup merge of #86040 - GuillaumeGomez:search-result-display-height,…
GuillaumeGomez Jun 6, 2021
d7d2548
Rollup merge of #86058 - fee1-dead:E0121-improvements, r=jackh726
GuillaumeGomez Jun 6, 2021
487200b
Rollup merge of #86077 - FabianWolff:issue-86061, r=GuillaumeGomez
GuillaumeGomez Jun 6, 2021
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
50 changes: 4 additions & 46 deletions compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use rustc_data_structures::graph::dominators::Dominators;
use rustc_index::bit_set::BitSet;
use rustc_index::vec::{Idx, IndexVec};
use rustc_middle::mir::traversal;
use rustc_middle::mir::visit::{
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext, Visitor,
};
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, Location, TerminatorKind};
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_target::abi::LayoutOf;
Expand All @@ -20,7 +18,9 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let mir = fx.mir;
let mut analyzer = LocalAnalyzer::new(fx);

analyzer.visit_body(&mir);
for (bb, data) in mir.basic_blocks().iter_enumerated() {
analyzer.visit_basic_block_data(bb, data);
}

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

if let mir::ProjectionElem::Deref = elem {
// Deref projections typically only read the pointer.
// (the exception being `VarDebugInfo` contexts, handled below)
base_context = PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy);

// Indirect debuginfo requires going through memory, that only
// the debugger accesses, following our emitted DWARF pointer ops.
//
// FIXME(eddyb) Investigate the possibility of relaxing this, but
// note that `llvm.dbg.declare` *must* be used for indirect places,
// even if we start using `llvm.dbg.value` for all other cases,
// as we don't necessarily know when the value changes, but only
// where it lives in memory.
//
// It's possible `llvm.dbg.declare` could support starting from
// a pointer that doesn't point to an `alloca`, but this would
// only be useful if we know the pointer being `Deref`'d comes
// from an immutable place, and if `llvm.dbg.declare` calls
// must be at the very start of the function, then only function
// arguments could contain such pointers.
if context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) {
// We use `NonUseContext::VarDebugInfo` for the base,
// which might not force the base local to memory,
// so we have to do it manually.
self.visit_local(&place_ref.local, context, location);
}
}

// `NonUseContext::VarDebugInfo` needs to flow all the
// way down to the base local (see `visit_local`).
if context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) {
base_context = context;
}

self.process_place(&place_base, base_context, location);
Expand All @@ -185,20 +156,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
);
}
} else {
// FIXME this is super_place code, is repeated here to avoid cloning place or changing
// visit_place API
let mut context = context;

if !place_ref.projection.is_empty() {
context = if context.is_mutating_use() {
PlaceContext::MutatingUse(MutatingUseContext::Projection)
} else {
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
};
}

self.visit_local(&place_ref.local, context, location);
self.visit_projection(*place_ref, context, location);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_error_codes/src/error_codes/E0759.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ fn bar(x: &i32) -> Box<dyn Debug> { // error!

Add `'static` requirement to fix them:

```compile_fail,E0759
```
# use std::fmt::Debug;
fn foo(x: &i32) -> impl Debug + 'static { // ok!
fn foo(x: &'static i32) -> impl Debug + 'static { // ok!
x
}

fn bar(x: &i32) -> Box<dyn Debug + 'static> { // ok!
fn bar(x: &'static i32) -> Box<dyn Debug + 'static> { // ok!
Box::new(x)
}
```
Expand Down
13 changes: 4 additions & 9 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,15 +711,10 @@ fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKi
return false;
}

for variant in &def.variants {
if let Some(field) = transparent_newtype_field(cx.tcx, variant) {
if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) {
return true;
}
}
}

false
def.variants
.iter()
.filter_map(|variant| transparent_newtype_field(cx.tcx, variant))
.any(|field| ty_is_known_nonnull(cx, field.ty(tcx, substs), mode))
}
_ => false,
}
Expand Down
84 changes: 47 additions & 37 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,49 +352,59 @@ impl<'a> Parser<'a> {
debug!("parse_generic_args_with_leading_angle_bracket_recovery: (snapshotting)");
match self.parse_angle_args() {
Ok(args) => Ok(args),
Err(ref mut e) if is_first_invocation && self.unmatched_angle_bracket_count > 0 => {
// Cancel error from being unable to find `>`. We know the error
// must have been this due to a non-zero unmatched angle bracket
// count.
e.cancel();

Err(mut e) if is_first_invocation && self.unmatched_angle_bracket_count > 0 => {
// Swap `self` with our backup of the parser state before attempting to parse
// generic arguments.
let snapshot = mem::replace(self, snapshot.unwrap());

debug!(
"parse_generic_args_with_leading_angle_bracket_recovery: (snapshot failure) \
snapshot.count={:?}",
snapshot.unmatched_angle_bracket_count,
);

// Eat the unmatched angle brackets.
for _ in 0..snapshot.unmatched_angle_bracket_count {
self.eat_lt();
}

// Make a span over ${unmatched angle bracket count} characters.
let span = lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
self.struct_span_err(
span,
&format!(
"unmatched angle bracket{}",
pluralize!(snapshot.unmatched_angle_bracket_count)
),
)
.span_suggestion(
span,
&format!(
"remove extra angle bracket{}",
pluralize!(snapshot.unmatched_angle_bracket_count)
),
String::new(),
Applicability::MachineApplicable,
)
.emit();
let all_angle_brackets = (0..snapshot.unmatched_angle_bracket_count)
.fold(true, |a, _| a && self.eat_lt());

if !all_angle_brackets {
// If there are other tokens in between the extraneous `<`s, we cannot simply
// suggest to remove them. This check also prevents us from accidentally ending
// up in the middle of a multibyte character (issue #84104).
let _ = mem::replace(self, snapshot);
Err(e)
} else {
// Cancel error from being unable to find `>`. We know the error
// must have been this due to a non-zero unmatched angle bracket
// count.
e.cancel();

debug!(
"parse_generic_args_with_leading_angle_bracket_recovery: (snapshot failure) \
snapshot.count={:?}",
snapshot.unmatched_angle_bracket_count,
);

// Make a span over ${unmatched angle bracket count} characters.
// This is safe because `all_angle_brackets` ensures that there are only `<`s,
// i.e. no multibyte characters, in this range.
let span =
lo.with_hi(lo.lo() + BytePos(snapshot.unmatched_angle_bracket_count));
self.struct_span_err(
span,
&format!(
"unmatched angle bracket{}",
pluralize!(snapshot.unmatched_angle_bracket_count)
),
)
.span_suggestion(
span,
&format!(
"remove extra angle bracket{}",
pluralize!(snapshot.unmatched_angle_bracket_count)
),
String::new(),
Applicability::MachineApplicable,
)
.emit();

// Try again without unmatched angle bracket characters.
self.parse_angle_args()
// Try again without unmatched angle bracket characters.
self.parse_angle_args()
}
}
Err(e) => Err(e),
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ impl<'a> Parser<'a> {
mut bounds: GenericBounds,
plus: bool,
) -> PResult<'a, TyKind> {
assert_ne!(self.token, token::Question);
if plus {
self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded
bounds.append(&mut self.parse_generic_bounds(Some(self.prev_token.span))?);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ fn infer_placeholder_type(
if !ty.references_error() {
diag.span_suggestion(
span,
"replace `_` with the correct type",
"replace with the correct type",
ty.to_string(),
Applicability::MaybeIncorrect,
);
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ fn main() {
cmd.arg("-C").arg("target-feature=-crt-static");
}
}

if stage == "0" {
// Cargo doesn't pass RUSTFLAGS to proc_macros:
// https://github.com/rust-lang/cargo/issues/4423
// Set `--cfg=bootstrap` explicitly instead.
cmd.arg("--cfg=bootstrap");
}
}

if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,13 @@ impl Build {

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

// If local-rust is the same major.minor as the current version, then force a
// local-rebuild
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ a {

.search-results .result-name > span {
display: inline-block;
margin: 0;
font-weight: normal;
}

body.blur > :not(#help) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0121.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LL | static BAR: _ = "test";
| ^
| |
| not allowed in type signatures
| help: replace `_` with the correct type: `&str`
| help: replace with the correct type: `&str`

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ LL | const A = "A".$fn();
| ^
| |
| not allowed in type signatures
| help: replace `_` with the correct type: `bool`
| help: replace with the correct type: `bool`
...
LL | / suite! {
LL | | len;
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/parser/issue-84104.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// error-pattern: this file contains an unclosed delimiter
// error-pattern: expected one of
#[i=i::<ښܖ<
16 changes: 16 additions & 0 deletions src/test/ui/parser/issue-84104.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error: this file contains an unclosed delimiter
--> $DIR/issue-84104.rs:3:13
|
LL | #[i=i::<ښܖ<
| - ^
| |
| unclosed delimiter

error: expected one of `>`, a const expression, lifetime, or type, found `]`
--> $DIR/issue-84104.rs:3:13
|
LL | #[i=i::<ښܖ<
| ^ expected one of `>`, a const expression, lifetime, or type

error: aborting due to 2 previous errors

4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-84148-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn f(t:for<>t?)
//~^ ERROR: expected parameter name
//~| ERROR: expected one of
//~| ERROR: expected one of
23 changes: 23 additions & 0 deletions src/test/ui/parser/issue-84148-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: expected parameter name, found `?`
--> $DIR/issue-84148-1.rs:1:14
|
LL | fn f(t:for<>t?)
| ^ expected parameter name

error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
--> $DIR/issue-84148-1.rs:1:14
|
LL | fn f(t:for<>t?)
| ^
| |
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`

error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-1.rs:1:15
|
LL | fn f(t:for<>t?)
| ^ expected one of `->`, `;`, `where`, or `{`

error: aborting due to 3 previous errors

4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-84148-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// error-pattern: this file contains an unclosed delimiter
// error-pattern: expected parameter name
// error-pattern: expected one of
fn f(t:for<>t?
31 changes: 31 additions & 0 deletions src/test/ui/parser/issue-84148-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: this file contains an unclosed delimiter
--> $DIR/issue-84148-2.rs:4:16
|
LL | fn f(t:for<>t?
| - ^
| |
| unclosed delimiter

error: expected parameter name, found `?`
--> $DIR/issue-84148-2.rs:4:14
|
LL | fn f(t:for<>t?
| ^ expected parameter name

error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
--> $DIR/issue-84148-2.rs:4:14
|
LL | fn f(t:for<>t?
| ^
| |
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`

error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-2.rs:4:16
|
LL | fn f(t:for<>t?
| ^ expected one of `->`, `;`, `where`, or `{`

error: aborting due to 4 previous errors

9 changes: 9 additions & 0 deletions src/test/ui/parser/unmatched-langle-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Check that a suggestion is issued if there are too many `<`s in a
// generic argument list, and that the parser recovers properly.

fn main() {
foo::<<<<Ty<i32>>();
//~^ ERROR: unmatched angle brackets
//~| ERROR: cannot find function `foo` in this scope [E0425]
//~| ERROR: cannot find type `Ty` in this scope [E0412]
}
Loading