Skip to content

Commit f5a13c1

Browse files
committed
1 parent 23a8541 commit f5a13c1

File tree

3 files changed

+9
-3
lines changed
  • driver/src
  • examples/restriction/inconsistent_qualification/src
  • utils/linting/src

3 files changed

+9
-3
lines changed

driver/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(rustc_private)]
2+
#![feature(string_leak)]
23
#![deny(clippy::expect_used)]
34
#![deny(clippy::unwrap_used)]
45
#![deny(clippy::panic)]
@@ -119,14 +120,16 @@ impl Callbacks {
119120
let lib = result.unwrap_or_else(|err| {
120121
// smoelius: rust-lang/rust#111633 changed the type of `early_error`'s `msg`
121122
// argument from `&str` to `impl Into<DiagnosticMessage>`.
123+
// smoelius: And rust-lang/rust#111748 made it that `msg` is borrowed for
124+
// `'static`. Since the program is about to exit, it's probably fine to leak the
125+
// string.
122126
rustc_session::early_error(
123127
rustc_session::config::ErrorOutputType::default(),
124128
format!(
125129
"could not load library `{}`: {}",
126130
path.to_string_lossy(),
127131
err
128-
)
129-
.as_str(),
132+
).leak(),
130133
);
131134
});
132135

examples/restriction/inconsistent_qualification/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ dylint_linting::declare_late_lint! {
5858
impl<'tcx> LateLintPass<'tcx> for InconsistentQualification {
5959
fn check_path(&mut self, cx: &LateContext<'tcx>, path: &Path<'tcx>, hir_id: HirId) {
6060
if_chain! {
61+
if !path.span.from_expansion();
6162
// smoelius: On the Dylint source code itself, simply checking
6263
// `path.span.in_derive_expansion()` isn't sufficient to prevent false positives.
6364
if !cx
@@ -161,6 +162,7 @@ impl<'cx, 'tcx, 'syms> Visitor<'tcx> for UseVisitor<'cx, 'tcx, 'syms> {
161162
UseKind::ListStem => false,
162163
};
163164
then {
165+
println!("{:#?}\n{:?}", self.path, item.hir_id());
164166
let prefix = self
165167
.syms_prefix
166168
.iter()

utils/linting/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
//! [examples]: ../../examples
169169
170170
#![feature(rustc_private)]
171+
#![feature(string_leak)]
171172
#![warn(unused_extern_crates)]
172173

173174
#[allow(unused_extern_crates)]
@@ -457,7 +458,7 @@ pub fn init_config(sess: &rustc_session::Session) {
457458
try_init_config(sess).unwrap_or_else(|err| {
458459
rustc_session::early_error(
459460
rustc_session::config::ErrorOutputType::default(),
460-
format!("could not read configuration file: {err}").as_str(),
461+
format!("could not read configuration file: {err}").leak(),
461462
);
462463
});
463464
}

0 commit comments

Comments
 (0)