From 8f47635254c9251e6b58c724c6e1fa6b83fb561e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Sun, 27 Mar 2022 14:14:34 +0200 Subject: [PATCH 1/9] Use default alloc_error_handler for hermit Hermit now properly separates kernel from userspace. Applications for hermit can now use Rust's default alloc_error_handler instead of calling the kernel's __rg_oom. --- library/alloc/src/alloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index bd7d721b5e173..7ed9ca5fd8781 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -385,7 +385,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")] From 5fde765df08d5f9d22df1368a8dbc0ed99e52b04 Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Tue, 10 May 2022 16:15:48 -0700 Subject: [PATCH 2/9] [save-analysis] Reference the variant not enum at struct-literal construction. Closes #96985 --- compiler/rustc_save_analysis/src/dump_visitor.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs index e1c9ecc055f6a..fe417f45e88d9 100644 --- a/compiler/rustc_save_analysis/src/dump_visitor.rs +++ b/compiler/rustc_save_analysis/src/dump_visitor.rs @@ -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 { From 1b41d11d741fa302acf34276aa3375330f31aad3 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 12 May 2022 17:34:16 -0700 Subject: [PATCH 3/9] rustdoc: remove weird, unused variable from source-files.js --- src/librustdoc/html/render/write_shared.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index e8e5fa1799333..68f2a54ddeb05 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -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()) From cc3c5d2700481bae497d6cde825c1d48e79c776a Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 13 May 2022 08:42:39 +0200 Subject: [PATCH 4/9] Improve name and documentation of generic_extension This function doesn't *create* a (rules based) macro, it *expands* it. Thus, the documentation was wrong. --- compiler/rustc_expand/src/mbe/macro_rules.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index ba0b35470b6ba..4cc3169180ea5 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -175,7 +175,7 @@ impl TTMacroExpander for MacroRulesMacroExpander { if !self.valid { return DummyResult::any(sp); } - generic_extension( + expand_macro( cx, sp, self.span, @@ -202,8 +202,9 @@ fn trace_macros_note(cx_expansions: &mut FxHashMap>, 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, From e6ccf9b5d8e56d08936cd77f1bb72abd5e2582ed Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 13 May 2022 08:48:35 +0200 Subject: [PATCH 5/9] Use pluralize in one instance --- compiler/rustc_expand/src/mbe/macro_parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 29f354d572802..ddfbef945efaa 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -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; @@ -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)), } ), ) From a50ad35dda4d5468539d9233f04f075692d86bd7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 13 May 2022 17:03:33 +0200 Subject: [PATCH 6/9] Update browser-ui-test version --- .../docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index 899f24fc754a1..f514a2f0bd053 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.9.0 \ No newline at end of file +0.9.1 \ No newline at end of file From 5ec5a762e9a6cd2369c02211f38ada9a55e1d12b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 13 May 2022 17:05:17 +0200 Subject: [PATCH 7/9] Emit an error if there is a JS failure on rustdoc pages --- src/tools/rustdoc-gui/tester.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index d75884567afee..8532410a1bf3a 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -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; From 5c98737715f60ce180a3b607fd1b96c709f6807d Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Fri, 13 May 2022 16:25:22 -0700 Subject: [PATCH 8/9] Drop tracking: handle invalid assignments better Previously this test case was crashing with an index out of bounds error deep in the call to `needs_drop`. We avoid this by detecting clearly invalid assignees in the `mutate` callback and ignoring these. --- .../drop_ranges/record_consumed_borrow.rs | 9 +++++++++ .../issue-73741-type-err-drop-tracking.rs | 14 ++++++++++++++ .../issue-73741-type-err-drop-tracking.stderr | 11 +++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs create mode 100644 src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr diff --git a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs index 928daba0a7b39..b3012cc677661 100644 --- a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -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.len() == 0 + { + // 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) { diff --git a/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs new file mode 100644 index 0000000000000..c3423ad629f16 --- /dev/null +++ b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs @@ -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() {} diff --git a/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr new file mode 100644 index 0000000000000..d4e3b6c3bf40d --- /dev/null +++ b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr @@ -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`. From 6665a4328b4076285e4c233995b5a08aeff4b603 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Fri, 13 May 2022 19:32:53 -0700 Subject: [PATCH 9/9] Fix nit --- .../generator_interior/drop_ranges/record_consumed_borrow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs index b3012cc677661..e89a896199615 100644 --- a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -182,7 +182,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { debug!("mutate {assignee_place:?}; diag_expr_id={diag_expr_id:?}"); if assignee_place.place.base == PlaceBase::Rvalue - && assignee_place.place.projections.len() == 0 + && 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.