Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdef683

Browse files
committedJun 13, 2024
Auto merge of #126446 - workingjubilee:rollup-esdbgdw, r=workingjubilee
Rollup of 8 pull requests Successful merges: - #121216 (Always emit `native-static-libs` note, even if it is empty) - #123726 (Clarify `Command::new` behavior for programs with arguments) - #125722 (Indicate in `non_local_defs` lint that the macro needs to change) - #126088 ([1/2] clean-up / general improvements) - #126390 (Fix wording in {checked_}next_power_of_two) - #126392 (Small style improvement in `gvn.rs`) - #126402 (Fix wrong `assert_unsafe_precondition` message for `core::ptr::copy`) - #126445 (Remove failing GUI test to stop blocking CI until it is fixed) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f158600 + b7c8b09 commit bdef683

File tree

40 files changed

+209
-249
lines changed

40 files changed

+209
-249
lines changed
 

‎compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,17 +1561,13 @@ fn print_native_static_libs(
15611561
match out {
15621562
OutFileName::Real(path) => {
15631563
out.overwrite(&lib_args.join(" "), sess);
1564-
if !lib_args.is_empty() {
1565-
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
1566-
}
1564+
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
15671565
}
15681566
OutFileName::Stdout => {
1569-
if !lib_args.is_empty() {
1570-
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
1571-
// Prefix for greppability
1572-
// Note: This must not be translated as tools are allowed to depend on this exact string.
1573-
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
1574-
}
1567+
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
1568+
// Prefix for greppability
1569+
// Note: This must not be translated as tools are allowed to depend on this exact string.
1570+
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
15751571
}
15761572
}
15771573
}

‎compiler/rustc_lint/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks sho
550550
.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
551551
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration
552552
.const_anon = use a const-anon item to suppress this lint
553+
.macro_to_change = the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed
553554
554555
lint_non_local_definitions_impl_move_help =
555556
move the `impl` block outside of this {$body_kind_descr} {$depth ->

‎compiler/rustc_lint/src/lints.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ pub enum NonLocalDefinitionsDiag {
13621362
has_trait: bool,
13631363
self_ty_str: String,
13641364
of_trait_str: Option<String>,
1365+
macro_to_change: Option<(String, &'static str)>,
13651366
},
13661367
MacroRules {
13671368
depth: u32,
@@ -1387,6 +1388,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13871388
has_trait,
13881389
self_ty_str,
13891390
of_trait_str,
1391+
macro_to_change,
13901392
} => {
13911393
diag.primary_message(fluent::lint_non_local_definitions_impl);
13921394
diag.arg("depth", depth);
@@ -1397,6 +1399,15 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13971399
diag.arg("of_trait_str", of_trait_str);
13981400
}
13991401

1402+
if let Some((macro_to_change, macro_kind)) = macro_to_change {
1403+
diag.arg("macro_to_change", macro_to_change);
1404+
diag.arg("macro_kind", macro_kind);
1405+
diag.note(fluent::lint_macro_to_change);
1406+
}
1407+
if let Some(cargo_update) = cargo_update {
1408+
diag.subdiagnostic(&diag.dcx, cargo_update);
1409+
}
1410+
14001411
if has_trait {
14011412
diag.note(fluent::lint_bounds);
14021413
diag.note(fluent::lint_with_trait);
@@ -1422,9 +1433,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
14221433
);
14231434
}
14241435

1425-
if let Some(cargo_update) = cargo_update {
1426-
diag.subdiagnostic(&diag.dcx, cargo_update);
1427-
}
14281436
if let Some(const_anon) = const_anon {
14291437
diag.note(fluent::lint_exception);
14301438
if let Some(const_anon) = const_anon {

‎compiler/rustc_lint/src/non_local_def.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
258258
Some((cx.tcx.def_span(parent), may_move))
259259
};
260260

261+
let macro_to_change =
262+
if let ExpnKind::Macro(kind, name) = item.span.ctxt().outer_expn_data().kind {
263+
Some((name.to_string(), kind.descr()))
264+
} else {
265+
None
266+
};
267+
261268
cx.emit_span_lint(
262269
NON_LOCAL_DEFINITIONS,
263270
ms,
@@ -274,6 +281,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
274281
move_to,
275282
may_remove,
276283
has_trait: impl_.of_trait.is_some(),
284+
macro_to_change,
277285
},
278286
)
279287
}

‎compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
330330
let is_sized = !self.feature_unsized_locals
331331
|| self.local_decls[local].ty.is_sized(self.tcx, self.param_env);
332332
if is_sized {
333-
self.rev_locals.ensure_contains_elem(value, SmallVec::new);
334-
self.rev_locals[value].push(local);
333+
self.rev_locals.ensure_contains_elem(value, SmallVec::new).push(local);
335334
}
336335
}
337336

