Skip to content

Commit

Permalink
Auto merge of rust-lang#97035 - JohnTitor:rollup-00ko07z, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - rust-lang#95365 (Use default alloc_error_handler for hermit)
 - rust-lang#96986 ([save-analysis] Reference the variant not enum at struct-literal cons…)
 - rust-lang#96998 (rustdoc: remove weird, unused variable from source-files.js)
 - rust-lang#97005 (Two small improvements of rustc_expand)
 - rust-lang#97018 (Ensure that test fail if a JS error occurs)
 - rust-lang#97031 (Drop tracking: handle invalid assignments better)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed May 14, 2022
2 parents 9fbbe75 + e239fd2 commit c318799
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 12 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ crate use ParseResult::*;
use crate::mbe::{KleeneOp, TokenTree};

use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
use rustc_lint_defs::pluralize;
use rustc_parse::parser::{NtOrTt, Parser};
use rustc_span::symbol::MacroRulesNormalizedIdent;
use rustc_span::Span;
Expand Down Expand Up @@ -668,8 +669,7 @@ impl TtParser {
self.macro_name,
match self.next_mps.len() {
0 => format!("built-in NTs {}.", nts),
1 => format!("built-in NTs {} or 1 other option.", nts),
n => format!("built-in NTs {} or {} other options.", nts, n),
n => format!("built-in NTs {} or {n} other option{s}.", nts, s = pluralize!(n)),
}
),
)
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl TTMacroExpander for MacroRulesMacroExpander {
if !self.valid {
return DummyResult::any(sp);
}
generic_extension(
expand_macro(
cx,
sp,
self.span,
Expand All @@ -202,8 +202,9 @@ fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span,
cx_expansions.entry(sp).or_default().push(message);
}

/// Given `lhses` and `rhses`, this is the new macro we create
fn generic_extension<'cx, 'tt>(
/// Expands the rules based macro defined by `lhses` and `rhses` for a given
/// input `arg`.
fn expand_macro<'cx, 'tt>(
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
def_span: Span,
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_save_analysis/src/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,18 @@ impl<'tcx> DumpVisitor<'tcx> {
variant: &'tcx ty::VariantDef,
rest: Option<&'tcx hir::Expr<'tcx>>,
) {
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
if let Some(_ex_res_data) = self.save_ctxt.get_expr_data(ex) {
if let hir::QPath::Resolved(_, path) = path {
self.write_sub_paths_truncated(path);
}
down_cast_data!(struct_lit_data, RefData, ex.span);
// For MyEnum::MyVariant, get_expr_data gives us MyEnum, not MyVariant.
// For recording the span's ref id, we want MyVariant.
if !generated_code(ex.span) {
self.dumper.dump_ref(struct_lit_data);
let sub_span = path.last_segment_span();
let span = self.save_ctxt.span_from_span(sub_span);
let reff =
Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(variant.def_id) };
self.dumper.dump_ref(reff);
}

for field in fields {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
diag_expr_id: HirId,
) {
debug!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}");

if assignee_place.place.base == PlaceBase::Rvalue
&& assignee_place.place.projections.is_empty()
{
// Assigning to an Rvalue is illegal unless done through a dereference. We would have
// already gotten a type error, so we will just return here.
return;
}

// If the type being assigned needs dropped, then the mutation counts as a borrow
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
if assignee_place.place.base_ty.needs_drop(self.tcx, self.param_env) {
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
#[cfg(all(not(no_global_oom_handling), test))]
pub use std::alloc::handle_alloc_error;

#[cfg(all(not(no_global_oom_handling), not(any(target_os = "hermit", test))))]
#[cfg(all(not(no_global_oom_handling), not(test)))]
#[doc(hidden)]
#[allow(unused_attributes)]
#[unstable(feature = "alloc_internals", issue = "none")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ pub(super) fn write_shared(
));
all_sources.sort();
Ok(format!(
"var N = null;var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();\n",
"var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();\n",
all_sources.join("\n")
)
.into_bytes())
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// edition:2018
// compile-flags: -Zdrop-tracking
// Regression test for issue #73741
// Ensures that we don't emit spurious errors when
// a type error ocurrs in an `async fn`

async fn weird() {
1 = 2; //~ ERROR invalid left-hand side

let mut loop_count = 0;
async {}.await
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0070]: invalid left-hand side of assignment
--> $DIR/issue-73741-type-err-drop-tracking.rs:8:7
|
LL | 1 = 2;
| - ^
| |
| cannot assign to this expression

error: aborting due to previous error

For more information about this error, try `rustc --explain E0070`.
2 changes: 1 addition & 1 deletion src/tools/rustdoc-gui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function main(argv) {
try {
// This is more convenient that setting fields one by one.
let args = [
"--variable", "DOC_PATH", opts["doc_folder"],
"--variable", "DOC_PATH", opts["doc_folder"], "--enable-fail-on-js-error",
];
if (opts["debug"]) {
debug = true;
Expand Down

0 comments on commit c318799

Please sign in to comment.