Skip to content

Rollup of 8 pull requests #107435

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
Jan 29, 2023
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
92aa5f6
Disable `linux_ext` in wasm32 and fortanix rustdoc builds.
jmillikin Jan 9, 2023
8f70b5c
library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu
glaubitz Jan 21, 2023
e489971
Fix def-use dominance check
tmiasko Jan 22, 2023
d4a816c
remove the usize field from CandidateSource::AliasBound
lenko-d Jan 28, 2023
d3cf813
Use field-less variant for AliasBound.
lenko-d Jan 28, 2023
5251769
make more pleasant to read
tshepang Jan 28, 2023
832751f
Also erase substs for new infcx in pin move error
Noratrieb Jan 28, 2023
65186e0
Gracefully exit when --keep-stage used on clean source tree
Teapot4195 Jan 28, 2023
4bfab39
Check for missing space between fat arrow and range pattern
clubby789 Jan 28, 2023
c568879
Migrate some range parsing diagnostics
clubby789 Jan 28, 2023
0f86ada
Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor
matthiaskrgr Jan 29, 2023
4caa9df
Rollup merge of #107097 - tmiasko:ssa, r=cjgillot
matthiaskrgr Jan 29, 2023
33da3c3
Rollup merge of #107154 - glaubitz:m68k-alloc, r=JohnTitor
matthiaskrgr Jan 29, 2023
40b63d0
Rollup merge of #107397 - Teapot4195:issue-107392-fix, r=albertlarsan68
matthiaskrgr Jan 29, 2023
70fc114
Rollup merge of #107401 - lenko-d:remove_the_usize_field_from_Candida…
matthiaskrgr Jan 29, 2023
74655dc
Rollup merge of #107413 - tshepang:pleasant-readin, r=Nilstrieb
matthiaskrgr Jan 29, 2023
5ff6cdc
Rollup merge of #107422 - Nilstrieb:erase-the-ice, r=compiler-errors
matthiaskrgr Jan 29, 2023
4e8f7e4
Rollup merge of #107425 - clubby789:match-range-missing-space, r=comp…
matthiaskrgr Jan 29, 2023
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
4 changes: 4 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"{place_name} {partially_str}moved due to this method call{loop_message}",
),
);

let infcx = tcx.infer_ctxt().build();
// Erase and shadow everything that could be passed to the new infcx.
let ty = tcx.erase_regions(moved_place.ty(self.body, tcx).ty);
let method_substs = tcx.erase_regions(method_substs);

if let ty::Adt(def, substs) = ty.kind()
&& Some(def.did()) == tcx.lang_items().pin_type()
&& let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub unsafe fn create_module<'ll>(
//
// FIXME(#34960)
let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
let custom_llvm_used = cfg_llvm_root.trim() != "";
let custom_llvm_used = !cfg_llvm_root.trim().is_empty();