‎library/core/src/intrinsics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,8 +3043,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
30433043
unsafe {
30443044
ub_checks::assert_unsafe_precondition!(
30453045
check_language_ub,
3046-
"ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null \
3047-
and the specified memory ranges do not overlap",
3046+
"ptr::copy requires that both pointer arguments are aligned and non-null",
30483047
(
30493048
src: *const () = src as *const (),
30503049
dst: *mut () = dst as *mut (),

‎library/core/src/num/nonzero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
10591059
unsafe { Self::new_unchecked(self.get().unchecked_add(other)) }
10601060
}
10611061

1062-
/// Returns the smallest power of two greater than or equal to n.
1062+
/// Returns the smallest power of two greater than or equal to `self`.
10631063
/// Checks for overflow and returns [`None`]
10641064
/// if the next power of two is greater than the type’s maximum value.
10651065
/// As a consequence, the result cannot wrap to zero.

‎library/core/src/num/uint_macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ macro_rules! uint_impl {
28302830
///
28312831
/// When return value overflows (i.e., `self > (1 << (N-1))` for type
28322832
/// `uN`), it panics in debug mode and the return value is wrapped to 0 in
2833-
/// release mode (the only situation in which method can return 0).
2833+
/// release mode (the only situation in which this method can return 0).
28342834
///
28352835
/// # Examples
28362836
///
@@ -2851,7 +2851,7 @@ macro_rules! uint_impl {
28512851
self.one_less_than_next_power_of_two() + 1
28522852
}
28532853

2854-
/// Returns the smallest power of two greater than or equal to `n`. If
2854+
/// Returns the smallest power of two greater than or equal to `self`. If
28552855
/// the next power of two is greater than the type's maximum value,
28562856
/// `None` is returned, otherwise the power of two is wrapped in `Some`.
28572857
///

‎library/std/src/process.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,25 @@ impl Command {
629629
/// .spawn()
630630
/// .expect("sh command failed to start");
631631
/// ```
632+
///
633+
/// # Caveats
634+
///
635+
/// [`Command::new`] is only intended to accept the path of the program. If you pass a program
636+
/// path along with arguments like `Command::new("ls -l").spawn()`, it will try to search for
637+
/// `ls -l` literally. The arguments need to be passed separately, such as via [`arg`] or
638+
/// [`args`].
639+
///
640+
/// ```no_run
641+
/// use std::process::Command;
642+
///
643+
/// Command::new("ls")
644+
/// .arg("-l") // arg passed separately
645+
/// .spawn()
646+
/// .expect("ls command failed to start");
647+
/// ```
648+
///
649+
/// [`arg`]: Self::arg
650+
/// [`args`]: Self::args
632651
#[stable(feature = "process", since = "1.0.0")]
633652
pub fn new<S: AsRef<OsStr>>(program: S) -> Command {
634653
Command { inner: imp::Command::new(program.as_ref()) }

‎src/bootstrap/src/core/build_steps/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
9393
return Ok(None);
9494
}
9595

96-
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &vec!["rs"])
96+
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
9797
}
9898

9999
#[derive(serde_derive::Deserialize)]

‎src/tools/build-manifest/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl Builder {
495495
Some(p) => p,
496496
None => return false,
497497
};
498-
pkg.target.get(&c.target).is_some()
498+
pkg.target.contains_key(&c.target)
499499
};
500500
extensions.retain(&has_component);
501501
components.retain(&has_component);

‎src/tools/build_helper/src/git.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn output_result(cmd: &mut Command) -> Result<String, String> {
2121
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
2222
));
2323
}
24-
Ok(String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?)
24+
String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))
2525
}
2626

2727
/// Finds the remote for rust-lang/rust.
@@ -64,18 +64,14 @@ pub fn rev_exists(rev: &str, git_dir: Option<&Path>) -> Result<bool, String> {
6464
match output.status.code() {
6565
Some(0) => Ok(true),
6666
Some(128) => Ok(false),
67-
None => {
68-
return Err(format!(
69-
"git didn't exit properly: {}",
70-
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
71-
));
72-
}
73-
Some(code) => {
74-
return Err(format!(
75-
"git command exited with status code: {code}: {}",
76-
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
77-
));
78-
}
67+
None => Err(format!(
68+
"git didn't exit properly: {}",
69+
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
70+
)),
71+
Some(code) => Err(format!(
72+
"git command exited with status code: {code}: {}",
73+
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
74+
)),
7975
}
8076
}
8177

@@ -96,7 +92,7 @@ pub fn updated_master_branch(
9692
}
9793
}
9894

99-
Err(format!("Cannot find any suitable upstream master branch"))
95+
Err("Cannot find any suitable upstream master branch".to_owned())
10096
}
10197

