From 04e8835d026fb4c99edd779da9fee553058b034b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 1 Jun 2022 13:22:43 -0700 Subject: [PATCH 1/4] [beta] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 3f052d8eed98c..4751950ccc948 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 3f052d8eed98c6a24f8b332fb2e6e6249d12d8c1 +Subproject commit 4751950ccc948c07047e62c20adf423d7e5f668c From 072348837a8fec03a12ca3c4827380ce428da893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 15 May 2022 08:10:42 +0200 Subject: [PATCH 2/4] Rollup merge of #97032 - est31:unused_macro_rules, r=petrochenkov Allow the unused_macro_rules lint for now It was newly added by #96150 with warn by default, which is great as it gave exposure to the community, and their feedback gave me ideas for improvements. Allowing the lint is good for two reasons: * It makes the transition easier as e.g. allow directives won't fire the unknown lint warning once it is turned to warn by default in the future. The [commit that allowed the lint in fuchsia](https://fuchsia.googlesource.com/fuchsia/+/9d8f96517c3963de2f0e25598fd36061914524cd%5E%21/) had to allow unknown lints for example. This is especially important compared to other lints in the unused group, because the _ prefix trick doesn't exist for macro rules, allowing is the only option (either of unused_macro_rules, or of the entire unused group, but that is not as informative to readers). Allowing the lint also makes it possible to work on possible heuristics for disabling the macro in specific cases. * It gives time for implementing heuristics for when to suppress the lint, e.g. when `compile_error!` is invoked by that arm (so it's only there to yield an error). See: https://github.com/rust-lang/rust/pull/96150#issuecomment-1126599107 I would also like this to be backported to the 1.62 beta branch (cc #97016). --- compiler/rustc_lint_defs/src/builtin.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 7ebb1e85cdb23..f942970278399 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -790,6 +790,7 @@ declare_lint! { /// ### Example /// /// ```rust + /// #[warn(unused_macro_rules)] /// macro_rules! unused_empty { /// (hello) => { println!("Hello, world!") }; // This rule is unused /// () => { println!("empty") }; // This rule is used @@ -814,7 +815,7 @@ declare_lint! { /// /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope pub UNUSED_MACRO_RULES, - Warn, + Allow, "detects macro rules that were not used" } From 0a2d181d2f8dcfef1a64b145285d679c47831cea Mon Sep 17 00:00:00 2001 From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> Date: Mon, 23 May 2022 07:43:52 +0200 Subject: [PATCH 3/4] Rollup merge of #97303 - compiler-errors:arg-typos, r=jackh726 Fix some typos in arg checking algorithm Fixes #97197 Also fixes a typo where if we're missing args A, B, C, we actually say A, B, B --- .../rustc_typeck/src/check/fn_ctxt/checks.rs | 10 +++++----- .../ui/argument-suggestions/issue-97197.rs | 6 ++++++ .../argument-suggestions/issue-97197.stderr | 19 +++++++++++++++++++ .../missing_arguments.stderr | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/argument-suggestions/issue-97197.rs create mode 100644 src/test/ui/argument-suggestions/issue-97197.stderr diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 847c2c32dba29..f1c7d52675c74 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -769,7 +769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let second_input_ty = self.resolve_vars_if_possible(expected_input_tys[second_idx]); let third_input_ty = - self.resolve_vars_if_possible(expected_input_tys[second_idx]); + self.resolve_vars_if_possible(expected_input_tys[third_idx]); let span = if third_idx < provided_arg_count { let first_arg_span = provided_args[first_idx].span; let third_arg_span = provided_args[third_idx].span; @@ -810,16 +810,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } missing_idxs => { let first_idx = *missing_idxs.first().unwrap(); - let second_idx = *missing_idxs.last().unwrap(); + let last_idx = *missing_idxs.last().unwrap(); // NOTE: Because we might be re-arranging arguments, might have extra arguments, etc. // It's hard to *really* know where we should provide this error label, so this is a // decent heuristic - let span = if first_idx < provided_arg_count { + let span = if last_idx < provided_arg_count { let first_arg_span = provided_args[first_idx].span; - let second_arg_span = provided_args[second_idx].span; + let last_arg_span = provided_args[last_idx].span; Span::new( first_arg_span.lo(), - second_arg_span.hi(), + last_arg_span.hi(), first_arg_span.ctxt(), None, ) diff --git a/src/test/ui/argument-suggestions/issue-97197.rs b/src/test/ui/argument-suggestions/issue-97197.rs new file mode 100644 index 0000000000000..6f9f4293e4964 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-97197.rs @@ -0,0 +1,6 @@ +fn main() { + g((), ()); + //~^ ERROR this function takes 6 arguments but 2 arguments were supplied +} + +pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} diff --git a/src/test/ui/argument-suggestions/issue-97197.stderr b/src/test/ui/argument-suggestions/issue-97197.stderr new file mode 100644 index 0000000000000..10689d5095748 --- /dev/null +++ b/src/test/ui/argument-suggestions/issue-97197.stderr @@ -0,0 +1,19 @@ +error[E0061]: this function takes 6 arguments but 2 arguments were supplied + --> $DIR/issue-97197.rs:2:5 + | +LL | g((), ()); + | ^-------- multiple arguments are missing + | +note: function defined here + --> $DIR/issue-97197.rs:6:8 + | +LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} + | ^ ------ -------- -------- -------- -------- ------ +help: provide the arguments + | +LL | g((), {bool}, {bool}, {bool}, {bool}, ()); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/argument-suggestions/missing_arguments.stderr b/src/test/ui/argument-suggestions/missing_arguments.stderr index b4dadb1b9da00..5236d15b94574 100644 --- a/src/test/ui/argument-suggestions/missing_arguments.stderr +++ b/src/test/ui/argument-suggestions/missing_arguments.stderr @@ -293,7 +293,7 @@ error[E0061]: this function takes 5 arguments but 2 arguments were supplied --> $DIR/missing_arguments.rs:39:3 | LL | complex( 1, "" ); - | ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing + | ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing | note: function defined here --> $DIR/missing_arguments.rs:7:4 From 054a2bd9f81f9d1fc6b5629f2dec351301ca5293 Mon Sep 17 00:00:00 2001 From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> Date: Wed, 25 May 2022 17:37:20 +0200 Subject: [PATCH 4/4] Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister rustc: Fix ICE in native library error reporting Fixes https://github.com/rust-lang/rust/issues/97299 --- compiler/rustc_metadata/src/native_libs.rs | 9 +++++---- .../ui/native-library-link-flags/modifiers-override-3.rs | 7 +++++++ .../modifiers-override-3.stderr | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/native-library-link-flags/modifiers-override-3.rs create mode 100644 src/test/ui/native-library-link-flags/modifiers-override-3.stderr diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index f468399930d3a..eec66fba9b8c4 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -383,10 +383,11 @@ impl<'tcx> Collector<'tcx> { // involved or not, library reordering and kind overriding without // explicit `:rename` in particular. if lib.has_modifiers() || passed_lib.has_modifiers() { - self.tcx.sess.span_err( - self.tcx.def_span(lib.foreign_module.unwrap()), - "overriding linking modifiers from command line is not supported" - ); + let msg = "overriding linking modifiers from command line is not supported"; + match lib.foreign_module { + Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg), + None => self.tcx.sess.err(msg), + }; } if passed_lib.kind != NativeLibKind::Unspecified { lib.kind = passed_lib.kind; diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.rs b/src/test/ui/native-library-link-flags/modifiers-override-3.rs new file mode 100644 index 0000000000000..b28c53c6b0a50 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.rs @@ -0,0 +1,7 @@ +// Regression test for issue #97299, one command line library with modifiers +// overrides another command line library with modifiers. + +// compile-flags:-lstatic:+whole-archive=foo -lstatic:+whole-archive=foo +// error-pattern: overriding linking modifiers from command line is not supported + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.stderr b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr new file mode 100644 index 0000000000000..365e561810017 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr @@ -0,0 +1,4 @@ +error: overriding linking modifiers from command line is not supported + +error: aborting due to previous error +