Skip to content

Commit a29efcc

Browse files
committed
Auto merge of rust-lang#107435 - matthiaskrgr:rollup-if5h6yu, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#106618 (Disable `linux_ext` in wasm32 and fortanix rustdoc builds.) - rust-lang#107097 (Fix def-use dominance check) - rust-lang#107154 (library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu) - rust-lang#107397 (Gracefully exit if --keep-stage flag is used on a clean source tree) - rust-lang#107401 (remove the usize field from CandidateSource::AliasBound) - rust-lang#107413 (make more pleasant to read) - rust-lang#107422 (Also erase substs for new infcx in pin move error) - rust-lang#107425 (Check for missing space between fat arrow and range pattern) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3cdd019 + 4e8f7e4 commit a29efcc

File tree

19 files changed

+221
-44
lines changed

19 files changed

+221
-44
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11281128
"{place_name} {partially_str}moved due to this method call{loop_message}",
11291129
),
11301130
);
1131+
11311132
let infcx = tcx.infer_ctxt().build();
1133+
// Erase and shadow everything that could be passed to the new infcx.
11321134
let ty = tcx.erase_regions(moved_place.ty(self.body, tcx).ty);
1135+
let method_substs = tcx.erase_regions(method_substs);
1136+
11331137
if let ty::Adt(def, substs) = ty.kind()
11341138
&& Some(def.did()) == tcx.lang_items().pin_type()
11351139
&& let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()

compiler/rustc_codegen_llvm/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub unsafe fn create_module<'ll>(
191191
//
192192
// FIXME(#34960)
193193
let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
194-
let custom_llvm_used = cfg_llvm_root.trim() != "";
194+
let custom_llvm_used = !cfg_llvm_root.trim().is_empty();
195195