if !custom_llvm_used && target_data_layout != llvm_data_layout {
bug!(
Expand Down
33 changes: 22 additions & 11 deletions compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

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

// If there exists a local definition that dominates all uses of that local,
Expand Down Expand Up @@ -64,7 +64,22 @@ enum LocalKind {
/// A scalar or a scalar pair local that is neither defined nor used.
Unused,
/// A scalar or a scalar pair local with a single definition that dominates all uses.
SSA(mir::Location),
SSA(DefLocation),
}

#[derive(Copy, Clone, PartialEq, Eq)]
enum DefLocation {
Argument,
Body(Location),
}

impl DefLocation {
fn dominates(self, location: Location, dominators: &Dominators<mir::BasicBlock>) -> bool {
match self {
DefLocation::Argument => true,
DefLocation::Body(def) => def.successor_within_block().dominates(location, dominators),
}
}
}

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

impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
fn assign(&mut self, local: mir::Local, location: Location) {
fn assign(&mut self, local: mir::Local, location: DefLocation) {
let kind = &mut self.locals[local];
match *kind {
LocalKind::ZST => {}
LocalKind::Memory => {}
LocalKind::Unused => {
*kind = LocalKind::SSA(location);
}
LocalKind::SSA(_) => {
*kind = LocalKind::Memory;
}
LocalKind::Unused => *kind = LocalKind::SSA(location),
LocalKind::SSA(_) => *kind = LocalKind::Memory,
}
}

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

if let Some(local) = place.as_local() {
self.assign(local, location);
self.assign(local, DefLocation::Body(location));
if self.locals[local] != LocalKind::Memory {
let decl_span = self.fx.mir.local_decls[local].source_info.span;
if !self.fx.rvalue_creates_operand(rvalue, decl_span) {
Expand All @@ -189,7 +200,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
match context {
PlaceContext::MutatingUse(MutatingUseContext::Call)
| PlaceContext::MutatingUse(MutatingUseContext::Yield) => {
self.assign(local, location);
self.assign(local, DefLocation::Body(location));
}

PlaceContext::NonUse(_) | PlaceContext::MutatingUse(MutatingUseContext::Retag) => {}
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parse.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ parse_match_arm_body_without_braces = `match` arm body without braces
} with a body
.suggestion_use_comma_not_semicolon = use a comma to end a `match` arm expression

parse_inclusive_range_extra_equals = unexpected `=` after inclusive range
.suggestion_remove_eq = use `..=` instead
.note = inclusive ranges end with a single equals sign (`..=`)

parse_inclusive_range_match_arrow = unexpected `=>` after open range
.suggestion_add_space = add a space between the pattern and `=>`

parse_inclusive_range_no_end = inclusive range with no end
.suggestion_open_range = use `..` instead
.note = inclusive ranges must be bounded at the end (`..=b` or `a..=b`)

parse_struct_literal_not_allowed_here = struct literals are not allowed here
.suggestion = surround the struct literal with parentheses

Expand Down
42 changes: 42 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,48 @@ pub(crate) struct MatchArmBodyWithoutBraces {
pub sub: MatchArmBodyWithoutBracesSugg,
}

#[derive(Diagnostic)]
#[diag(parse_inclusive_range_extra_equals)]
#[note]
pub(crate) struct InclusiveRangeExtraEquals {
#[primary_span]
#[suggestion(
suggestion_remove_eq,
style = "short",
code = "..=",
applicability = "maybe-incorrect"
)]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_inclusive_range_match_arrow)]
pub(crate) struct InclusiveRangeMatchArrow {
#[primary_span]
pub span: Span,
#[suggestion(
suggestion_add_space,
style = "verbose",
code = " ",
applicability = "machine-applicable"
)]
pub after_pat: Span,
}

#[derive(Diagnostic)]
#[diag(parse_inclusive_range_no_end, code = "E0586")]
#[note]
pub(crate) struct InclusiveRangeNoEnd {
#[primary_span]
#[suggestion(
suggestion_open_range,
code = "..",
applicability = "machine-applicable",
style = "short"
)]
pub span: Span,
}

#[derive(Subdiagnostic)]
pub(crate) enum MatchArmBodyWithoutBracesSugg {
#[multipart_suggestion(suggestion_add_braces, applicability = "machine-applicable")]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ impl<'a> Parser<'a> {
limits: RangeLimits,
) -> ExprKind {
if end.is_none() && limits == RangeLimits::Closed {
self.inclusive_range_with_incorrect_end(self.prev_token.span);
self.inclusive_range_with_incorrect_end();
ExprKind::Err
} else {
ExprKind::Range(start, end, limits)
Expand Down
53 changes: 30 additions & 23 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use super::{ForceCollect, Parser, PathStyle, TrailingToken};
use crate::errors::RemoveLet;
use crate::errors::{
InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, InclusiveRangeNoEnd, RemoveLet,
};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor};
use rustc_ast::ptr::P;
Expand All @@ -9,7 +11,7 @@ use rustc_ast::{
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
};
use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::{respan, Span, Spanned};
use rustc_span::symbol::{kw, sym, Ident};
Expand Down Expand Up @@ -746,47 +748,52 @@ impl<'a> Parser<'a> {
// Parsing e.g. `X..`.
if let RangeEnd::Included(_) = re.node {
// FIXME(Centril): Consider semantic errors instead in `ast_validation`.
self.inclusive_range_with_incorrect_end(re.span);
self.inclusive_range_with_incorrect_end();
}
None
};
Ok(PatKind::Range(Some(begin), end, re))
}

