Skip to content

Commit

Permalink
Auto merge of #95061 - cuviper:beta-stage0, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
[beta] backports + bootstrap bump

Add pending backports:

* Revert accidental stabilization #94805
* Do not recover from Ty? in macro parsing #94593
* Fix cmake build. #95050

And updates the bootstrap compiler to 1.59.0.
  • Loading branch information
bors committed Mar 18, 2022
2 parents 99f967e + 113631b commit 6ee5a40
Show file tree
Hide file tree
Showing 11 changed files with 353 additions and 361 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::pat::Expected;
use super::ty::{AllowPlus, IsAsCast};
use super::ty::{AllowPlus, RecoverQuestionMark};
use super::{
BlockMode, Parser, PathStyle, RecoverColon, RecoverComma, Restrictions, SemiColonMode, SeqSep,
TokenExpectType, TokenType,
Expand Down Expand Up @@ -1037,9 +1037,9 @@ impl<'a> Parser<'a> {
pub(super) fn maybe_recover_from_question_mark(
&mut self,
ty: P<Ty>,
is_as_cast: IsAsCast,
recover_question_mark: RecoverQuestionMark,
) -> P<Ty> {
if let IsAsCast::Yes = is_as_cast {
if let RecoverQuestionMark::No = recover_question_mark {
return ty;
}
if self.token == token::Question {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/nonterminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a> Parser<'a> {
}

NonterminalKind::Ty => {
token::NtTy(self.collect_tokens_no_attrs(|this| this.parse_ty())?)
token::NtTy(self.collect_tokens_no_attrs(|this| this.parse_no_question_mark_recover())?)
}
// this could be handled like a token, since it is one
NonterminalKind::Ident
Expand Down
34 changes: 23 additions & 11 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub(super) enum RecoverQPath {
No,
}

pub(super) enum IsAsCast {
pub(super) enum RecoverQuestionMark {
Yes,
No,
}
Expand Down Expand Up @@ -105,7 +105,7 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::Yes,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)
}

Expand All @@ -119,7 +119,7 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::Yes,
Some(ty_params),
IsAsCast::No,
RecoverQuestionMark::Yes,
)
}

Expand All @@ -133,7 +133,7 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::Yes,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)
}

Expand All @@ -150,7 +150,7 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::Yes,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)
}

Expand All @@ -163,9 +163,21 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::Yes,
None,
IsAsCast::Yes,
RecoverQuestionMark::No,
)
}

pub(super) fn parse_no_question_mark_recover(&mut self) -> PResult<'a, P<Ty>> {
self.parse_ty_common(
AllowPlus::Yes,
AllowCVariadic::No,
RecoverQPath::Yes,
RecoverReturnSign::Yes,
None,
RecoverQuestionMark::No,
)
}

/// Parse a type without recovering `:` as `->` to avoid breaking code such as `where fn() : for<'a>`
pub(super) fn parse_ty_for_where_clause(&mut self) -> PResult<'a, P<Ty>> {
self.parse_ty_common(
Expand All @@ -174,7 +186,7 @@ impl<'a> Parser<'a> {
RecoverQPath::Yes,
RecoverReturnSign::OnlyFatArrow,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)
}

Expand All @@ -193,7 +205,7 @@ impl<'a> Parser<'a> {
recover_qpath,
recover_return_sign,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)?;
FnRetTy::Ty(ty)
} else if recover_return_sign.can_recover(&self.token.kind) {
Expand All @@ -214,7 +226,7 @@ impl<'a> Parser<'a> {
recover_qpath,
recover_return_sign,
None,
IsAsCast::No,
RecoverQuestionMark::Yes,
)?;
FnRetTy::Ty(ty)
} else {
Expand All @@ -229,7 +241,7 @@ impl<'a> Parser<'a> {
recover_qpath: RecoverQPath,
recover_return_sign: RecoverReturnSign,
ty_generics: Option<&Generics>,
is_as_cast: IsAsCast,
recover_question_mark: RecoverQuestionMark,
) -> PResult<'a, P<Ty>> {
let allow_qpath_recovery = recover_qpath == RecoverQPath::Yes;
maybe_recover_from_interpolated_ty_qpath!(self, allow_qpath_recovery);
Expand Down Expand Up @@ -305,7 +317,7 @@ impl<'a> Parser<'a> {
// Try to recover from use of `+` with incorrect priority.
self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
self.maybe_recover_from_bad_type_plus(allow_plus, &ty)?;
let ty = self.maybe_recover_from_question_mark(ty, is_as_cast);
let ty = self.maybe_recover_from_question_mark(ty, recover_question_mark);
self.maybe_recover_from_bad_qpath(ty, allow_qpath_recovery)
}

Expand Down
3 changes: 1 addition & 2 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> const Drop for Box<T, A> {
unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box<T, A> {
fn drop(&mut self) {
// FIXME: Do nothing, drop is currently performed by compiler.
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/tests/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn const_box() {
*boxed = 42;
assert!(*boxed == 42);

*boxed
*Box::leak(boxed)
};

assert!(VALUE == 42);
Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/scripts/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ hide_output() {
set +x
on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/build.log
cat /tmp/cmake_build.log
exit 1
"
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
"$@" &> /tmp/build.log
"$@" &> /tmp/cmake_build.log
trap - ERR
kill $PING_LOOP_PID
rm /tmp/build.log
rm /tmp/cmake_build.log
set -x
}

Expand Down
Loading

0 comments on commit 6ee5a40

Please sign in to comment.