196196
if !custom_llvm_used && target_data_layout != llvm_data_layout {
197197
bug!(

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+22-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
3636

3737
// Arguments get assigned to by means of the function being called
3838
for arg in mir.args_iter() {
39-
analyzer.assign(arg, mir::START_BLOCK.start_location());
39+
analyzer.assign(arg, DefLocation::Argument);
4040
}
4141

4242
// If there exists a local definition that dominates all uses of that local,
@@ -64,7 +64,22 @@ enum LocalKind {
6464
/// A scalar or a scalar pair local that is neither defined nor used.
6565
Unused,
6666
/// A scalar or a scalar pair local with a single definition that dominates all uses.
67-
SSA(mir::Location),
67+
SSA(DefLocation),
68+
}
69+
70+
#[derive(Copy, Clone, PartialEq, Eq)]
71+
enum DefLocation {
72+
Argument,
73+
Body(Location),
74+
}
75+
76+
impl DefLocation {
77+
fn dominates(self, location: Location, dominators: &Dominators<mir::BasicBlock>) -> bool {
78+
match self {
79+
DefLocation::Argument => true,
80+
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
81+
}
82+
}
6883
}
6984

7085
struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
@@ -74,17 +89,13 @@ struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
7489
}
7590

7691
impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
77-
fn assign(&mut self, local: mir::Local, location: Location) {
92+
fn assign(&mut self, local: mir::Local, location: DefLocation) {
7893
let kind = &mut self.locals[local];
7994
match *kind {
8095
LocalKind::ZST => {}
8196
LocalKind::Memory => {}
82-
LocalKind::Unused => {
83-
*kind = LocalKind::SSA(location);
84-
}
85-
LocalKind::SSA(_) => {
86-
*kind = LocalKind::Memory;
87-
}
97+
LocalKind::Unused => *kind = LocalKind::SSA(location),
98+
LocalKind::SSA(_) => *kind = LocalKind::Memory,
8899
}
89100
}
90101

@@ -166,7 +177,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
166177
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
167178

168179
if let Some(local) = place.as_local() {
169-
self.assign(local, location);
180+
self.assign(local, DefLocation::Body(location));
170181
if self.locals[local] != LocalKind::Memory {
171182
let decl_span = self.fx.mir.local_decls[local].source_info.span;
172183
if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
@@ -189,7 +200,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
189200
match context {
190201
PlaceContext::MutatingUse(MutatingUseContext::Call)
191202
| PlaceContext::MutatingUse(MutatingUseContext::Yield) => {
192-
self.assign(local, location);
203+
self.assign(local, DefLocation::Body(location));
193204
}
194205

195206
PlaceContext::NonUse(_) | PlaceContext::MutatingUse(MutatingUseContext::Retag) => {}

compiler/rustc_error_messages/locales/en-US/parse.ftl

+11
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ parse_match_arm_body_without_braces = `match` arm body without braces
199199
} with a body
200200
.suggestion_use_comma_not_semicolon = use a comma to end a `match` arm expression
201201
202+
parse_inclusive_range_extra_equals = unexpected `=` after inclusive range
203+
.suggestion_remove_eq = use `..=` instead
204+
.note = inclusive ranges end with a single equals sign (`..=`)
205+
206+
parse_inclusive_range_match_arrow = unexpected `=>` after open range
207+
.suggestion_add_space = add a space between the pattern and `=>`
208+
209+
parse_inclusive_range_no_end = inclusive range with no end
210+
.suggestion_open_range = use `..` instead
211+
.note = inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
212+
202213
parse_struct_literal_not_allowed_here = struct literals are not allowed here
203214
.suggestion = surround the struct literal with parentheses
204215

compiler/rustc_parse/src/errors.rs

+42
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,48 @@ pub(crate) struct MatchArmBodyWithoutBraces {
649649
pub sub: MatchArmBodyWithoutBracesSugg,
650650
}
651651

652+
#[derive(Diagnostic)]
653+
#[diag(parse_inclusive_range_extra_equals)]
654+
#[note]
655+
pub(crate) struct InclusiveRangeExtraEquals {
656+
#[primary_span]
657+
#[suggestion(
658+
suggestion_remove_eq,
659+
style = "short",
660+
code = "..=",
661+
applicability = "maybe-incorrect"
662+
)]
663+
pub span: Span,
664+
}
665+
666+
#[derive(Diagnostic)]
667+
#[diag(parse_inclusive_range_match_arrow)]
668+
pub(crate) struct InclusiveRangeMatchArrow {
669+
#[primary_span]
670+
pub span: Span,
671+
#[suggestion(
672+
suggestion_add_space,
673+
style = "verbose",
674+
code = " ",
675+
applicability = "machine-applicable"
676+
)]
677+
pub after_pat: Span,
678+
}
679+
680+
#[derive(Diagnostic)]
681+
#[diag(parse_inclusive_range_no_end, code = "E0586")]
682+
#[note]
683+
pub(crate) struct InclusiveRangeNoEnd {
684+
#[primary_span]
685+
#[suggestion(
686+
suggestion_open_range,
687+
code = "..",
688+
applicability = "machine-applicable",
689+
style = "short"
690+
)]
691+
pub span: Span,
692+
}
693+
652694
#[derive(Subdiagnostic)]
653695
pub(crate) enum MatchArmBodyWithoutBracesSugg {
654696
#[multipart_suggestion(suggestion_add_braces, applicability = "machine-applicable")]

compiler/rustc_parse/src/parser/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3168,7 +3168,7 @@ impl<'a> Parser<'a> {
31683168
limits: RangeLimits,
31693169
) -> ExprKind {
31703170
if end.is_none() && limits == RangeLimits::Closed {
3171-
self.inclusive_range_with_incorrect_end(self.prev_token.span);
3171+
self.inclusive_range_with_incorrect_end();
31723172
ExprKind::Err
31733173
} else {
31743174
ExprKind::Range(start, end, limits)

compiler/rustc_parse/src/parser/pat.rs

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use super::{ForceCollect, Parser, PathStyle, TrailingToken};
2-
use crate::errors::RemoveLet;
2+
use crate::errors::{
3+
InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, InclusiveRangeNoEnd, RemoveLet,
4+
};
35
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
46
use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor};
57
use rustc_ast::ptr::P;
@@ -9,7 +11,7 @@ use rustc_ast::{
911
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
1012
};
1113
use rustc_ast_pretty::pprust;
12-
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
14+
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
1315
use rustc_session::errors::ExprParenthesesNeeded;
1416
use rustc_span::source_map::{respan, Span, Spanned};
1517
use rustc_span::symbol::{kw, sym, Ident};
@@ -746,47 +748,52 @@ impl<'a> Parser<'a> {
746748
// Parsing e.g. `X..`.
747749
if let RangeEnd::Included(_) = re.node {
748750
// FIXME(Centril): Consider semantic errors instead in `ast_validation`.
749-
self.inclusive_range_with_incorrect_end(re.span);
751+
self.inclusive_range_with_incorrect_end();
750752
}
751753
None
752754
};
753755
Ok(PatKind::Range(Some(begin), end, re))
754756
}
755757

756-
pub(super) fn inclusive_range_with_incorrect_end(&mut self, span: Span) {
758+
pub(super) fn inclusive_range_with_incorrect_end(&mut self) {
757759
let tok = &self.token;
758-
760+
let span = self.prev_token.span;
759761
// If the user typed "..==" instead of "..=", we want to give them
760762
// a specific error message telling them to use "..=".
763+
// If they typed "..=>", suggest they use ".. =>".
761764
// Otherwise, we assume that they meant to type a half open exclusive
762765
// range and give them an error telling them to do that instead.
763-
if matches!(tok.kind, token::Eq) && tok.span.lo() == span.hi() {
764-
let span_with_eq = span.to(tok.span);
766+
let no_space = tok.span.lo() == span.hi();
767+
match tok.kind {
768+
token::Eq if no_space => {
769+
let span_with_eq = span.to(tok.span);
765770

766-
// Ensure the user doesn't receive unhelpful unexpected token errors
767-
self.bump();
768-
if self.is_pat_range_end_start(0) {
769-
let _ = self.parse_pat_range_end().map_err(|e| e.cancel());
770-
}
771+
// Ensure the user doesn't receive unhelpful unexpected token errors
772+
self.bump();
773+
if self.is_pat_range_end_start(0) {
774+
let _ = self.parse_pat_range_end().map_err(|e| e.cancel());
775+
}
771776

772-
self.error_inclusive_range_with_extra_equals(span_with_eq);
773-
} else {
774-
self.error_inclusive_range_with_no_end(span);
777+
self.error_inclusive_range_with_extra_equals(span_with_eq);
778+
}
779+
token::Gt if no_space => {
780+
self.error_inclusive_range_match_arrow(span);
781+
}
782+
_ => self.error_inclusive_range_with_no_end(span),
775783
}
776784
}
777785

778786
fn error_inclusive_range_with_extra_equals(&self, span: Span) {
779-
self.struct_span_err(span, "unexpected `=` after inclusive range")
780-
.span_suggestion_short(span, "use `..=` instead", "..=", Applicability::MaybeIncorrect)
781-
.note("inclusive ranges end with a single equals sign (`..=`)")
782-
.emit();
787+
self.sess.emit_err(InclusiveRangeExtraEquals { span });
788+
}
789+
790+
fn error_inclusive_range_match_arrow(&self, span: Span) {
791+
let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi();
792+
self.sess.emit_err(InclusiveRangeMatchArrow { span, after_pat });
783793
}
784794

785795
fn error_inclusive_range_with_no_end(&self, span: Span) {
786-
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
787-
.span_suggestion_short(span, "use `..` instead", "..", Applicability::MachineApplicable)
788-
.note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
789-
.emit();
796+
self.sess.emit_err(InclusiveRangeNoEnd { span });
790797
}
791798

792799
/// Parse a range-to pattern, `..X` or `..=X` where `X` remains to be parsed.

compiler/rustc_trait_selection/src/solve/assembly.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) enum CandidateSource {
7878
/// let _y = x.clone();
7979
/// }
8080
/// ```
81-
AliasBound(usize),
81+
AliasBound,
8282
}
8383

8484
pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy + Eq {
@@ -242,8 +242,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
242242
// NOTE: Alternatively we could call `evaluate_goal` here and only have a `Normalized` candidate.
243243
// This doesn't work as long as we use `CandidateSource` in winnowing.
244244
let goal = goal.with(tcx, goal.predicate.with_self_ty(tcx, normalized_ty));
245-
// FIXME: This is broken if we care about the `usize` of `AliasBound` because the self type
246-
// could be normalized to yet another projection with different item bounds.
247245
let normalized_candidates = self.assemble_and_evaluate_candidates(goal);
248246
for mut normalized_candidate in normalized_candidates {
249247
normalized_candidate.result =
@@ -368,15 +366,14 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
368366
ty::Alias(_, alias_ty) => alias_ty,
369367
};
370368

371-
for (i, (assumption, _)) in self
369+
for (assumption, _) in self
372370
.tcx()
373371
.bound_explicit_item_bounds(alias_ty.def_id)
374372
.subst_iter_copied(self.tcx(), alias_ty.substs)
375-
.enumerate()
376373
{
377374
match G::consider_assumption(self, goal, assumption) {
378375
Ok(result) => {
379-
candidates.push(Candidate { source: CandidateSource::AliasBound(i), result })
376+
candidates.push(Candidate { source: CandidateSource::AliasBound, result })
380377
}
381378
Err(NoSolution) => (),
382379
}

compiler/rustc_trait_selection/src/solve/project_goals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
171171
(CandidateSource::Impl(_), _)
172172
| (CandidateSource::ParamEnv(_), _)
173173
| (CandidateSource::BuiltinImpl, _)
174-
| (CandidateSource::AliasBound(_), _) => unimplemented!(),
174+
| (CandidateSource::AliasBound, _) => unimplemented!(),
175175
}
176176
}
177177
}

compiler/rustc_trait_selection/src/solve/trait_goals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
322322
match (candidate.source, other.source) {
323323
(CandidateSource::Impl(_), _)
324324
| (CandidateSource::ParamEnv(_), _)
325-
| (CandidateSource::AliasBound(_), _)
325+
| (CandidateSource::AliasBound, _)
326326
| (CandidateSource::BuiltinImpl, _) => unimplemented!(),
327327
}
328328
}

