From 810cce85aa138fb59b397e6b17651f42e32f6f5a Mon Sep 17 00:00:00 2001 From: Andrew Pollack Date: Thu, 13 Oct 2022 21:26:52 +0000 Subject: [PATCH 01/18] Adding fuchsia-ignore and needs-unwind to compiler test cases --- src/test/ui/command/command-current-dir.rs | 1 + src/test/ui/issues/issue-30490.rs | 1 + src/test/ui/process/process-spawn-with-unicode-params.rs | 1 + .../test-fn-signature-verification-for-explicit-return-type.rs | 1 + src/test/ui/test-attrs/test-thread-capture.rs | 1 + src/test/ui/test-attrs/test-thread-capture.run.stdout | 2 +- src/test/ui/test-attrs/test-thread-nocapture.rs | 1 + src/test/ui/test-attrs/test-thread-nocapture.run.stderr | 2 +- src/test/ui/threads-sendsync/sync-send-in-std.rs | 1 + 9 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/test/ui/command/command-current-dir.rs b/src/test/ui/command/command-current-dir.rs index 69a0b486d689f..5d06fcdebc6b1 100644 --- a/src/test/ui/command/command-current-dir.rs +++ b/src/test/ui/command/command-current-dir.rs @@ -1,6 +1,7 @@ // run-pass // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Needs directory creation privilege use std::env; use std::fs; diff --git a/src/test/ui/issues/issue-30490.rs b/src/test/ui/issues/issue-30490.rs index 47c17e362ae0b..68d9c4de4d1bf 100644 --- a/src/test/ui/issues/issue-30490.rs +++ b/src/test/ui/issues/issue-30490.rs @@ -1,6 +1,7 @@ // run-pass // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Child I/O swaps not privileged // Previously libstd would set stdio descriptors of a child process // by `dup`ing the requested descriptors to inherit directly into the diff --git a/src/test/ui/process/process-spawn-with-unicode-params.rs b/src/test/ui/process/process-spawn-with-unicode-params.rs index 6e9229b62936c..16dba6292db98 100644 --- a/src/test/ui/process/process-spawn-with-unicode-params.rs +++ b/src/test/ui/process/process-spawn-with-unicode-params.rs @@ -9,6 +9,7 @@ // ignore-emscripten no processes // ignore-sgx no processes +// ignore-fuchsia Filesystem manipulation privileged use std::io::prelude::*; use std::io; diff --git a/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs b/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs index ff62d84925f2b..02fee1a00da6d 100644 --- a/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs +++ b/src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs @@ -1,4 +1,5 @@ // run-pass +// ignore-fuchsia Test must be run out-of-process #![feature(test)] diff --git a/src/test/ui/test-attrs/test-thread-capture.rs b/src/test/ui/test-attrs/test-thread-capture.rs index edc972837a3f7..53acca34133a4 100644 --- a/src/test/ui/test-attrs/test-thread-capture.rs +++ b/src/test/ui/test-attrs/test-thread-capture.rs @@ -5,6 +5,7 @@ // exec-env:RUST_BACKTRACE=0 // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support +// needs-unwind #[test] fn thready_pass() { diff --git a/src/test/ui/test-attrs/test-thread-capture.run.stdout b/src/test/ui/test-attrs/test-thread-capture.run.stdout index 487cfb55eb473..c712a78afb0f1 100644 --- a/src/test/ui/test-attrs/test-thread-capture.run.stdout +++ b/src/test/ui/test-attrs/test-thread-capture.run.stdout @@ -10,7 +10,7 @@ fee fie foe fum -thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:31:5 +thread 'main' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/test-attrs/test-thread-nocapture.rs b/src/test/ui/test-attrs/test-thread-nocapture.rs index 8e8e9bbfdf0ed..2b57eb8aae19d 100644 --- a/src/test/ui/test-attrs/test-thread-nocapture.rs +++ b/src/test/ui/test-attrs/test-thread-nocapture.rs @@ -5,6 +5,7 @@ // exec-env:RUST_BACKTRACE=0 // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support +// needs-unwind #[test] fn thready_pass() { diff --git a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr index 06495681b3eb2..0a12a052819c9 100644 --- a/src/test/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/src/test/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:31:5 +thread 'main' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/threads-sendsync/sync-send-in-std.rs b/src/test/ui/threads-sendsync/sync-send-in-std.rs index b8ae214dc09b1..6d1fba64e4216 100644 --- a/src/test/ui/threads-sendsync/sync-send-in-std.rs +++ b/src/test/ui/threads-sendsync/sync-send-in-std.rs @@ -2,6 +2,7 @@ // ignore-wasm32-bare networking not available // ignore-sgx ToSocketAddrs cannot be used for DNS Resolution +// ignore-fuchsia Req. test-harness networking privileges use std::net::ToSocketAddrs; From 48c85c5c79cd693e4e6933a126e1576fb59ab9bb Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 11 Oct 2022 16:17:59 +0000 Subject: [PATCH 02/18] Filtering spans --- compiler/rustc_errors/src/json.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 4cc7be47fc2c6..2093a1a7ca28b 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -319,7 +319,7 @@ impl Diagnostic { message: translated_message.to_string(), code: None, level: "help", - spans: DiagnosticSpan::from_suggestion(sugg, &args, je), + spans: Self::filter_empty_spans_with_no_replacement(DiagnosticSpan::from_suggestion(sugg, &args, je)), children: vec![], rendered: None, } @@ -372,6 +372,12 @@ impl Diagnostic { } } + fn filter_empty_spans_with_no_replacement(spans: Vec) -> Vec { + spans.into_iter() + .filter(|span| !(span.byte_start == span.byte_end && span.suggested_replacement == Some(String::new()))) + .collect() + } + fn from_sub_diagnostic( diag: &SubDiagnostic, args: &FluentArgs<'_>, From c87dc6d114e1c08828351ed80cc3fb2208ed7c44 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 11 Oct 2022 17:47:07 +0000 Subject: [PATCH 03/18] Running the formatter --- compiler/rustc_errors/src/json.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 2093a1a7ca28b..0c2b7f8704c77 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -319,7 +319,9 @@ impl Diagnostic { message: translated_message.to_string(), code: None, level: "help", - spans: Self::filter_empty_spans_with_no_replacement(DiagnosticSpan::from_suggestion(sugg, &args, je)), + spans: Self::filter_empty_spans_with_no_replacement( + DiagnosticSpan::from_suggestion(sugg, &args, je), + ), children: vec![], rendered: None, } @@ -373,8 +375,12 @@ impl Diagnostic { } fn filter_empty_spans_with_no_replacement(spans: Vec) -> Vec { - spans.into_iter() - .filter(|span| !(span.byte_start == span.byte_end && span.suggested_replacement == Some(String::new()))) + spans + .into_iter() + .filter(|span| { + !(span.byte_start == span.byte_end + && span.suggested_replacement == Some(String::new())) + }) .collect() } From 2db95d06f444e57d3e6735047f41dd6239f3bbae Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 11 Oct 2022 18:39:12 +0000 Subject: [PATCH 04/18] Revert "Running the formatter" This reverts commit dab560ffcf1b97a60748bc8ebfebee204df3f0bc. --- compiler/rustc_errors/src/json.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 0c2b7f8704c77..2093a1a7ca28b 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -319,9 +319,7 @@ impl Diagnostic { message: translated_message.to_string(), code: None, level: "help", - spans: Self::filter_empty_spans_with_no_replacement( - DiagnosticSpan::from_suggestion(sugg, &args, je), - ), + spans: Self::filter_empty_spans_with_no_replacement(DiagnosticSpan::from_suggestion(sugg, &args, je)), children: vec![], rendered: None, } @@ -375,12 +373,8 @@ impl Diagnostic { } fn filter_empty_spans_with_no_replacement(spans: Vec) -> Vec { - spans - .into_iter() - .filter(|span| { - !(span.byte_start == span.byte_end - && span.suggested_replacement == Some(String::new())) - }) + spans.into_iter() + .filter(|span| !(span.byte_start == span.byte_end && span.suggested_replacement == Some(String::new()))) .collect() } From 795a4fd5c6ae19d9a577186bbad7557409573636 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 11 Oct 2022 18:39:26 +0000 Subject: [PATCH 05/18] Revert "Filtering spans" This reverts commit d652f0ea588ecdf96d31a86fcc9aaa5f78f734a2. --- compiler/rustc_errors/src/json.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 2093a1a7ca28b..4cc7be47fc2c6 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -319,7 +319,7 @@ impl Diagnostic { message: translated_message.to_string(), code: None, level: "help", - spans: Self::filter_empty_spans_with_no_replacement(DiagnosticSpan::from_suggestion(sugg, &args, je)), + spans: DiagnosticSpan::from_suggestion(sugg, &args, je), children: vec![], rendered: None, } @@ -372,12 +372,6 @@ impl Diagnostic { } } - fn filter_empty_spans_with_no_replacement(spans: Vec) -> Vec { - spans.into_iter() - .filter(|span| !(span.byte_start == span.byte_end && span.suggested_replacement == Some(String::new()))) - .collect() - } - fn from_sub_diagnostic( diag: &SubDiagnostic, args: &FluentArgs<'_>, From da10a05330b1e71d437a956360c70492f1b75ffb Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Tue, 11 Oct 2022 20:26:24 +0000 Subject: [PATCH 06/18] Addressing feedback --- compiler/rustc_errors/src/diagnostic.rs | 25 +++++++++++++++++++ .../rustc_hir_analysis/src/astconv/mod.rs | 25 +++++++++++-------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 518c59dba5366..493760942680c 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -567,6 +567,11 @@ impl Diagnostic { style: SuggestionStyle, ) -> &mut Self { assert!(!suggestion.is_empty()); + debug_assert!( + !(suggestion.iter().any(|(sp, text)| sp.lo() == sp.hi() && text.is_empty())), + "Span must not be empty and have no suggestion" + ); + self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { parts: suggestion @@ -644,6 +649,10 @@ impl Diagnostic { applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { + debug_assert!( + !(sp.lo() == sp.hi() && suggestion.to_string().is_empty()), + "Span must not be empty and have no suggestion" + ); self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }], @@ -684,6 +693,12 @@ impl Diagnostic { ) -> &mut Self { let mut suggestions: Vec<_> = suggestions.collect(); suggestions.sort(); + + debug_assert!( + !(sp.lo() == sp.hi() && suggestions.iter().any(|suggestion| suggestion.is_empty())), + "Span must not be empty and have no suggestion" + ); + let substitutions = suggestions .into_iter() .map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] }) @@ -705,8 +720,18 @@ impl Diagnostic { suggestions: impl Iterator>, applicability: Applicability, ) -> &mut Self { + let suggestions: Vec<_> = suggestions.collect(); + debug_assert!( + !(suggestions + .iter() + .flat_map(|suggs| suggs) + .any(|(sp, suggestion)| sp.lo() == sp.hi() && suggestion.is_empty())), + "Span must not be empty and have no suggestion" + ); + self.push_suggestion(CodeSuggestion { substitutions: suggestions + .into_iter() .map(|sugg| Substitution { parts: sugg .into_iter() diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 6e373e41b4c02..a8f70ba2b3780 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -3051,24 +3051,27 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .map_or(false, |s| s.trim_end().ends_with('<')); let is_global = poly_trait_ref.trait_ref.path.is_global(); - let sugg = Vec::from_iter([ - ( - self_ty.span.shrink_to_lo(), - format!( - "{}dyn {}", - if needs_bracket { "<" } else { "" }, - if is_global { "(" } else { "" }, - ), + + let mut sugg = Vec::from_iter([( + self_ty.span.shrink_to_lo(), + format!( + "{}dyn {}", + if needs_bracket { "<" } else { "" }, + if is_global { "(" } else { "" }, ), - ( + )]); + + if is_global || needs_bracket { + sugg.push(( self_ty.span.shrink_to_hi(), format!( "{}{}", if is_global { ")" } else { "" }, if needs_bracket { ">" } else { "" }, ), - ), - ]); + )); + } + if self_ty.span.edition() >= Edition::Edition2021 { let msg = "trait objects must include the `dyn` keyword"; let label = "add `dyn` keyword before this trait"; From 1d970c3a99d37f1f1f93ef67020d0206820555cb Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Wed, 12 Oct 2022 19:42:10 +0000 Subject: [PATCH 07/18] Using the `is_empty` method of a span --- compiler/rustc_errors/src/diagnostic.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 493760942680c..a63fc0ca285da 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -568,7 +568,7 @@ impl Diagnostic { ) -> &mut Self { assert!(!suggestion.is_empty()); debug_assert!( - !(suggestion.iter().any(|(sp, text)| sp.lo() == sp.hi() && text.is_empty())), + !(suggestion.iter().any(|(sp, text)| sp.is_empty() && text.is_empty())), "Span must not be empty and have no suggestion" ); @@ -650,7 +650,7 @@ impl Diagnostic { style: SuggestionStyle, ) -> &mut Self { debug_assert!( - !(sp.lo() == sp.hi() && suggestion.to_string().is_empty()), + !(sp.is_empty() && suggestion.to_string().is_empty()), "Span must not be empty and have no suggestion" ); self.push_suggestion(CodeSuggestion { @@ -695,7 +695,7 @@ impl Diagnostic { suggestions.sort(); debug_assert!( - !(sp.lo() == sp.hi() && suggestions.iter().any(|suggestion| suggestion.is_empty())), + !(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())), "Span must not be empty and have no suggestion" ); @@ -725,7 +725,7 @@ impl Diagnostic { !(suggestions .iter() .flat_map(|suggs| suggs) - .any(|(sp, suggestion)| sp.lo() == sp.hi() && suggestion.is_empty())), + .any(|(sp, suggestion)| sp.is_empty() && suggestion.is_empty())), "Span must not be empty and have no suggestion" ); From 8fbd19dd2d0e558dfdb74ea909a45bc689e56b20 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Wed, 12 Oct 2022 20:59:10 +0000 Subject: [PATCH 08/18] Removing one suggestion --- compiler/rustc_parse/src/parser/diagnostics.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 828b7d2f2f7be..04efa0ee798b3 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1320,16 +1320,15 @@ impl<'a> Parser<'a> { IsStandalone::Maybe => { let Ok(base_src) = self.span_to_snippet(base.span) else { return help_base_case(err, base) }; - let sugg1 = match kind.fixity { + let sugg = match kind.fixity { UnaryFixity::Pre => self.prefix_inc_dec_suggest(base_src, kind, spans), UnaryFixity::Post => self.postfix_inc_dec_suggest(base_src, kind, spans), }; - let sugg2 = self.inc_dec_standalone_suggest(kind, spans); MultiSugg::emit_many( &mut err, "use `+= 1` instead", Applicability::Unspecified, - [sugg1, sugg2].into_iter(), + [sugg].into_iter(), ) } } From fe3f76cd2365eee4e4a4e7b07101fa2fa9d0b484 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Wed, 12 Oct 2022 21:18:24 +0000 Subject: [PATCH 09/18] Fixing suggestions --- compiler/rustc_expand/src/base.rs | 2 +- src/test/ui/macros/issue-86865.stderr | 8 ++------ src/test/ui/parser/increment-notfixed.stderr | 12 ------------ 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index cd8a525e062c5..a58f48de3fc5e 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1229,7 +1229,7 @@ pub fn expr_to_spanned_string<'a>( ast::LitKind::ByteStr(_) => { let mut err = cx.struct_span_err(l.span, err_msg); err.span_suggestion( - expr.span.shrink_to_lo(), + expr.span, "consider removing the leading `b`", "", Applicability::MaybeIncorrect, diff --git a/src/test/ui/macros/issue-86865.stderr b/src/test/ui/macros/issue-86865.stderr index eed755366311b..a05ec5f4c4266 100644 --- a/src/test/ui/macros/issue-86865.stderr +++ b/src/test/ui/macros/issue-86865.stderr @@ -2,17 +2,13 @@ error: format argument must be a string literal --> $DIR/issue-86865.rs:4:14 | LL | println!(b"foo"); - | -^^^^^ - | | - | help: consider removing the leading `b` + | ^^^^^^ help: consider removing the leading `b` error: format argument must be a string literal --> $DIR/issue-86865.rs:8:15 | LL | write!(s, b"foo{}", "bar"); - | -^^^^^^^ - | | - | help: consider removing the leading `b` + | ^^^^^^^^ help: consider removing the leading `b` error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/increment-notfixed.stderr b/src/test/ui/parser/increment-notfixed.stderr index ae55ae0671431..bba88ce85256a 100644 --- a/src/test/ui/parser/increment-notfixed.stderr +++ b/src/test/ui/parser/increment-notfixed.stderr @@ -8,8 +8,6 @@ help: use `+= 1` instead | LL | { let tmp = i; i += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~ -LL | i += 1; - | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:17:12 @@ -23,8 +21,6 @@ help: use `+= 1` instead | LL | while { let tmp = i; i += 1; tmp } < 5 { | +++++++++++ ~~~~~~~~~~~~~~~ -LL | while i += 1 < 5 { - | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:25:8 @@ -36,8 +32,6 @@ help: use `+= 1` instead | LL | { let tmp_ = tmp; tmp += 1; tmp_ }; | ++++++++++++ ~~~~~~~~~~~~~~~~~~ -LL | tmp += 1; - | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:31:14 @@ -51,8 +45,6 @@ help: use `+= 1` instead | LL | while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 { | ++++++++++++ ~~~~~~~~~~~~~~~~~~ -LL | while tmp += 1 < 5 { - | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:39:16 @@ -64,8 +56,6 @@ help: use `+= 1` instead | LL | { let tmp = foo.bar.qux; foo.bar.qux += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ -LL | foo.bar.qux += 1; - | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:49:10 @@ -77,8 +67,6 @@ help: use `+= 1` instead | LL | { let tmp = s.tmp; s.tmp += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~~~~~ -LL | s.tmp += 1; - | ~~~~ error: Rust has no prefix increment operator --> $DIR/increment-notfixed.rs:56:5 From 17e3b7312941697525996363a1aa472f0fd8ca57 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sat, 15 Oct 2022 12:40:32 +0000 Subject: [PATCH 10/18] Revert "Removing one suggestion" This reverts commit 8fbd19dd2d0e558dfdb74ea909a45bc689e56b20. --- compiler/rustc_parse/src/parser/diagnostics.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 04efa0ee798b3..828b7d2f2f7be 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1320,15 +1320,16 @@ impl<'a> Parser<'a> { IsStandalone::Maybe => { let Ok(base_src) = self.span_to_snippet(base.span) else { return help_base_case(err, base) }; - let sugg = match kind.fixity { + let sugg1 = match kind.fixity { UnaryFixity::Pre => self.prefix_inc_dec_suggest(base_src, kind, spans), UnaryFixity::Post => self.postfix_inc_dec_suggest(base_src, kind, spans), }; + let sugg2 = self.inc_dec_standalone_suggest(kind, spans); MultiSugg::emit_many( &mut err, "use `+= 1` instead", Applicability::Unspecified, - [sugg].into_iter(), + [sugg1, sugg2].into_iter(), ) } } From 40424689ce3f9b126e98fff8bb0efffdcdb7acaf Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sat, 15 Oct 2022 13:05:29 +0000 Subject: [PATCH 11/18] Adding only suggestion when span not empty --- compiler/rustc_parse/src/parser/diagnostics.rs | 10 +++++++++- src/test/ui/parser/increment-notfixed.stderr | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 828b7d2f2f7be..77ec0d34a1386 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1374,9 +1374,17 @@ impl<'a> Parser<'a> { kind: IncDecRecovery, (pre_span, post_span): (Span, Span), ) -> MultiSugg { + let mut patches = Vec::new(); + + if !pre_span.is_empty() { + patches.push((pre_span, String::new())); + } + + patches.push((post_span, format!(" {}= 1", kind.op.chr()))); + MultiSugg { msg: format!("use `{}= 1` instead", kind.op.chr()), - patches: vec![(pre_span, String::new()), (post_span, format!(" {}= 1", kind.op.chr()))], + patches, applicability: Applicability::MachineApplicable, } } diff --git a/src/test/ui/parser/increment-notfixed.stderr b/src/test/ui/parser/increment-notfixed.stderr index bba88ce85256a..ae55ae0671431 100644 --- a/src/test/ui/parser/increment-notfixed.stderr +++ b/src/test/ui/parser/increment-notfixed.stderr @@ -8,6 +8,8 @@ help: use `+= 1` instead | LL | { let tmp = i; i += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~ +LL | i += 1; + | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:17:12 @@ -21,6 +23,8 @@ help: use `+= 1` instead | LL | while { let tmp = i; i += 1; tmp } < 5 { | +++++++++++ ~~~~~~~~~~~~~~~ +LL | while i += 1 < 5 { + | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:25:8 @@ -32,6 +36,8 @@ help: use `+= 1` instead | LL | { let tmp_ = tmp; tmp += 1; tmp_ }; | ++++++++++++ ~~~~~~~~~~~~~~~~~~ +LL | tmp += 1; + | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:31:14 @@ -45,6 +51,8 @@ help: use `+= 1` instead | LL | while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 { | ++++++++++++ ~~~~~~~~~~~~~~~~~~ +LL | while tmp += 1 < 5 { + | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:39:16 @@ -56,6 +64,8 @@ help: use `+= 1` instead | LL | { let tmp = foo.bar.qux; foo.bar.qux += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | foo.bar.qux += 1; + | ~~~~ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:49:10 @@ -67,6 +77,8 @@ help: use `+= 1` instead | LL | { let tmp = s.tmp; s.tmp += 1; tmp }; | +++++++++++ ~~~~~~~~~~~~~~~~~~~ +LL | s.tmp += 1; + | ~~~~ error: Rust has no prefix increment operator --> $DIR/increment-notfixed.rs:56:5 From 88c3a203b6dfb011e30bd4939ed945a66a6c9848 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sat, 15 Oct 2022 13:55:15 +0000 Subject: [PATCH 12/18] Fixing span by extending it to the first character --- compiler/rustc_expand/src/base.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index a58f48de3fc5e..052ca229f0127 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -22,7 +22,7 @@ use rustc_span::edition::Edition; use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId}; use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{FileName, Span, DUMMY_SP}; +use rustc_span::{BytePos, FileName, Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; use std::default::Default; @@ -1228,8 +1228,9 @@ pub fn expr_to_spanned_string<'a>( ast::LitKind::Str(s, style) => return Ok((s, style, expr.span)), ast::LitKind::ByteStr(_) => { let mut err = cx.struct_span_err(l.span, err_msg); + let span = expr.span.shrink_to_lo(); err.span_suggestion( - expr.span, + span.with_hi(span.lo() + BytePos(1)), "consider removing the leading `b`", "", Applicability::MaybeIncorrect, From 3e2e0eadc02906ab703a00838ee2bf02f36e4cf5 Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sat, 15 Oct 2022 13:57:02 +0000 Subject: [PATCH 13/18] Running fmt --- compiler/rustc_parse/src/parser/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 77ec0d34a1386..7e11ca57cebda 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1377,7 +1377,7 @@ impl<'a> Parser<'a> { let mut patches = Vec::new(); if !pre_span.is_empty() { - patches.push((pre_span, String::new())); + patches.push((pre_span, String::new())); } patches.push((post_span, format!(" {}= 1", kind.op.chr()))); From 9e2c2a52db3d2fad310a8ae0aceb8d6e056b7bbb Mon Sep 17 00:00:00 2001 From: Kevin Per Date: Sat, 15 Oct 2022 14:06:53 +0000 Subject: [PATCH 14/18] Updating .stderr --- src/test/ui/macros/issue-86865.stderr | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/ui/macros/issue-86865.stderr b/src/test/ui/macros/issue-86865.stderr index a05ec5f4c4266..eed755366311b 100644 --- a/src/test/ui/macros/issue-86865.stderr +++ b/src/test/ui/macros/issue-86865.stderr @@ -2,13 +2,17 @@ error: format argument must be a string literal --> $DIR/issue-86865.rs:4:14 | LL | println!(b"foo"); - | ^^^^^^ help: consider removing the leading `b` + | -^^^^^ + | | + | help: consider removing the leading `b` error: format argument must be a string literal --> $DIR/issue-86865.rs:8:15 | LL | write!(s, b"foo{}", "bar"); - | ^^^^^^^^ help: consider removing the leading `b` + | -^^^^^^^ + | | + | help: consider removing the leading `b` error: aborting due to 2 previous errors From 684df4d24ec605a07f1a5789c1d0027d4887103c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 17 Oct 2022 12:04:16 +0200 Subject: [PATCH 15/18] Make diagnostic for unsatisfied Termination bounds more precise --- compiler/rustc_span/src/symbol.rs | 1 + .../traits/error_reporting/on_unimplemented.rs | 4 ++++ library/std/src/process.rs | 12 ++++++++++-- .../issue-103052-1.rs | 11 +++++++++++ .../issue-103052-1.stderr | 17 +++++++++++++++++ .../issue-103052-2.rs | 18 ++++++++++++++++++ .../issue-103052-2.stderr | 15 +++++++++++++++ .../termination-trait-test-wrong-type.stderr | 5 ++--- 8 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr create mode 100644 src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c6711b603b683..3fe79370c374d 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -451,6 +451,7 @@ symbols! { call_once, caller_location, capture_disjoint_fields, + cause, cdylib, ceilf32, ceilf64, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 0f20e02d6ecc9..5eef54c6330db 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -164,6 +164,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { flags.push((sym::from_desugaring, Some(format!("{:?}", k)))); } + if let ObligationCauseCode::MainFunctionType = obligation.cause.code() { + flags.push((sym::cause, Some("MainFunctionType".to_string()))); + } + // Add all types without trimmed paths. ty::print::with_no_trimmed_paths!({ let generics = self.tcx.generics_of(def_id); diff --git a/library/std/src/process.rs b/library/std/src/process.rs index b8249a027ad99..400d25beb26f3 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2154,8 +2154,16 @@ pub fn id() -> u32 { #[cfg_attr(not(test), lang = "termination")] #[stable(feature = "termination_trait_lib", since = "1.61.0")] #[rustc_on_unimplemented( - message = "`main` has invalid return type `{Self}`", - label = "`main` can only return types that implement `{Termination}`" + on( + all(not(bootstrap), cause = "MainFunctionType"), + message = "`main` has invalid return type `{Self}`", + label = "`main` can only return types that implement `{Termination}`" + ), + on( + bootstrap, + message = "`main` has invalid return type `{Self}`", + label = "`main` can only return types that implement `{Termination}`" + ) )] pub trait Termination { /// Is called to get the representation of the value as status code. diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs new file mode 100644 index 0000000000000..a75c91cc90df7 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.rs @@ -0,0 +1,11 @@ +// Check that we don't blindly emit a diagnostic claiming that "`main` has an invalid return type" +// if we encounter a type that doesn't implement `std::process::Termination` and is not actually +// the return type of the program entry `main`. + +fn receive(_: impl std::process::Termination) {} + +struct Something; + +fn main() { + receive(Something); //~ ERROR the trait bound `Something: Termination` is not satisfied +} diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr new file mode 100644 index 0000000000000..409dede1a90ac --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-1.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-1.rs:10:13 + | +LL | receive(Something); + | ------- ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | | + | required by a bound introduced by this call + | +note: required by a bound in `receive` + --> $DIR/issue-103052-1.rs:5:20 + | +LL | fn receive(_: impl std::process::Termination) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `receive` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs new file mode 100644 index 0000000000000..fa9182b6deeb7 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.rs @@ -0,0 +1,18 @@ +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +mod child { + trait Main { + fn main() -> impl std::process::Termination; + } + + struct Something; + + impl Main for () { + fn main() -> Something { //~ ERROR the trait bound `Something: Termination` is not satisfied + Something + } + } +} + +fn main() {} diff --git a/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr new file mode 100644 index 0000000000000..a700c72ea689f --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/issue-103052-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:12:22 + | +LL | fn main() -> Something { + | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | +note: required by a bound in `Main::main::{opaque#0}` + --> $DIR/issue-103052-2.rs:6:27 + | +LL | fn main() -> impl std::process::Termination; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 7c1390cdc6446..6ee32314607ad 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,4 +1,4 @@ -error[E0277]: `main` has invalid return type `f32` +error[E0277]: the trait bound `f32: Termination` is not satisfied --> $DIR/termination-trait-test-wrong-type.rs:6:1 | LL | #[test] @@ -6,9 +6,8 @@ LL | #[test] LL | / fn can_parse_zero_as_f32() -> Result { LL | | "0".parse() LL | | } - | |_^ `main` can only return types that implement `Termination` + | |_^ the trait `Termination` is not implemented for `f32` | - = help: the trait `Termination` is not implemented for `f32` = note: required for `Result` to implement `Termination` note: required by a bound in `assert_test_result` --> $SRC_DIR/test/src/lib.rs:LL:COL From 9a7e527e28448fcfe589ef4ce9c3d753382a6f20 Mon Sep 17 00:00:00 2001 From: Sky Date: Mon, 17 Oct 2022 13:14:15 -0400 Subject: [PATCH 16/18] Fix typo in `ReverseSearcher` docs --- library/core/src/str/pattern.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index 031fb8e8b21fb..ec2cb429e67bf 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -267,7 +267,7 @@ pub unsafe trait Searcher<'a> { /// The index ranges returned by this trait are not required /// to exactly match those of the forward search in reverse. /// -/// For the reason why this trait is marked unsafe, see them +/// For the reason why this trait is marked unsafe, see the /// parent trait [`Searcher`]. pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { /// Performs the next search step starting from the back. From d7fd1d57ec90d43aee3caee75a9663914ccc1400 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 17 Oct 2022 11:21:50 -0700 Subject: [PATCH 17/18] Remove the redundant `Some(try_opt!(..))` in `checked_pow` The final return value doesn't need to be tried at all -- we can just return the checked option directly. The optimizer can probably figure this out anyway, but there's no need to make it work here. --- library/core/src/num/int_macros.rs | 2 +- library/core/src/num/uint_macros.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index b413a85fee340..81f050cb283d4 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -869,7 +869,7 @@ macro_rules! int_impl { // Deal with the final bit of the exponent separately, since // squaring the base afterwards is not necessary and may cause a // needless overflow. - Some(try_opt!(acc.checked_mul(base))) + acc.checked_mul(base) } /// Saturating integer addition. Computes `self + rhs`, saturating at the numeric diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index b177e5e390028..f186b468e64cb 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -990,7 +990,7 @@ macro_rules! uint_impl { // squaring the base afterwards is not necessary and may cause a // needless overflow. - Some(try_opt!(acc.checked_mul(base))) + acc.checked_mul(base) } /// Saturating integer addition. Computes `self + rhs`, saturating at From 430bd6200dd290497423c5f3a1f9ee4e9bd35d67 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Mon, 17 Oct 2022 22:38:37 +0100 Subject: [PATCH 18/18] Stabilize asm_sym --- compiler/rustc_ast_lowering/src/asm.rs | 10 ------- compiler/rustc_codegen_gcc/tests/run/asm.rs | 9 ++++--- compiler/rustc_feature/src/accepted.rs | 2 ++ compiler/rustc_feature/src/active.rs | 2 -- .../src/language-features/asm-sym.md | 13 ---------- src/test/assembly/asm/aarch64-types.rs | 2 +- src/test/assembly/asm/arm-types.rs | 2 +- src/test/assembly/asm/avr-types.rs | 2 +- src/test/assembly/asm/bpf-types.rs | 2 +- src/test/assembly/asm/global_asm.rs | 6 +++-- src/test/assembly/asm/hexagon-types.rs | 2 +- src/test/assembly/asm/mips-types.rs | 2 +- src/test/assembly/asm/msp430-types.rs | 2 +- src/test/assembly/asm/nvptx-types.rs | 2 +- src/test/assembly/asm/powerpc-types.rs | 2 +- src/test/assembly/asm/riscv-types.rs | 2 +- src/test/assembly/asm/s390x-types.rs | 2 +- src/test/assembly/asm/wasm-types.rs | 2 +- src/test/assembly/asm/x86-types.rs | 2 +- src/test/ui/abi/abi-sysv64-register-usage.rs | 26 +++++++++++++------ src/test/ui/asm/aarch64/bad-reg.rs | 2 +- src/test/ui/asm/aarch64/may_unwind.rs | 2 +- src/test/ui/asm/aarch64/sym.rs | 2 +- src/test/ui/asm/aarch64/type-check-2-2.rs | 2 +- src/test/ui/asm/aarch64/type-check-2.rs | 2 +- src/test/ui/asm/generic-const.rs | 2 +- src/test/ui/asm/naked-functions.rs | 2 +- src/test/ui/asm/type-check-1.rs | 2 +- src/test/ui/asm/x86_64/bad-reg.rs | 2 +- src/test/ui/asm/x86_64/issue-96797.rs | 2 -- src/test/ui/asm/x86_64/may_unwind.rs | 2 +- .../ui/asm/x86_64/multiple-clobber-abi.rs | 2 -- src/test/ui/asm/x86_64/sym.rs | 2 +- src/test/ui/asm/x86_64/type-check-2.rs | 2 +- src/test/ui/asm/x86_64/type-check-4.rs | 5 ++-- src/test/ui/asm/x86_64/type-check-4.stderr | 6 ++--- src/test/ui/asm/x86_64/type-check-5.rs | 2 +- .../ui/feature-gates/feature-gate-asm_sym.rs | 19 -------------- .../feature-gates/feature-gate-asm_sym.stderr | 21 --------------- 39 files changed, 61 insertions(+), 114 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/asm-sym.md delete mode 100644 src/test/ui/feature-gates/feature-gate-asm_sym.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-asm_sym.stderr diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index 54c83fb760460..450cdf246b150 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -192,16 +192,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } InlineAsmOperand::Sym { ref sym } => { - if !self.tcx.features().asm_sym { - feature_err( - &sess.parse_sess, - sym::asm_sym, - *op_sp, - "sym operands for inline assembly are unstable", - ) - .emit(); - } - let static_def_id = self .resolver .get_partial_res(sym.id) diff --git a/compiler/rustc_codegen_gcc/tests/run/asm.rs b/compiler/rustc_codegen_gcc/tests/run/asm.rs index 46abbb553bf2f..38c1eac7adf69 100644 --- a/compiler/rustc_codegen_gcc/tests/run/asm.rs +++ b/compiler/rustc_codegen_gcc/tests/run/asm.rs @@ -3,11 +3,12 @@ // Run-time: // status: 0 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::{asm, global_asm}; -global_asm!(" +global_asm!( + " .global add_asm add_asm: mov rax, rdi @@ -132,7 +133,9 @@ fn main() { assert_eq!(x, 43); // check sym fn - extern "C" fn foo() -> u64 { 42 } + extern "C" fn foo() -> u64 { + 42 + } let x: u64; unsafe { asm!("call {}", sym foo, lateout("rax") x); diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index ca12659695feb..54bf5a2c34b82 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -53,6 +53,8 @@ declare_features! ( (accepted, abi_sysv64, "1.24.0", Some(36167), None), /// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`. (accepted, adx_target_feature, "1.61.0", Some(44839), None), + /// Allows using `sym` operands in inline assembly. + (accepted, asm_sym, "CURRENT_RUSTC_VERSION", Some(93333), None), /// Allows the definition of associated constants in `trait` or `impl` blocks. (accepted, associated_consts, "1.20.0", Some(29646), None), /// Allows using associated `type`s in `trait`s. diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 5ea433e6b3d3e..1b8d683b13361 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -300,8 +300,6 @@ declare_features! ( (active, asm_const, "1.58.0", Some(93332), None), /// Enables experimental inline assembly support for additional architectures. (active, asm_experimental_arch, "1.58.0", Some(93335), None), - /// Allows using `sym` operands in inline assembly. - (active, asm_sym, "1.58.0", Some(93333), None), /// Allows the `may_unwind` option in inline assembly. (active, asm_unwind, "1.58.0", Some(93334), None), /// Allows users to enforce equality of associated constants `TraitImpl`. diff --git a/src/doc/unstable-book/src/language-features/asm-sym.md b/src/doc/unstable-book/src/language-features/asm-sym.md deleted file mode 100644 index 103d91caf4ccd..0000000000000 --- a/src/doc/unstable-book/src/language-features/asm-sym.md +++ /dev/null @@ -1,13 +0,0 @@ -# `asm_sym` - -The tracking issue for this feature is: [#93333] - -[#93333]: https://github.com/rust-lang/rust/issues/93333 - ------------------------- - -This feature adds a `sym ` operand type to `asm!` and `global_asm!`. -- `` must refer to a `fn` or `static`. -- A mangled symbol name referring to the item is substituted into the asm template string. -- The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc). -- `` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data. diff --git a/src/test/assembly/asm/aarch64-types.rs b/src/test/assembly/asm/aarch64-types.rs index 04b5f4aed9bb5..66c39a48c6e1d 100644 --- a/src/test/assembly/asm/aarch64-types.rs +++ b/src/test/assembly/asm/aarch64-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target aarch64-unknown-linux-gnu // needs-llvm-components: aarch64 -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/arm-types.rs b/src/test/assembly/asm/arm-types.rs index 5ac1af6afd67d..b22a26ce36f14 100644 --- a/src/test/assembly/asm/arm-types.rs +++ b/src/test/assembly/asm/arm-types.rs @@ -3,7 +3,7 @@ // compile-flags: -C target-feature=+neon // needs-llvm-components: arm -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/avr-types.rs b/src/test/assembly/asm/avr-types.rs index 58bf1ad9e35eb..b2d11a8826f6b 100644 --- a/src/test/assembly/asm/avr-types.rs +++ b/src/test/assembly/asm/avr-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target avr-unknown-gnu-atmega328 // needs-llvm-components: avr -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(non_camel_case_types)] diff --git a/src/test/assembly/asm/bpf-types.rs b/src/test/assembly/asm/bpf-types.rs index f894644cc20ee..e177b8d0dbe50 100644 --- a/src/test/assembly/asm/bpf-types.rs +++ b/src/test/assembly/asm/bpf-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target bpfel-unknown-none -C target_feature=+alu32 // needs-llvm-components: bpf -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/global_asm.rs b/src/test/assembly/asm/global_asm.rs index 4cf73b40faf0b..0b361a7ed963d 100644 --- a/src/test/assembly/asm/global_asm.rs +++ b/src/test/assembly/asm/global_asm.rs @@ -4,7 +4,7 @@ // compile-flags: -C llvm-args=--x86-asm-syntax=intel // compile-flags: -C symbol-mangling-version=v0 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] #![crate_type = "rlib"] use std::arch::global_asm; @@ -28,4 +28,6 @@ global_asm!("lea rax, [rip + {}]", sym MY_STATIC); // CHECK: call _RNvCsiubXh4Yz005_10global_asm6foobar global_asm!("call {}", sym foobar); // CHECK: _RNvCsiubXh4Yz005_10global_asm6foobar: -fn foobar() { loop {} } +fn foobar() { + loop {} +} diff --git a/src/test/assembly/asm/hexagon-types.rs b/src/test/assembly/asm/hexagon-types.rs index eff9a0bb431d4..af16faedbc4a2 100644 --- a/src/test/assembly/asm/hexagon-types.rs +++ b/src/test/assembly/asm/hexagon-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target hexagon-unknown-linux-musl // needs-llvm-components: hexagon -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/mips-types.rs b/src/test/assembly/asm/mips-types.rs index 04bf49a40efbc..6aa28b062db8a 100644 --- a/src/test/assembly/asm/mips-types.rs +++ b/src/test/assembly/asm/mips-types.rs @@ -5,7 +5,7 @@ //[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 //[mips64] needs-llvm-components: mips -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/msp430-types.rs b/src/test/assembly/asm/msp430-types.rs index 4fa2e8081f816..2c73b3b098de4 100644 --- a/src/test/assembly/asm/msp430-types.rs +++ b/src/test/assembly/asm/msp430-types.rs @@ -2,7 +2,7 @@ // compile-flags: --target msp430-none-elf // needs-llvm-components: msp430 -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch, asm_const)] #![crate_type = "rlib"] #![no_core] #![allow(non_camel_case_types)] diff --git a/src/test/assembly/asm/nvptx-types.rs b/src/test/assembly/asm/nvptx-types.rs index 3ebd5b4b89681..c319946b5f5c1 100644 --- a/src/test/assembly/asm/nvptx-types.rs +++ b/src/test/assembly/asm/nvptx-types.rs @@ -3,7 +3,7 @@ // compile-flags: --crate-type cdylib // needs-llvm-components: nvptx -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![no_core] #[rustc_builtin_macro] diff --git a/src/test/assembly/asm/powerpc-types.rs b/src/test/assembly/asm/powerpc-types.rs index 0ca8908497ad7..e27b005206835 100644 --- a/src/test/assembly/asm/powerpc-types.rs +++ b/src/test/assembly/asm/powerpc-types.rs @@ -5,7 +5,7 @@ //[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu //[powerpc64] needs-llvm-components: powerpc -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/riscv-types.rs b/src/test/assembly/asm/riscv-types.rs index 68dc186ea0c76..f18ba294d0cff 100644 --- a/src/test/assembly/asm/riscv-types.rs +++ b/src/test/assembly/asm/riscv-types.rs @@ -6,7 +6,7 @@ //[riscv32] needs-llvm-components: riscv // compile-flags: -C target-feature=+d -#![feature(no_core, lang_items, rustc_attrs, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register)] diff --git a/src/test/assembly/asm/s390x-types.rs b/src/test/assembly/asm/s390x-types.rs index 6a12902a0461f..2fb404dd9b280 100644 --- a/src/test/assembly/asm/s390x-types.rs +++ b/src/test/assembly/asm/s390x-types.rs @@ -3,7 +3,7 @@ //[s390x] compile-flags: --target s390x-unknown-linux-gnu //[s390x] needs-llvm-components: systemz -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/assembly/asm/wasm-types.rs b/src/test/assembly/asm/wasm-types.rs index 3aa128c46ac01..3b1ac1b455ad8 100644 --- a/src/test/assembly/asm/wasm-types.rs +++ b/src/test/assembly/asm/wasm-types.rs @@ -3,7 +3,7 @@ // compile-flags: --crate-type cdylib // needs-llvm-components: webassembly -#![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] #![no_core] #[rustc_builtin_macro] diff --git a/src/test/assembly/asm/x86-types.rs b/src/test/assembly/asm/x86-types.rs index e871535cfdeef..81be79cbaac18 100644 --- a/src/test/assembly/asm/x86-types.rs +++ b/src/test/assembly/asm/x86-types.rs @@ -7,7 +7,7 @@ // compile-flags: -C llvm-args=--x86-asm-syntax=intel // compile-flags: -C target-feature=+avx512bw -#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_sym)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] diff --git a/src/test/ui/abi/abi-sysv64-register-usage.rs b/src/test/ui/abi/abi-sysv64-register-usage.rs index 9404e71d0fe24..39330693677eb 100644 --- a/src/test/ui/abi/abi-sysv64-register-usage.rs +++ b/src/test/ui/abi/abi-sysv64-register-usage.rs @@ -6,20 +6,30 @@ // ignore-arm // ignore-aarch64 // needs-asm-support -#![feature(asm_sym)] #[cfg(target_arch = "x86_64")] -pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64, - rcx: i64, r8 : i64, r9 : i64, - xmm0: f32, xmm1: f32, xmm2: f32, - xmm3: f32, xmm4: f32, xmm5: f32, - xmm6: f32, xmm7: f32) -> i64 { +pub extern "sysv64" fn all_the_registers( + rdi: i64, + rsi: i64, + rdx: i64, + rcx: i64, + r8: i64, + r9: i64, + xmm0: f32, + xmm1: f32, + xmm2: f32, + xmm3: f32, + xmm4: f32, + xmm5: f32, + xmm6: f32, + xmm7: f32, +) -> i64 { assert_eq!(rdi, 1); assert_eq!(rsi, 2); assert_eq!(rdx, 3); assert_eq!(rcx, 4); - assert_eq!(r8, 5); - assert_eq!(r9, 6); + assert_eq!(r8, 5); + assert_eq!(r9, 6); assert_eq!(xmm0, 1.0f32); assert_eq!(xmm1, 2.0f32); assert_eq!(xmm2, 4.0f32); diff --git a/src/test/ui/asm/aarch64/bad-reg.rs b/src/test/ui/asm/aarch64/bad-reg.rs index 2b6a9b71cd506..9ccb8ed676269 100644 --- a/src/test/ui/asm/aarch64/bad-reg.rs +++ b/src/test/ui/asm/aarch64/bad-reg.rs @@ -1,7 +1,7 @@ // only-aarch64 // compile-flags: -C target-feature=+neon -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/aarch64/may_unwind.rs b/src/test/ui/asm/aarch64/may_unwind.rs index dfd891b4212d5..6af8728bbaa96 100644 --- a/src/test/ui/asm/aarch64/may_unwind.rs +++ b/src/test/ui/asm/aarch64/may_unwind.rs @@ -2,7 +2,7 @@ // run-pass // needs-asm-support -#![feature(asm_sym, asm_unwind)] +#![feature(asm_unwind)] use std::arch::asm; use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; diff --git a/src/test/ui/asm/aarch64/sym.rs b/src/test/ui/asm/aarch64/sym.rs index 3f659363cc848..6a6cdb00d5173 100644 --- a/src/test/ui/asm/aarch64/sym.rs +++ b/src/test/ui/asm/aarch64/sym.rs @@ -3,7 +3,7 @@ // needs-asm-support // run-pass -#![feature(thread_local, asm_sym)] +#![feature(thread_local)] use std::arch::asm; diff --git a/src/test/ui/asm/aarch64/type-check-2-2.rs b/src/test/ui/asm/aarch64/type-check-2-2.rs index aa12d4aa4b40c..0ce1f1d8f7f4a 100644 --- a/src/test/ui/asm/aarch64/type-check-2-2.rs +++ b/src/test/ui/asm/aarch64/type-check-2-2.rs @@ -1,6 +1,6 @@ // only-aarch64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/aarch64/type-check-2.rs b/src/test/ui/asm/aarch64/type-check-2.rs index fdafe63c7b07b..1c71c1185d465 100644 --- a/src/test/ui/asm/aarch64/type-check-2.rs +++ b/src/test/ui/asm/aarch64/type-check-2.rs @@ -1,6 +1,6 @@ // only-aarch64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/generic-const.rs b/src/test/ui/asm/generic-const.rs index 55c5587804b32..caa9b7dbce6a8 100644 --- a/src/test/ui/asm/generic-const.rs +++ b/src/test/ui/asm/generic-const.rs @@ -1,7 +1,7 @@ // needs-asm-support // build-pass -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/naked-functions.rs b/src/test/ui/asm/naked-functions.rs index 9e626f5711db4..2f3716ca77f65 100644 --- a/src/test/ui/asm/naked-functions.rs +++ b/src/test/ui/asm/naked-functions.rs @@ -4,7 +4,7 @@ // ignore-wasm32 #![feature(naked_functions)] -#![feature(asm_const, asm_sym, asm_unwind)] +#![feature(asm_const, asm_unwind)] #![crate_type = "lib"] use std::arch::asm; diff --git a/src/test/ui/asm/type-check-1.rs b/src/test/ui/asm/type-check-1.rs index 50b369ae04527..59f7b36afcd89 100644 --- a/src/test/ui/asm/type-check-1.rs +++ b/src/test/ui/asm/type-check-1.rs @@ -3,7 +3,7 @@ // ignore-spirv // ignore-wasm32 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/x86_64/bad-reg.rs b/src/test/ui/asm/x86_64/bad-reg.rs index a4f50a534a158..f5728079a6a56 100644 --- a/src/test/ui/asm/x86_64/bad-reg.rs +++ b/src/test/ui/asm/x86_64/bad-reg.rs @@ -1,7 +1,7 @@ // only-x86_64 // compile-flags: -C target-feature=+avx2 -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::asm; diff --git a/src/test/ui/asm/x86_64/issue-96797.rs b/src/test/ui/asm/x86_64/issue-96797.rs index d3e0906f37aff..954f8c5ccc33d 100644 --- a/src/test/ui/asm/x86_64/issue-96797.rs +++ b/src/test/ui/asm/x86_64/issue-96797.rs @@ -7,8 +7,6 @@ // regression test for #96797 -#![feature(asm_sym)] - use std::arch::global_asm; #[no_mangle] diff --git a/src/test/ui/asm/x86_64/may_unwind.rs b/src/test/ui/asm/x86_64/may_unwind.rs index 2f5d1a360246a..c11f0938d0b6c 100644 --- a/src/test/ui/asm/x86_64/may_unwind.rs +++ b/src/test/ui/asm/x86_64/may_unwind.rs @@ -3,7 +3,7 @@ // needs-asm-support // needs-unwind -#![feature(asm_sym, asm_unwind)] +#![feature(asm_unwind)] use std::arch::asm; use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; diff --git a/src/test/ui/asm/x86_64/multiple-clobber-abi.rs b/src/test/ui/asm/x86_64/multiple-clobber-abi.rs index 513eb270e4f36..06589431a445f 100644 --- a/src/test/ui/asm/x86_64/multiple-clobber-abi.rs +++ b/src/test/ui/asm/x86_64/multiple-clobber-abi.rs @@ -4,8 +4,6 @@ // Checks that multiple clobber_abi options can be used -#![feature(asm_sym)] - use std::arch::asm; extern "sysv64" fn foo(x: i32) -> i32 { diff --git a/src/test/ui/asm/x86_64/sym.rs b/src/test/ui/asm/x86_64/sym.rs index 447e11e6eabca..93ef4f090622e 100644 --- a/src/test/ui/asm/x86_64/sym.rs +++ b/src/test/ui/asm/x86_64/sym.rs @@ -3,7 +3,7 @@ // needs-asm-support // run-pass -#![feature(thread_local, asm_sym)] +#![feature(thread_local)] use std::arch::asm; diff --git a/src/test/ui/asm/x86_64/type-check-2.rs b/src/test/ui/asm/x86_64/type-check-2.rs index 59d8cde3fb6c7..80b29ec870fc1 100644 --- a/src/test/ui/asm/x86_64/type-check-2.rs +++ b/src/test/ui/asm/x86_64/type-check-2.rs @@ -1,6 +1,6 @@ // only-x86_64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::{asm, global_asm}; diff --git a/src/test/ui/asm/x86_64/type-check-4.rs b/src/test/ui/asm/x86_64/type-check-4.rs index da3b76c3d23a6..3d5d3807c530e 100644 --- a/src/test/ui/asm/x86_64/type-check-4.rs +++ b/src/test/ui/asm/x86_64/type-check-4.rs @@ -1,14 +1,13 @@ // only-x86_64 // compile-flags: -C target-feature=+avx512f -#![feature(asm_const, asm_sym)] +#![feature(asm_const)] use std::arch::{asm, global_asm}; use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps}; -fn main() { -} +fn main() {} // Constants must be... constant diff --git a/src/test/ui/asm/x86_64/type-check-4.stderr b/src/test/ui/asm/x86_64/type-check-4.stderr index 33f4638fb4b37..3875bcc211252 100644 --- a/src/test/ui/asm/x86_64/type-check-4.stderr +++ b/src/test/ui/asm/x86_64/type-check-4.stderr @@ -1,5 +1,5 @@ error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:22:25 + --> $DIR/type-check-4.rs:21:25 | LL | global_asm!("{}", const S); | ^ @@ -7,7 +7,7 @@ LL | global_asm!("{}", const S); = help: consider extracting the value of the `static` to a `const`, and referring to that error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:25:35 + --> $DIR/type-check-4.rs:24:35 | LL | global_asm!("{}", const const_foo(S)); | ^ @@ -15,7 +15,7 @@ LL | global_asm!("{}", const const_foo(S)); = help: consider extracting the value of the `static` to a `const`, and referring to that error[E0013]: constants cannot refer to statics - --> $DIR/type-check-4.rs:28:35 + --> $DIR/type-check-4.rs:27:35 | LL | global_asm!("{}", const const_bar(S)); | ^ diff --git a/src/test/ui/asm/x86_64/type-check-5.rs b/src/test/ui/asm/x86_64/type-check-5.rs index 6190e0b52f4e9..8198df91095f9 100644 --- a/src/test/ui/asm/x86_64/type-check-5.rs +++ b/src/test/ui/asm/x86_64/type-check-5.rs @@ -1,6 +1,6 @@ // only-x86_64 -#![feature(repr_simd, never_type, asm_sym)] +#![feature(repr_simd, never_type)] use std::arch::asm; diff --git a/src/test/ui/feature-gates/feature-gate-asm_sym.rs b/src/test/ui/feature-gates/feature-gate-asm_sym.rs deleted file mode 100644 index 0de6b3abb18bb..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-asm_sym.rs +++ /dev/null @@ -1,19 +0,0 @@ -// only-x86_64 - -use std::arch::asm; - -fn bar() {} - -fn foo() { - unsafe { - asm!("mov eax, {}", sym bar::); - //~^ ERROR sym operands for inline assembly are unstable - } -} - -fn main() { - unsafe { - asm!("mov eax, {}", sym foo::<0>); - //~^ ERROR sym operands for inline assembly are unstable - } -} diff --git a/src/test/ui/feature-gates/feature-gate-asm_sym.stderr b/src/test/ui/feature-gates/feature-gate-asm_sym.stderr deleted file mode 100644 index d4b16f60b0b41..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-asm_sym.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: sym operands for inline assembly are unstable - --> $DIR/feature-gate-asm_sym.rs:9:29 - | -LL | asm!("mov eax, {}", sym bar::); - | ^^^^^^^^^^^^ - | - = note: see issue #93333 for more information - = help: add `#![feature(asm_sym)]` to the crate attributes to enable - -error[E0658]: sym operands for inline assembly are unstable - --> $DIR/feature-gate-asm_sym.rs:16:29 - | -LL | asm!("mov eax, {}", sym foo::<0>); - | ^^^^^^^^^^^^ - | - = note: see issue #93333 for more information - = help: add `#![feature(asm_sym)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`.