Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] Beta backports #97631

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Expand Up @@ -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
Expand All @@ -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"
}

Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_metadata/src/native_libs.rs
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
)
Expand Down
6 changes: 6 additions & 0 deletions 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: ()) -> () {}
19 changes: 19 additions & 0 deletions 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`.
2 changes: 1 addition & 1 deletion src/test/ui/argument-suggestions/missing_arguments.stderr
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions 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() {}
@@ -0,0 +1,4 @@
error: overriding linking modifiers from command line is not supported

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/tools/cargo