library/std/src/os/net/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
//! OS-specific networking functionality.
22
3+
// See cfg macros in `library/std/src/os/mod.rs` for why these platforms must
4+
// be special-cased during rustdoc generation.
5+
#[cfg(not(all(
6+
doc,
7+
any(
8+
all(target_arch = "wasm32", not(target_os = "wasi")),
9+
all(target_vendor = "fortanix", target_env = "sgx")
10+
)
11+
)))]
312
#[cfg(any(target_os = "linux", target_os = "android", doc))]
413
pub(super) mod linux_ext;

library/std/src/sys/common/alloc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::ptr;
77
#[cfg(any(
88
target_arch = "x86",
99
target_arch = "arm",
10+
target_arch = "m68k",
1011
target_arch = "mips",
1112
target_arch = "powerpc",
1213
target_arch = "powerpc64",

src/bootstrap/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,13 @@ impl Build {
14311431
return Vec::new();
14321432
}
14331433

1434+
if !stamp.exists() {
1435+
eprintln!(
1436+
"Warning: Unable to find the stamp file, did you try to keep a nonexistent build stage?"
1437+
);
1438+
crate::detail_exit(1);
1439+
}
1440+
14341441
let mut paths = Vec::new();
14351442
let contents = t!(fs::read(stamp), &stamp);
14361443
// This is the method we use for extracting paths from the stamp file passed to us. See
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let x = 42;
3+
match x {
4+
0..=73 => {},
5+
74..=> {}, //~ ERROR unexpected `=>` after open range
6+
//~^ ERROR expected one of `=>`, `if`, or `|`, found `>`
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error: unexpected `=>` after open range
2+
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:11
3+
|
4+
LL | 74..=> {},
5+
| ^^^
6+
|
7+
help: add a space between the pattern and `=>`
8+
|
9+
LL | 74.. => {},
10+
| +
11+
12+
error: expected one of `=>`, `if`, or `|`, found `>`
13+
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
14+
|
15+
LL | 74..=> {},
16+
| ^ expected one of `=>`, `if`, or `|`
17+
18+
error: aborting due to 2 previous errors
19+

0 commit comments

Comments
 (0)