Skip to content

Commit a5cf77c

Browse files
committed
Auto merge of #97631 - ehuss:update-beta-cargo, r=ehuss
[beta] Beta backports * Allow the unused_macro_rules lint for now #97032 * Fix some typos in arg checking algorithm #97303 * rustc: Fix ICE in native library error reporting #97328 * Cargo: * Fix `cargo publish -p spec` rust-lang/cargo#10707
2 parents daf68b1 + 054a2bd commit a5cf77c

File tree

9 files changed

+50
-12
lines changed

9 files changed

+50
-12
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ declare_lint! {
790790
/// ### Example
791791
///
792792
/// ```rust
793+
/// #[warn(unused_macro_rules)]
793794
/// macro_rules! unused_empty {
794795
/// (hello) => { println!("Hello, world!") }; // This rule is unused
795796
/// () => { println!("empty") }; // This rule is used
@@ -814,7 +815,7 @@ declare_lint! {
814815
///
815816
/// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
816817
pub UNUSED_MACRO_RULES,
817-
Warn,
818+
Allow,
818819
"detects macro rules that were not used"
819820
}
820821

compiler/rustc_metadata/src/native_libs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,11 @@ impl<'tcx> Collector<'tcx> {
383383
// involved or not, library reordering and kind overriding without
384384
// explicit `:rename` in particular.
385385
if lib.has_modifiers() || passed_lib.has_modifiers() {
386-
self.tcx.sess.span_err(
387-
self.tcx.def_span(lib.foreign_module.unwrap()),
388-
"overriding linking modifiers from command line is not supported"
389-
);
386+
let msg = "overriding linking modifiers from command line is not supported";
387+
match lib.foreign_module {
388+
Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg),
389+
None => self.tcx.sess.err(msg),
390+
};
390391
}
391392
if passed_lib.kind != NativeLibKind::Unspecified {
392393
lib.kind = passed_lib.kind;

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
769769
let second_input_ty =
770770
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
771771
let third_input_ty =
772-
self.resolve_vars_if_possible(expected_input_tys[second_idx]);
772+
self.resolve_vars_if_possible(expected_input_tys[third_idx]);
773773
let span = if third_idx < provided_arg_count {
774774
let first_arg_span = provided_args[first_idx].span;
775775
let third_arg_span = provided_args[third_idx].span;
@@ -810,16 +810,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
810810
}
811811
missing_idxs => {
812812
let first_idx = *missing_idxs.first().unwrap();
813-
let second_idx = *missing_idxs.last().unwrap();
813+
let last_idx = *missing_idxs.last().unwrap();
814814
// NOTE: Because we might be re-arranging arguments, might have extra arguments, etc.
815815
// It's hard to *really* know where we should provide this error label, so this is a
816816
// decent heuristic
817-
let span = if first_idx < provided_arg_count {
817+
let span = if last_idx < provided_arg_count {
818818
let first_arg_span = provided_args[first_idx].span;
819-
let second_arg_span = provided_args[second_idx].span;
819+
let last_arg_span = provided_args[last_idx].span;
820820
Span::new(
821821
first_arg_span.lo(),
822-
second_arg_span.hi(),
822+
last_arg_span.hi(),
823823
first_arg_span.ctxt(),
824824
None,
825825
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
g((), ());
3+
//~^ ERROR this function takes 6 arguments but 2 arguments were supplied
4+
}
5+
6+
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0061]: this function takes 6 arguments but 2 arguments were supplied
2+
--> $DIR/issue-97197.rs:2:5
3+
|
4+
LL | g((), ());
5+
| ^-------- multiple arguments are missing
6+
|
7+
note: function defined here
8+
--> $DIR/issue-97197.rs:6:8
9+
|
10+
LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
11+
| ^ ------ -------- -------- -------- -------- ------
12+
help: provide the arguments
13+
|
14+
LL | g((), {bool}, {bool}, {bool}, {bool}, ());
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0061`.

src/test/ui/argument-suggestions/missing_arguments.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ error[E0061]: this function takes 5 arguments but 2 arguments were supplied
293293
--> $DIR/missing_arguments.rs:39:3
294294
|
295295
LL | complex( 1, "" );
296-
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing
296+
| ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing
297297
|
298298
note: function defined here
299299
--> $DIR/missing_arguments.rs:7:4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for issue #97299, one command line library with modifiers
2+
// overrides another command line library with modifiers.
3+
4+
// compile-flags:-lstatic:+whole-archive=foo -lstatic:+whole-archive=foo
5+
// error-pattern: overriding linking modifiers from command line is not supported
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: overriding linking modifiers from command line is not supported
2+
3+
error: aborting due to previous error
4+

0 commit comments

Comments
 (0)