10298
pub fn get_git_merge_base(
@@ -118,7 +114,7 @@ pub fn get_git_merge_base(
118114
pub fn get_git_modified_files(
119115
config: &GitConfig<'_>,
120116
git_dir: Option<&Path>,
121-
extensions: &Vec<&str>,
117+
extensions: &[&str],
122118
) -> Result<Option<Vec<String>>, String> {
123119
let merge_base = get_git_merge_base(config, git_dir)?;
124120

‎src/tools/compiletest/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl TargetCfgs {
582582
name,
583583
Some(
584584
value
585-
.strip_suffix("\"")
585+
.strip_suffix('\"')
586586
.expect("key-value pair should be properly quoted"),
587587
),
588588
)

‎src/tools/compiletest/src/header.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl EarlyProps {
8282
panic!("errors encountered during EarlyProps parsing");
8383
}
8484

85-
return props;
85+
props
8686
}
8787
}
8888

@@ -382,7 +382,7 @@ impl TestProps {
382382
// Individual flags can be single-quoted to preserve spaces; see
383383
// <https://github.com/rust-lang/rust/pull/115948/commits/957c5db6>.
384384
flags
385-
.split("'")
385+
.split('\'')
386386
.enumerate()
387387
.flat_map(|(i, f)| {
388388
if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() }
@@ -613,7 +613,7 @@ impl TestProps {
613613

614614
for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
615615
if let Ok(val) = env::var(key) {
616-
if self.exec_env.iter().find(|&&(ref x, _)| x == key).is_none() {
616+
if !self.exec_env.iter().any(|&(ref x, _)| x == key) {
617617
self.exec_env.push(((*key).to_owned(), val))
618618
}
619619
}
@@ -991,7 +991,7 @@ pub(crate) fn check_directive(directive_ln: &str) -> CheckDirectiveResult<'_> {
991991
let trailing = post.trim().split_once(' ').map(|(pre, _)| pre).unwrap_or(post);
992992
let trailing_directive = {
993993
// 1. is the directive name followed by a space? (to exclude `:`)
994-
matches!(directive_ln.get(directive_name.len()..), Some(s) if s.starts_with(" "))
994+
matches!(directive_ln.get(directive_name.len()..), Some(s) if s.starts_with(' '))
995995
// 2. is what is after that directive also a directive (ex: "only-x86 only-arm")
996996
&& KNOWN_DIRECTIVE_NAMES.contains(&trailing)
997997
}
@@ -1363,7 +1363,7 @@ pub fn extract_llvm_version_from_binary(binary_path: &str) -> Option<u32> {
13631363
}
13641364
let version = String::from_utf8(output.stdout).ok()?;
13651365
for line in version.lines() {
1366-
if let Some(version) = line.split("LLVM version ").skip(1).next() {
1366+
if let Some(version) = line.split("LLVM version ").nth(1) {
13671367
return extract_llvm_version(version);
13681368
}
13691369
}
@@ -1394,7 +1394,7 @@ where
13941394

13951395
let min = parse(min)?;
13961396
let max = match max {
1397-
Some(max) if max.is_empty() => return None,
1397+
Some("") => return None,
13981398
Some(max) => parse(max)?,
13991399
_ => min,
14001400
};
@@ -1466,12 +1466,12 @@ pub fn make_test_description<R: Read>(
14661466
decision!(ignore_gdb(config, ln));
14671467
decision!(ignore_lldb(config, ln));
14681468

1469-
if config.target == "wasm32-unknown-unknown" {
1470-
if config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS) {
1471-
decision!(IgnoreDecision::Ignore {
1472-
reason: "ignored on WASM as the run results cannot be checked there".into(),
1473-
});
1474-
}
1469+
if config.target == "wasm32-unknown-unknown"
1470+
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS)
1471+
{
1472+
decision!(IgnoreDecision::Ignore {
1473+
reason: "ignored on WASM as the run results cannot be checked there".into(),
1474+
});
14751475
}
14761476

14771477
should_fail |= config.parse_name_directive(ln, "should-fail");

‎src/tools/compiletest/src/header/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn parse_cfg_name_directive<'a>(
5858

5959
// Some of the matchers might be "" depending on what the target information is. To avoid
6060
// problems we outright reject empty directives.
61-
if name == "" {
61+
if name.is_empty() {
6262
return ParsedNameDirective::not_a_directive();
6363
}
6464

‎src/tools/compiletest/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
11471147
}
11481148

11491149
fn not_a_digit(c: char) -> bool {
1150-
!c.is_digit(10)
1150+
!c.is_ascii_digit()
11511151
}
11521152

11531153
fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) {

‎src/tools/compiletest/src/read2.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ mod tests;
66

77
pub use self::imp::read2;
88
use std::io::{self, Write};
9-
use std::mem::replace;
109
use std::process::{Child, Output};
1110

1211
#[derive(Copy, Clone, Debug)]
@@ -101,10 +100,10 @@ impl ProcOutput {
101100
return;
102101
}
103102

104-
let mut head = replace(bytes, Vec::new());
103+
let mut head = std::mem::take(bytes);
105104
// Don't truncate if this as a whole line.
106105
// That should make it less likely that we cut a JSON line in half.
107-
if head.last() != Some(&('\n' as u8)) {
106+
if head.last() != Some(&b'\n') {
108107
head.truncate(MAX_OUT_LEN);
109108
}
110109
let skipped = new_len - head.len();

‎src/tools/compiletest/src/read2/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ fn test_abbreviate_filterss_are_detected() {
6464
#[test]
6565
fn test_abbreviate_filters_avoid_abbreviations() {
6666
let mut out = ProcOutput::new();
67-
let filters = &[std::iter::repeat('a').take(64).collect::<String>()];
67+
let filters = &["a".repeat(64)];
6868

69-
let mut expected = vec![b'.'; MAX_OUT_LEN - FILTERED_PATHS_PLACEHOLDER_LEN as usize];
69+
let mut expected = vec![b'.'; MAX_OUT_LEN - FILTERED_PATHS_PLACEHOLDER_LEN];
7070
expected.extend_from_slice(filters[0].as_bytes());
7171

7272
out.extend(&expected, filters);
@@ -81,7 +81,7 @@ fn test_abbreviate_filters_avoid_abbreviations() {
8181
#[test]
8282
fn test_abbreviate_filters_can_still_cause_abbreviations() {
8383
let mut out = ProcOutput::new();
84-
let filters = &[std::iter::repeat('a').take(64).collect::<String>()];
84+
let filters = &["a".repeat(64)];
8585

8686
let mut input = vec![b'.'; MAX_OUT_LEN];
8787
input.extend_from_slice(filters[0].as_bytes());

‎src/tools/compiletest/src/runtest.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ impl<'test> TestCx<'test> {
374374

375375
// if a test does not crash, consider it an error
376376
if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) {
377-
self.fatal(&format!(
377+
self.fatal(
378378
"test no longer crashes/triggers ICE! Please give it a mearningful name, \
379379
add a doc-comment to the start of the test explaining why it exists and \
380-
move it to tests/ui or wherever you see fit."
381-
));
380+
move it to tests/ui or wherever you see fit.",
381+
);
382382
}
383383
}
384384

@@ -697,10 +697,10 @@ impl<'test> TestCx<'test> {
697697
// since it is extensively used in the testsuite.
698698
check_cfg.push_str("cfg(FALSE");
699699
for revision in &self.props.revisions {
700-
check_cfg.push_str(",");
701-
check_cfg.push_str(&normalize_revision(&revision));
700+
check_cfg.push(',');
701+
check_cfg.push_str(&normalize_revision(revision));
702702
}
703-
check_cfg.push_str(")");
703+
check_cfg.push(')');
704704

705705
cmd.args(&["--check-cfg", &check_cfg]);
706706
}
@@ -818,7 +818,7 @@ impl<'test> TestCx<'test> {
818818
// Append the other `cdb-command:`s
819819
for line in &dbg_cmds.commands {
820820
script_str.push_str(line);
821-
script_str.push_str("\n");
821+
script_str.push('\n');
822822
}
823823

824824
script_str.push_str("qq\n"); // Quit the debugger (including remote debugger, if any)
@@ -1200,7 +1200,7 @@ impl<'test> TestCx<'test> {
12001200
// Append the other commands
12011201
for line in &dbg_cmds.commands {
12021202
script_str.push_str(line);
1203-
script_str.push_str("\n");
1203+
script_str.push('\n');
12041204
}
12051205

12061206
// Finally, quit the debugger
@@ -1250,7 +1250,7 @@ impl<'test> TestCx<'test> {
12501250
// Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
12511251
let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
12521252

1253-
options.iter().filter(|x| !options_to_remove.contains(x)).map(|x| x.clone()).collect()
1253+
options.iter().filter(|x| !options_to_remove.contains(x)).cloned().collect()
12541254
}
12551255

12561256
fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec<String>) {
@@ -2504,8 +2504,8 @@ impl<'test> TestCx<'test> {
25042504
// This works with both `--emit asm` (as default output name for the assembly)
25052505
// and `ptx-linker` because the latter can write output at requested location.
25062506
let output_path = self.output_base_name().with_extension(extension);
2507-
let output_file = TargetLocation::ThisFile(output_path.clone());
2508-
output_file
2507+
2508+
TargetLocation::ThisFile(output_path.clone())
25092509
}
25102510
}
25112511

@@ -2752,7 +2752,7 @@ impl<'test> TestCx<'test> {
27522752
for entry in walkdir::WalkDir::new(dir) {
27532753
let entry = entry.expect("failed to read file");
27542754
if entry.file_type().is_file()
2755-
&& entry.path().extension().and_then(|p| p.to_str()) == Some("html".into())
2755+
&& entry.path().extension().and_then(|p| p.to_str()) == Some("html")
27562756
{
27572757
let status =
27582758
Command::new("tidy").args(&tidy_args).arg(entry.path()).status().unwrap();
@@ -2783,8 +2783,7 @@ impl<'test> TestCx<'test> {
27832783
&compare_dir,
27842784
self.config.verbose,
27852785
|file_type, extension| {
2786-
file_type.is_file()
2787-
&& (extension == Some("html".into()) || extension == Some("js".into()))
2786+
file_type.is_file() && (extension == Some("html") || extension == Some("js"))
27882787
},
27892788
) {
27902789
return;
@@ -2830,11 +2829,11 @@ impl<'test> TestCx<'test> {
28302829
}
28312830
match String::from_utf8(line.clone()) {
28322831
Ok(line) => {
2833-
if line.starts_with("+") {
2832+
if line.starts_with('+') {
28342833
write!(&mut out, "{}", line.green()).unwrap();
2835-
} else if line.starts_with("-") {
2834+
} else if line.starts_with('-') {
28362835
write!(&mut out, "{}", line.red()).unwrap();
2837-
} else if line.starts_with("@") {
2836+
} else if line.starts_with('@') {
28382837
write!(&mut out, "{}", line.blue()).unwrap();
28392838
} else {
28402839
out.write_all(line.as_bytes()).unwrap();
@@ -2907,7 +2906,7 @@ impl<'test> TestCx<'test> {
29072906
&& line.ends_with(';')
29082907
{
29092908
if let Some(ref mut other_files) = other_files {
2910-
other_files.push(line.rsplit("mod ").next().unwrap().replace(";", ""));
2909+
other_files.push(line.rsplit("mod ").next().unwrap().replace(';', ""));
29112910
}
29122911
None
29132912
} else {
@@ -3139,7 +3138,7 @@ impl<'test> TestCx<'test> {
31393138
let mut string = String::new();
31403139
for cgu in cgus {
31413140
string.push_str(&cgu[..]);
3142-
string.push_str(" ");
3141+
string.push(' ');
31433142
}
31443143

31453144
string
@@ -3172,10 +3171,7 @@ impl<'test> TestCx<'test> {
31723171
// CGUs joined with "--". This function splits such composite CGU names
31733172
// and handles each component individually.
31743173
fn remove_crate_disambiguators_from_set_of_cgu_names(cgus: &str) -> String {
3175-
cgus.split("--")
3176-
.map(|cgu| remove_crate_disambiguator_from_cgu(cgu))
3177-
.collect::<Vec<_>>()
3178-
.join("--")
3174+
cgus.split("--").map(remove_crate_disambiguator_from_cgu).collect::<Vec<_>>().join("--")
31793175
}
31803176
}
31813177

@@ -3357,7 +3353,7 @@ impl<'test> TestCx<'test> {
33573353
// endif
33583354
}
33593355

3360-
if self.config.target.contains("msvc") && self.config.cc != "" {
3356+
if self.config.target.contains("msvc") && !self.config.cc.is_empty() {
33613357
// We need to pass a path to `lib.exe`, so assume that `cc` is `cl.exe`
33623358
// and that `lib.exe` lives next to it.
33633359
let lib = Path::new(&self.config.cc).parent().unwrap().join("lib.exe");
@@ -3639,7 +3635,7 @@ impl<'test> TestCx<'test> {
36393635
// endif
36403636
}
36413637

3642-
if self.config.target.contains("msvc") && self.config.cc != "" {
3638+
if self.config.target.contains("msvc") && !self.config.cc.is_empty() {
36433639
// We need to pass a path to `lib.exe`, so assume that `cc` is `cl.exe`
36443640
// and that `lib.exe` lives next to it.
36453641
let lib = Path::new(&self.config.cc).parent().unwrap().join("lib.exe");
@@ -3830,7 +3826,7 @@ impl<'test> TestCx<'test> {
38303826
&& !self.props.dont_check_compiler_stderr
38313827
{
38323828
self.fatal_proc_rec(
3833-
&format!("compiler output got truncated, cannot compare with reference file"),
3829+
"compiler output got truncated, cannot compare with reference file",
38343830
&proc_res,
38353831
);
38363832
}
@@ -4011,8 +4007,8 @@ impl<'test> TestCx<'test> {
40114007
crate_name.to_str().expect("crate name implies file name must be valid UTF-8");
40124008
// replace `a.foo` -> `a__foo` for crate name purposes.
40134009
// replace `revision-name-with-dashes` -> `revision_name_with_underscore`
4014-
let crate_name = crate_name.replace(".", "__");
4015-
let crate_name = crate_name.replace("-", "_");
4010+
let crate_name = crate_name.replace('.', "__");
4011+
let crate_name = crate_name.replace('-', "_");
40164012
rustc.arg("--crate-name");
40174013
rustc.arg(crate_name);
40184014
}
@@ -4060,7 +4056,7 @@ impl<'test> TestCx<'test> {
40604056
fn check_mir_dump(&self, test_info: MiroptTest) {
40614057
let test_dir = self.testpaths.file.parent().unwrap();
40624058
let test_crate =
4063-
self.testpaths.file.file_stem().unwrap().to_str().unwrap().replace("-", "_");
4059+
self.testpaths.file.file_stem().unwrap().to_str().unwrap().replace('-', "_");
40644060

40654061
let MiroptTest { run_filecheck, suffix, files, passes: _ } = test_info;
40664062

‎src/tools/compiletest/src/runtest/debugger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,5 @@ fn check_single_line(line: &str, check_line: &str) -> bool {
148148
rest = &rest[pos + current_fragment.len()..];
149149
}
150150

151-
if !can_end_anywhere && !rest.is_empty() { false } else { true }
151+
can_end_anywhere || rest.is_empty()
152152
}

‎src/tools/compiletest/src/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ fn test_extract_lldb_version() {
5858

5959
#[test]
6060
fn is_test_test() {
61-
assert_eq!(true, is_test(&OsString::from("a_test.rs")));
62-
assert_eq!(false, is_test(&OsString::from(".a_test.rs")));
63-
assert_eq!(false, is_test(&OsString::from("a_cat.gif")));
64-
assert_eq!(false, is_test(&OsString::from("#a_dog_gif")));
65-
assert_eq!(false, is_test(&OsString::from("~a_temp_file")));
61+
assert!(is_test(&OsString::from("a_test.rs")));
62+
assert!(!is_test(&OsString::from(".a_test.rs")));
63+
assert!(!is_test(&OsString::from("a_cat.gif")));
64+
assert!(!is_test(&OsString::from("#a_dog_gif")));
65+
assert!(!is_test(&OsString::from("~a_temp_file")));
6666
}
6767

6868
#[test]

‎src/tools/jsondoclint/src/validator.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,13 @@ impl<'a> Validator<'a> {
418418
} else {
419419
self.fail_expecting(id, expected);
420420
}
421-
} else {
422-
if !self.missing_ids.contains(id) {
423-
self.missing_ids.insert(id);
421+
} else if !self.missing_ids.contains(id) {
422+
self.missing_ids.insert(id);
424423

425-
let sels = json_find::find_selector(&self.krate_json, &Value::String(id.0.clone()));
426-
assert_ne!(sels.len(), 0);
424+
let sels = json_find::find_selector(&self.krate_json, &Value::String(id.0.clone()));
425+
assert_ne!(sels.len(), 0);
427426

428-
self.fail(id, ErrorKind::NotFound(sels))
429-
}
427+
self.fail(id, ErrorKind::NotFound(sels))
430428
}
431429
}
432430

‎src/tools/lint-docs/src/groups.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ impl<'a> LintExtractor<'a> {
121121
};
122122
to_link.extend(group_lints);
123123
let brackets: Vec<_> = group_lints.iter().map(|l| format!("[{}]", l)).collect();
124-
write!(result, "| {} | {} | {} |\n", group_name, description, brackets.join(", "))
124+
writeln!(result, "| {} | {} | {} |", group_name, description, brackets.join(", "))
125125
.unwrap();
126126
}
127127
result.push('\n');
128128
result.push_str("[warn-by-default]: listing/warn-by-default.md\n");
129129
for lint_name in to_link {
130-
let lint_def = match lints.iter().find(|l| l.name == lint_name.replace("-", "_")) {
130+
let lint_def = match lints.iter().find(|l| l.name == lint_name.replace('-', "_")) {
131131
Some(def) => def,
132132
None => {
133133
let msg = format!(
@@ -144,9 +144,9 @@ impl<'a> LintExtractor<'a> {
144144
}
145145
}
146146
};
147-
write!(
147+
writeln!(
148148
result,
149-
"[{}]: listing/{}#{}\n",
149+
"[{}]: listing/{}#{}",
150150
lint_name,
151151
lint_def.level.doc_filename(),
152152
lint_name

‎src/tools/lint-docs/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl Lint {
8484
for &expected in &["### Example", "### Explanation", "{{produces}}"] {
8585
if expected == "{{produces}}" && self.is_ignored() {
8686
if self.doc_contains("{{produces}}") {
87-
return Err(format!(
88-
"the lint example has `ignore`, but also contains the {{{{produces}}}} marker\n\
87+
return Err(
88+
"the lint example has `ignore`, but also contains the {{produces}} marker\n\
8989
\n\
9090
The documentation generator cannot generate the example output when the \
9191
example is ignored.\n\
@@ -111,7 +111,7 @@ impl Lint {
111111
Replacing the output with the text of the example you \
112112
compiled manually yourself.\n\
113113
"
114-
).into());
114+
.into());
115115
}
116116
continue;
117117
}
@@ -519,11 +519,11 @@ impl<'a> LintExtractor<'a> {
519519
let mut these_lints: Vec<_> = lints.iter().filter(|lint| lint.level == level).collect();
520520
these_lints.sort_unstable_by_key(|lint| &lint.name);
521521
for lint in &these_lints {
522-
write!(result, "* [`{}`](#{})\n", lint.name, lint.name.replace("_", "-")).unwrap();
522+
writeln!(result, "* [`{}`](#{})", lint.name, lint.name.replace('_', "-")).unwrap();
523523
}
524524
result.push('\n');
525525
for lint in &these_lints {
526-
write!(result, "## {}\n\n", lint.name.replace("_", "-")).unwrap();
526+
write!(result, "## {}\n\n", lint.name.replace('_', "-")).unwrap();
527527
for line in &lint.doc {
528528
result.push_str(line);
529529
result.push('\n');
@@ -583,7 +583,7 @@ fn add_rename_redirect(level: Level, output: &mut String) {
583583
let filename = level.doc_filename().replace(".md", ".html");
584584
output.push_str(RENAME_START);
585585
for (from, to) in *names {
586-
write!(output, " \"#{from}\": \"{filename}#{to}\",\n").unwrap();
586+
writeln!(output, " \"#{from}\": \"{filename}#{to}\",").unwrap();
587587
}
588588
output.push_str(RENAME_END);
589589
}

‎src/tools/opt-dist/src/training.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,9 @@ pub fn gather_bolt_profiles(
216216
log::info!("Profile file count: {}", profiles.len());
217217

218218
// Delete the gathered profiles
219-
for profile in glob::glob(&format!("{profile_prefix}*"))?.into_iter() {
220-
if let Ok(profile) = profile {
221-
if let Err(error) = std::fs::remove_file(&profile) {
222-
log::error!("Cannot delete BOLT profile {}: {error:?}", profile.display());
223-
}
219+
for profile in glob::glob(&format!("{profile_prefix}*"))?.flatten() {
220+
if let Err(error) = std::fs::remove_file(&profile) {
221+
log::error!("Cannot delete BOLT profile {}: {error:?}", profile.display());
224222
}
225223
}
226224

‎src/tools/remote-test-client/src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,11 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
317317
t!(io::copy(&mut (&mut client).take(amt), &mut stdout));
318318
t!(stdout.flush());
319319
}
320+
} else if amt == 0 {
321+
stderr_done = true;
320322
} else {
321-
if amt == 0 {
322-
stderr_done = true;
323-
} else {
324-
t!(io::copy(&mut (&mut client).take(amt), &mut stderr));
325-
t!(stderr.flush());
326-
}
323+
t!(io::copy(&mut (&mut client).take(amt), &mut stderr));
324+
t!(stderr.flush());
327325
}
328326
}
329327

‎src/tools/remote-test-server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
282282
cmd.env(library_path, env::join_paths(paths).unwrap());
283283

284284
// Some tests assume RUST_TEST_TMPDIR exists
285-
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
285+
cmd.env("RUST_TEST_TMPDIR", tmp);
286286

287287
let socket = Arc::new(Mutex::new(reader.into_inner()));
288288

‎src/tools/tidy/src/alphabetical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn check_section<'a>(
8888
let trimmed_line = line.trim_start_matches(' ');
8989

9090
if trimmed_line.starts_with("//")
91-
|| (trimmed_line.starts_with("#") && !trimmed_line.starts_with("#!"))
91+
|| (trimmed_line.starts_with('#') && !trimmed_line.starts_with("#!"))
9292
|| trimmed_line.starts_with(is_close_bracket)
9393
{
9494
continue;

‎src/tools/tidy/src/bins.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mod os_impl {
6161
fs::remove_file(&path).expect("Deleted temp file");
6262
// If the file is executable, then we assume that this
6363
// filesystem does not track executability, so skip this check.
64-
return if exec { Unsupported } else { Supported };
64+
if exec { Unsupported } else { Supported }
6565
}
6666
Err(e) => {
6767
// If the directory is read-only or we otherwise don't have rights,
@@ -76,7 +76,7 @@ mod os_impl {
7676

7777
panic!("unable to create temporary file `{:?}`: {:?}", path, e);
7878
}
79-
};
79+
}
8080
}
8181

8282
for &source_dir in sources {
@@ -92,7 +92,7 @@ mod os_impl {
9292
}
9393
}
9494

95-
return true;
95+
true
9696
}
9797

9898
// FIXME: check when rust-installer test sh files will be removed,

‎src/tools/tidy/src/deps.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,9 @@ fn check_permitted_dependencies(
699699
for dep in deps {
700700
let dep = pkg_from_id(metadata, dep);
701701
// If this path is in-tree, we don't require it to be explicitly permitted.
702-
if dep.source.is_some() {
703-
if !permitted_dependencies.contains(dep.name.as_str()) {
704-
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id);
705-
has_permitted_dep_error = true;
706-
}
702+
if dep.source.is_some() && !permitted_dependencies.contains(dep.name.as_str()) {
703+
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id);
704+
has_permitted_dep_error = true;
707705
}
708706
}
709707

‎src/tools/tidy/src/error_codes.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,9 @@ fn check_error_codes_tests(
308308
for line in file.lines() {
309309
let s = line.trim();
310310
// Assuming the line starts with `error[E`, we can substring the error code out.
311-
if s.starts_with("error[E") {
312-
if &s[6..11] == code {
313-
found_code = true;
314-
break;
315-
}
311+
if s.starts_with("error[E") && &s[6..11] == code {
312+
found_code = true;
313+
break;
316314
};
317315
}
318316

‎src/tools/tidy/src/ext_tool_checks.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ fn check_impl(
7878
let mut py_path = None;
7979

8080
let (cfg_args, file_args): (Vec<_>, Vec<_>) = pos_args
81-
.into_iter()
81+
.iter()
8282
.map(OsStr::new)
83-
.partition(|arg| arg.to_str().is_some_and(|s| s.starts_with("-")));
83+
.partition(|arg| arg.to_str().is_some_and(|s| s.starts_with('-')));
8484

8585
if python_lint || python_fmt {
8686
let venv_path = outdir.join("venv");
@@ -277,10 +277,11 @@ fn create_venv_at_path(path: &Path) -> Result<(), Error> {
277277

278278
let stderr = String::from_utf8_lossy(&out.stderr);
279279
let err = if stderr.contains("No module named virtualenv") {
280-
Error::Generic(format!(
280+
Error::Generic(
281281
"virtualenv not found: you may need to install it \
282282
(`python3 -m pip install venv`)"
283-
))
283+
.to_owned(),
284+
)
284285
} else {
285286
Error::Generic(format!(
286287
"failed to create venv at '{}' using {sys_py}: {stderr}",

‎src/tools/tidy/src/style.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,13 @@ pub fn check(path: &Path, bad: &mut bool) {
463463
}
464464
}
465465
// for now we just check libcore
466-
if trimmed.contains("unsafe {") && !trimmed.starts_with("//") && !last_safety_comment {
467-
if file.components().any(|c| c.as_os_str() == "core") && !is_test {
468-
suppressible_tidy_err!(err, skip_undocumented_unsafe, "undocumented unsafe");
469-
}
466+
if trimmed.contains("unsafe {")
467+
&& !trimmed.starts_with("//")
468+
&& !last_safety_comment
469+
&& file.components().any(|c| c.as_os_str() == "core")
470+
&& !is_test
471+
{
472+
suppressible_tidy_err!(err, skip_undocumented_unsafe, "undocumented unsafe");
470473
}
471474
if trimmed.contains("// SAFETY:") {
472475
last_safety_comment = true;
@@ -487,10 +490,10 @@ pub fn check(path: &Path, bad: &mut bool) {
487490
"copyright notices attributed to the Rust Project Developers are deprecated"
488491
);
489492
}
490-
if !file.components().any(|c| c.as_os_str() == "rustc_baked_icu_data") {
491-
if is_unexplained_ignore(&extension, line) {
492-
err(UNEXPLAINED_IGNORE_DOCTEST_INFO);
493-
}
493+
if !file.components().any(|c| c.as_os_str() == "rustc_baked_icu_data")
494+
&& is_unexplained_ignore(&extension, line)
495+
{
496+
err(UNEXPLAINED_IGNORE_DOCTEST_INFO);
494497
}
495498

496499
if filename.ends_with(".cpp") && line.contains("llvm_unreachable") {
@@ -525,26 +528,24 @@ pub fn check(path: &Path, bad: &mut bool) {
525528
backtick_count += comment_text.chars().filter(|ch| *ch == '`').count();
526529
}
527530
comment_block = Some((start_line, backtick_count));
528-
} else {
529-
if let Some((start_line, backtick_count)) = comment_block.take() {
530-
if backtick_count % 2 == 1 {
531-
let mut err = |msg: &str| {
532-
tidy_error!(bad, "{}:{start_line}: {msg}", file.display());
533-
};
534-
let block_len = (i + 1) - start_line;
535-
if block_len == 1 {
536-
suppressible_tidy_err!(
537-
err,
538-
skip_odd_backticks,
539-
"comment with odd number of backticks"
540-
);
541-
} else {
542-
suppressible_tidy_err!(
543-
err,
544-
skip_odd_backticks,
545-
"{block_len}-line comment block with odd number of backticks"
546-
);
547-
}
531+
} else if let Some((start_line, backtick_count)) = comment_block.take() {
532+
if backtick_count % 2 == 1 {
533+
let mut err = |msg: &str| {
534+
tidy_error!(bad, "{}:{start_line}: {msg}", file.display());
535+
};
536+
let block_len = (i + 1) - start_line;
537+
if block_len == 1 {
538+
suppressible_tidy_err!(
539+
err,
540+
skip_odd_backticks,
541+
"comment with odd number of backticks"
542+
);
543+
} else {
544+
suppressible_tidy_err!(
545+
err,
546+
skip_odd_backticks,
547+
"{block_len}-line comment block with odd number of backticks"
548+
);
548549
}
549550
}
550551
}

‎src/tools/tidy/src/walk.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,11 @@ pub(crate) fn walk_no_read(
7979
let walker = walker.filter_entry(move |e| {
8080
!skip(e.path(), e.file_type().map(|ft| ft.is_dir()).unwrap_or(false))
8181
});
82-
for entry in walker.build() {
83-
if let Ok(entry) = entry {
84-
if entry.file_type().map_or(true, |kind| kind.is_dir() || kind.is_symlink()) {
85-
continue;
86-
}
87-
f(&entry);
82+
for entry in walker.build().flatten() {
83+
if entry.file_type().map_or(true, |kind| kind.is_dir() || kind.is_symlink()) {
84+
continue;
8885
}
86+
f(&entry);
8987
}
9088
}
9189

@@ -97,11 +95,9 @@ pub(crate) fn walk_dir(
9795
) {
9896
let mut walker = ignore::WalkBuilder::new(path);
9997
let walker = walker.filter_entry(move |e| !skip(e.path()));
100-
for entry in walker.build() {
101-
if let Ok(entry) = entry {
102-
if entry.path().is_dir() {
103-
f(&entry);
104-
}
98+
for entry in walker.build().flatten() {
99+
if entry.path().is_dir() {
100+
f(&entry);
105101
}
106102
}
107103
}

‎src/tools/tidy/src/x_version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
5252
);
5353
}
5454
} else {
55-
return tidy_error!(bad, "failed to check version of `x`: {}", cargo_list.status);
55+
tidy_error!(bad, "failed to check version of `x`: {}", cargo_list.status)
5656
}
5757
}
5858

‎tests/rustdoc-gui/help-page.goml

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test that linking a no_std application still outputs the
2+
// `native-static-libs: ` note, even though it's empty.
3+
//@ compile-flags: -Cpanic=abort --print=native-static-libs
4+
//@ build-pass
5+
//@ ignore-wasm
6+
//@ ignore-cross-compile This doesn't produce any output on i686-unknown-linux-gnu for some reason?
7+
8+
#![crate_type = "staticlib"]
9+
#![no_std]
10+
11+
#[panic_handler]
12+
fn panic(_info: &core::panic::PanicInfo) -> ! {
13+
loop {}
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
2+
3+
note: native-static-libs:
4+

‎tests/ui/lint/non-local-defs/cargo-update.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
88
| `Debug` is not local
99
| move the `impl` block outside of this constant `_IMPL_DEBUG`
1010
|
11+
= note: the macro `non_local_macro::non_local_impl` defines the non-local `impl`, and may need to be changed
12+
= 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`
1113
= 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
1214
= 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`
13-
= 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`
1415
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
1516
= 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>
1617
= note: `#[warn(non_local_definitions)]` on by default

‎tests/ui/lint/non-local-defs/inside-macro_rules.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LL | impl MacroTrait for OutsideStruct {}
1212
LL | m!();
1313
| ---- in this macro invocation
1414
|
15+
= note: the macro `m` defines the non-local `impl`, and may need to be changed
1516
= 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
1617
= 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`
1718
= 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>

0 commit comments

Comments
 (0)
Please sign in to comment.