pub(super) fn inclusive_range_with_incorrect_end(&mut self, span: Span) {
pub(super) fn inclusive_range_with_incorrect_end(&mut self) {
let tok = &self.token;

let span = self.prev_token.span;
// If the user typed "..==" instead of "..=", we want to give them
// a specific error message telling them to use "..=".
// If they typed "..=>", suggest they use ".. =>".
// Otherwise, we assume that they meant to type a half open exclusive
// range and give them an error telling them to do that instead.
if matches!(tok.kind, token::Eq) && tok.span.lo() == span.hi() {
let span_with_eq = span.to(tok.span);
let no_space = tok.span.lo() == span.hi();
match tok.kind {
token::Eq if no_space => {
let span_with_eq = span.to(tok.span);

// Ensure the user doesn't receive unhelpful unexpected token errors
self.bump();
if self.is_pat_range_end_start(0) {
let _ = self.parse_pat_range_end().map_err(|e| e.cancel());
}
// Ensure the user doesn't receive unhelpful unexpected token errors
self.bump();
if self.is_pat_range_end_start(0) {
let _ = self.parse_pat_range_end().map_err(|e| e.cancel());
}

self.error_inclusive_range_with_extra_equals(span_with_eq);
} else {
self.error_inclusive_range_with_no_end(span);
self.error_inclusive_range_with_extra_equals(span_with_eq);
}
token::Gt if no_space => {
self.error_inclusive_range_match_arrow(span);
}
_ => self.error_inclusive_range_with_no_end(span),
}
}

fn error_inclusive_range_with_extra_equals(&self, span: Span) {
self.struct_span_err(span, "unexpected `=` after inclusive range")
.span_suggestion_short(span, "use `..=` instead", "..=", Applicability::MaybeIncorrect)
.note("inclusive ranges end with a single equals sign (`..=`)")
.emit();
self.sess.emit_err(InclusiveRangeExtraEquals { span });
}

fn error_inclusive_range_match_arrow(&self, span: Span) {
let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi();
self.sess.emit_err(InclusiveRangeMatchArrow { span, after_pat });
}

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

/// Parse a range-to pattern, `..X` or `..=X` where `X` remains to be parsed.
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_trait_selection/src/solve/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(super) enum CandidateSource {
/// let _y = x.clone();
/// }
/// ```
AliasBound(usize),
AliasBound,
}

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

for (i, (assumption, _)) in self
for (assumption, _) in self
.tcx()
.bound_explicit_item_bounds(alias_ty.def_id)
.subst_iter_copied(self.tcx(), alias_ty.substs)
.enumerate()
{
match G::consider_assumption(self, goal, assumption) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::AliasBound(i), result })
candidates.push(Candidate { source: CandidateSource::AliasBound, result })
}
Err(NoSolution) => (),
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/solve/project_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
(CandidateSource::Impl(_), _)
| (CandidateSource::ParamEnv(_), _)
| (CandidateSource::BuiltinImpl, _)
| (CandidateSource::AliasBound(_), _) => unimplemented!(),
| (CandidateSource::AliasBound, _) => unimplemented!(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
match (candidate.source, other.source) {
(CandidateSource::Impl(_), _)
| (CandidateSource::ParamEnv(_), _)
| (CandidateSource::AliasBound(_), _)
| (CandidateSource::AliasBound, _)
| (CandidateSource::BuiltinImpl, _) => unimplemented!(),
}
}
Expand Down
9 changes: 9 additions & 0 deletions library/std/src/os/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
//! OS-specific networking functionality.

// See cfg macros in `library/std/src/os/mod.rs` for why these platforms must
// be special-cased during rustdoc generation.
#[cfg(not(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(any(target_os = "linux", target_os = "android", doc))]
pub(super) mod linux_ext;
1 change: 1 addition & 0 deletions library/std/src/sys/common/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::ptr;
#[cfg(any(
target_arch = "x86",
target_arch = "arm",
target_arch = "m68k",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,13 @@ impl Build {
return Vec::new();
}

if !stamp.exists() {
eprintln!(
"Warning: Unable to find the stamp file, did you try to keep a nonexistent build stage?"
);
crate::detail_exit(1);
}

let mut paths = Vec::new();
let contents = t!(fs::read(stamp), &stamp);
// This is the method we use for extracting paths from the stamp file passed to us. See
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
let x = 42;
match x {
0..=73 => {},
74..=> {}, //~ ERROR unexpected `=>` after open range
//~^ ERROR expected one of `=>`, `if`, or `|`, found `>`
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: unexpected `=>` after open range
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:11
|
LL | 74..=> {},
| ^^^
|
help: add a space between the pattern and `=>`
|
LL | 74.. => {},
| +

error: expected one of `=>`, `if`, or `|`, found `>`
--> $DIR/half-open-range-pats-inclusive-match-arrow.rs:5:14
|
LL | 74..=> {},
| ^ expected one of `=>`, `if`, or `|`

error: aborting due to 2 previous errors

Loading