Skip to content

Commit c318799

Browse files
committed
Auto merge of #97035 - JohnTitor:rollup-00ko07z, r=JohnTitor
Rollup of 6 pull requests Successful merges: - #95365 (Use default alloc_error_handler for hermit) - #96986 ([save-analysis] Reference the variant not enum at struct-literal cons…) - #96998 (rustdoc: remove weird, unused variable from source-files.js) - #97005 (Two small improvements of rustc_expand) - #97018 (Ensure that test fail if a JS error occurs) - #97031 (Drop tracking: handle invalid assignments better) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9fbbe75 + e239fd2 commit c318799

File tree

10 files changed

+52
-12
lines changed

10 files changed

+52
-12
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ crate use ParseResult::*;
7676
use crate::mbe::{KleeneOp, TokenTree};
7777

7878
use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
79+
use rustc_lint_defs::pluralize;
7980
use rustc_parse::parser::{NtOrTt, Parser};
8081
use rustc_span::symbol::MacroRulesNormalizedIdent;
8182
use rustc_span::Span;
@@ -668,8 +669,7 @@ impl TtParser {
668669
self.macro_name,
669670
match self.next_mps.len() {
670671
0 => format!("built-in NTs {}.", nts),
671-
1 => format!("built-in NTs {} or 1 other option.", nts),
672-
n => format!("built-in NTs {} or {} other options.", nts, n),
672+
n => format!("built-in NTs {} or {n} other option{s}.", nts, s = pluralize!(n)),
673673
}
674674
),
675675
)

compiler/rustc_expand/src/mbe/macro_rules.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl TTMacroExpander for MacroRulesMacroExpander {
175175
if !self.valid {
176176
return DummyResult::any(sp);
177177
}
178-
generic_extension(
178+
expand_macro(
179179
cx,
180180
sp,
181181
self.span,
@@ -202,8 +202,9 @@ fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span,
202202
cx_expansions.entry(sp).or_default().push(message);
203203
}
204204

205-
/// Given `lhses` and `rhses`, this is the new macro we create
206-
fn generic_extension<'cx, 'tt>(
205+
/// Expands the rules based macro defined by `lhses` and `rhses` for a given
206+
/// input `arg`.
207+
fn expand_macro<'cx, 'tt>(
207208
cx: &'cx mut ExtCtxt<'_>,
208209
sp: Span,
209210
def_span: Span,

compiler/rustc_save_analysis/src/dump_visitor.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,18 @@ impl<'tcx> DumpVisitor<'tcx> {
780780
variant: &'tcx ty::VariantDef,
781781
rest: Option<&'tcx hir::Expr<'tcx>>,
782782
) {
783-
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
783+
if let Some(_ex_res_data) = self.save_ctxt.get_expr_data(ex) {
784784
if let hir::QPath::Resolved(_, path) = path {
785785
self.write_sub_paths_truncated(path);
786786
}
787-
down_cast_data!(struct_lit_data, RefData, ex.span);
787+
// For MyEnum::MyVariant, get_expr_data gives us MyEnum, not MyVariant.
788+
// For recording the span's ref id, we want MyVariant.
788789
if !generated_code(ex.span) {
789-
self.dumper.dump_ref(struct_lit_data);
790+
let sub_span = path.last_segment_span();
791+
let span = self.save_ctxt.span_from_span(sub_span);
792+
let reff =
793+
Ref { kind: RefKind::Type, span, ref_id: id_from_def_id(variant.def_id) };
794+
self.dumper.dump_ref(reff);
790795
}
791796

792797
for field in fields {

compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs

+9
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
180180
diag_expr_id: HirId,
181181
) {
182182
debug!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}");
183+
184+
if assignee_place.place.base == PlaceBase::Rvalue
185+
&& assignee_place.place.projections.is_empty()
186+
{
187+
// Assigning to an Rvalue is illegal unless done through a dereference. We would have
188+
// already gotten a type error, so we will just return here.
189+
return;
190+
}
191+
183192
// If the type being assigned needs dropped, then the mutation counts as a borrow
184193
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
185194
if assignee_place.place.base_ty.needs_drop(self.tcx, self.param_env) {

library/alloc/src/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
387387
#[cfg(all(not(no_global_oom_handling), test))]
388388
pub use std::alloc::handle_alloc_error;
389389

390-
#[cfg(all(not(no_global_oom_handling), not(any(target_os = "hermit", test))))]
390+
#[cfg(all(not(no_global_oom_handling), not(test)))]
391391
#[doc(hidden)]
392392
#[allow(unused_attributes)]
393393
#[unstable(feature = "alloc_internals", issue = "none")]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.0
1+
0.9.1

src/librustdoc/html/render/write_shared.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub(super) fn write_shared(
417417
));
418418
all_sources.sort();
419419
Ok(format!(
420-
"var N = null;var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();\n",
420+
"var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();\n",
421421
all_sources.join("\n")
422422
)
423423
.into_bytes())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// edition:2018
2+
// compile-flags: -Zdrop-tracking
3+
// Regression test for issue #73741
4+
// Ensures that we don't emit spurious errors when
5+
// a type error ocurrs in an `async fn`
6+
7+
async fn weird() {
8+
1 = 2; //~ ERROR invalid left-hand side
9+
10+
let mut loop_count = 0;
11+
async {}.await
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0070]: invalid left-hand side of assignment
2+
--> $DIR/issue-73741-type-err-drop-tracking.rs:8:7
3+
|
4+
LL | 1 = 2;
5+
| - ^
6+
| |
7+
| cannot assign to this expression
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0070`.

src/tools/rustdoc-gui/tester.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async function main(argv) {
138138
try {
139139
// This is more convenient that setting fields one by one.
140140
let args = [
141-
"--variable", "DOC_PATH", opts["doc_folder"],
141+
"--variable", "DOC_PATH", opts["doc_folder"], "--enable-fail-on-js-error",
142142
];
143143
if (opts["debug"]) {
144144
debug = true;

0 commit comments

Comments
 (0)