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

Rollup of 8 pull requests #126446

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cfe020
Always emit native-static-libs note, even if it is empty
madsmtm Feb 17, 2024
c4c8bda
non_local_defs: indicate that the macro needs to change
Urgau May 29, 2024
b5d4867
non_local_defs: move cargo update suggestion upper
Urgau May 29, 2024
bd6fca2
Clarify `Command::new` behavior if passed programs with arguments
jieyouxu Apr 10, 2024
523408e
Fix wording in {checked_}next_power_of_two
Kriskras99 Jun 13, 2024
10c7643
Small style improvement in `gvn.rs`
WaffleLapkin Jun 13, 2024
0cc099b
fix wrong assert_unsafe_precondition message for core::ptr::copy
firefighterduck Jun 13, 2024
cc65413
compiletest: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
a5ef43e
build_helper: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
4a7c138
build-manifest: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
481dcb0
jsondoclint: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
c755df2
remote-test-server: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
5aa3fbc
remote-test-client: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
80d96df
lint-docs: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
a31b1b2
opt-dist: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
d12f1a7
tidy: apply considerable clippy suggestions
onur-ozkan Jun 6, 2024
c8d2b93
fix bootstrap CI failure
onur-ozkan Jun 6, 2024
9e466d3
Remove failing GUI test to stop blocking CI until it is fixed
GuillaumeGomez Jun 13, 2024
9958f1f
Rollup merge of #121216 - madsmtm:fix-108825, r=wesleywiser
workingjubilee Jun 13, 2024
c48034d
Rollup merge of #123726 - jieyouxu:command-new-docs, r=Nilstrieb
workingjubilee Jun 13, 2024
1e12128
Rollup merge of #125722 - Urgau:non_local_defs-macro-to-change, r=est…
workingjubilee Jun 13, 2024
b96c7ef
Rollup merge of #126088 - onur-ozkan:brooming, r=albertlarsan68
workingjubilee Jun 13, 2024
3475261
Rollup merge of #126390 - Kriskras99:master, r=Nilstrieb
workingjubilee Jun 13, 2024
fead76a
Rollup merge of #126392 - WaffleLapkin:gvn-style-ish-changes, r=scottmcm
workingjubilee Jun 13, 2024
4a42928
Rollup merge of #126402 - firefighterduck:fix-unsafe-precon-copy, r=N…
workingjubilee Jun 13, 2024
b7c8b09
Rollup merge of #126445 - GuillaumeGomez:rm-help-page, r=lqd
workingjubilee Jun 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks sho
.bounds = `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration
.const_anon = use a const-anon item to suppress this lint
.macro_to_change = the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed

lint_non_local_definitions_impl_move_help =
move the `impl` block outside of this {$body_kind_descr} {$depth ->
Expand Down
14 changes: 11 additions & 3 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ pub enum NonLocalDefinitionsDiag {
has_trait: bool,
self_ty_str: String,
of_trait_str: Option<String>,
macro_to_change: Option<(String, &'static str)>,
},
MacroRules {
depth: u32,
Expand All @@ -1387,6 +1388,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
has_trait,
self_ty_str,
of_trait_str,
macro_to_change,
} => {
diag.primary_message(fluent::lint_non_local_definitions_impl);
diag.arg("depth", depth);
Expand All @@ -1397,6 +1399,15 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
diag.arg("of_trait_str", of_trait_str);
}

if let Some((macro_to_change, macro_kind)) = macro_to_change {
diag.arg("macro_to_change", macro_to_change);
diag.arg("macro_kind", macro_kind);
diag.note(fluent::lint_macro_to_change);
}
if let Some(cargo_update) = cargo_update {
diag.subdiagnostic(&diag.dcx, cargo_update);
}

if has_trait {
diag.note(fluent::lint_bounds);
diag.note(fluent::lint_with_trait);
Expand All @@ -1422,9 +1433,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
);
}

if let Some(cargo_update) = cargo_update {
diag.subdiagnostic(&diag.dcx, cargo_update);
}
if let Some(const_anon) = const_anon {
diag.note(fluent::lint_exception);
if let Some(const_anon) = const_anon {
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_lint/src/non_local_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
Some((cx.tcx.def_span(parent), may_move))
};

let macro_to_change =
if let ExpnKind::Macro(kind, name) = item.span.ctxt().outer_expn_data().kind {
Some((name.to_string(), kind.descr()))
} else {
None
};

cx.emit_span_lint(
NON_LOCAL_DEFINITIONS,
ms,
Expand All @@ -274,6 +281,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
move_to,
may_remove,
has_trait: impl_.of_trait.is_some(),
macro_to_change,
},
)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/lint/non-local-defs/cargo-update.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
| `Debug` is not local
| move the `impl` block outside of this constant `_IMPL_DEBUG`
|
= note: the macro `non_local_macro::non_local_impl` defines the non-local `impl`, and may need to be changed
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
Expand Down
1 change: 1 addition & 0 deletions tests/ui/lint/non-local-defs/inside-macro_rules.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LL | impl MacroTrait for OutsideStruct {}
LL | m!();
| ---- in this macro invocation
|
= note: the macro `m` defines the non-local `impl`, and may need to be changed
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
Expand Down