Skip to content

Commit 9f5c3e9

Browse files
committed
Remove lint from clippy
1 parent 37b72bc commit 9f5c3e9

File tree

7 files changed

+3
-140
lines changed

7 files changed

+3
-140
lines changed

src/tools/clippy/.github/driver.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ unset CARGO_MANIFEST_DIR
2222

2323
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
2424
# FIXME: How to match the clippy invocation in compile-test.rs?
25-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
26-
sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr
27-
diff normalized.stderr tests/ui/cstring.stderr
25+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cast.rs 2> cast.stderr && exit 1
26+
sed -e "s,tests/ui,\$DIR," -e "/= help/d" cast.stderr > normalized.stderr
27+
diff normalized.stderr tests/ui/cast.stderr
2828

2929

3030
# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same

src/tools/clippy/clippy_lints/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
689689
&methods::SKIP_WHILE_NEXT,
690690
&methods::STRING_EXTEND_CHARS,
691691
&methods::SUSPICIOUS_MAP,
692-
&methods::TEMPORARY_CSTRING_AS_PTR,
693692
&methods::UNINIT_ASSUMED_INIT,
694693
&methods::UNNECESSARY_FILTER_MAP,
695694
&methods::UNNECESSARY_FOLD,
@@ -1376,7 +1375,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13761375
LintId::of(&methods::SKIP_WHILE_NEXT),
13771376
LintId::of(&methods::STRING_EXTEND_CHARS),
13781377
LintId::of(&methods::SUSPICIOUS_MAP),
1379-
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
13801378
LintId::of(&methods::UNINIT_ASSUMED_INIT),
13811379
LintId::of(&methods::UNNECESSARY_FILTER_MAP),
13821380
LintId::of(&methods::UNNECESSARY_FOLD),
@@ -1721,7 +1719,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
17211719
LintId::of(&mem_replace::MEM_REPLACE_WITH_UNINIT),
17221720
LintId::of(&methods::CLONE_DOUBLE_REF),
17231721
LintId::of(&methods::ITERATOR_STEP_BY_ZERO),
1724-
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
17251722
LintId::of(&methods::UNINIT_ASSUMED_INIT),
17261723
LintId::of(&methods::ZST_OFFSET),
17271724
LintId::of(&minmax::MIN_MAX),

src/tools/clippy/clippy_lints/src/methods/mod.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -797,40 +797,6 @@ declare_clippy_lint! {
797797
"using a single-character str where a char could be used, e.g., `_.split(\"x\")`"
798798
}
799799

800-
declare_clippy_lint! {
801-
/// **What it does:** Checks for getting the inner pointer of a temporary
802-
/// `CString`.
803-
///
804-
/// **Why is this bad?** The inner pointer of a `CString` is only valid as long
805-
/// as the `CString` is alive.
806-
///
807-
/// **Known problems:** None.
808-
///
809-
/// **Example:**
810-
/// ```rust
811-
/// # use std::ffi::CString;
812-
/// # fn call_some_ffi_func(_: *const i8) {}
813-
/// #
814-
/// let c_str = CString::new("foo").unwrap().as_ptr();
815-
/// unsafe {
816-
/// call_some_ffi_func(c_str);
817-
/// }
818-
/// ```
819-
/// Here `c_str` points to a freed address. The correct use would be:
820-
/// ```rust
821-
/// # use std::ffi::CString;
822-
/// # fn call_some_ffi_func(_: *const i8) {}
823-
/// #
824-
/// let c_str = CString::new("foo").unwrap();
825-
/// unsafe {
826-
/// call_some_ffi_func(c_str.as_ptr());
827-
/// }
828-
/// ```
829-
pub TEMPORARY_CSTRING_AS_PTR,
830-
correctness,
831-
"getting the inner pointer of a temporary `CString`"
832-
}
833-
834800
declare_clippy_lint! {
835801
/// **What it does:** Checks for calling `.step_by(0)` on iterators which panics.
836802
///
@@ -1405,7 +1371,6 @@ declare_lint_pass!(Methods => [
14051371
SINGLE_CHAR_PATTERN,
14061372
SINGLE_CHAR_PUSH_STR,
14071373
SEARCH_IS_SOME,
1408-
TEMPORARY_CSTRING_AS_PTR,
14091374
FILTER_NEXT,
14101375
SKIP_WHILE_NEXT,
14111376
FILTER_MAP,
@@ -1486,7 +1451,6 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
14861451
lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0], method_spans[1])
14871452
},
14881453
["extend", ..] => lint_extend(cx, expr, arg_lists[0]),
1489-
["as_ptr", "unwrap" | "expect"] => lint_cstring_as_ptr(cx, expr, &arg_lists[1][0], &arg_lists[0][0]),
14901454
["nth", "iter"] => lint_iter_nth(cx, expr, &arg_lists, false),
14911455
["nth", "iter_mut"] => lint_iter_nth(cx, expr, &arg_lists, true),
14921456
["nth", ..] => lint_iter_nth_zero(cx, expr, arg_lists[0]),
@@ -2235,26 +2199,6 @@ fn lint_extend(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>
22352199
}
22362200
}
22372201

2238-
fn lint_cstring_as_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, source: &hir::Expr<'_>, unwrap: &hir::Expr<'_>) {
2239-
if_chain! {
2240-
let source_type = cx.typeck_results().expr_ty(source);
2241-
if let ty::Adt(def, substs) = source_type.kind();
2242-
if cx.tcx.is_diagnostic_item(sym!(result_type), def.did);
2243-
if match_type(cx, substs.type_at(0), &paths::CSTRING);
2244-
then {
2245-
span_lint_and_then(
2246-
cx,
2247-
TEMPORARY_CSTRING_AS_PTR,
2248-
expr.span,
2249-
"you are getting the inner pointer of a temporary `CString`",
2250-
|diag| {
2251-
diag.note("that pointer will be invalid outside this expression");
2252-
diag.span_help(unwrap.span, "assign the `CString` to a variable to extend its lifetime");
2253-
});
2254-
}
2255-
}
2256-
}
2257-
22582202
fn lint_iter_cloned_collect<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, iter_args: &'tcx [hir::Expr<'_>]) {
22592203
if_chain! {
22602204
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym!(vec_type));

src/tools/clippy/clippy_lints/src/utils/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
2121
pub const CMP_MAX: [&str; 3] = ["core", "cmp", "max"];
2222
pub const CMP_MIN: [&str; 3] = ["core", "cmp", "min"];
2323
pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"];
24-
pub const CSTRING: [&str; 4] = ["std", "ffi", "c_str", "CString"];
2524
pub const CSTRING_AS_C_STR: [&str; 5] = ["std", "ffi", "c_str", "CString", "as_c_str"];
2625
pub const DEFAULT_TRAIT: [&str; 3] = ["core", "default", "Default"];
2726
pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "default"];

src/tools/clippy/src/lintlist/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,13 +2187,6 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
21872187
deprecation: None,
21882188
module: "temporary_assignment",
21892189
},
2190-
Lint {
2191-
name: "temporary_cstring_as_ptr",
2192-
group: "correctness",
2193-
desc: "getting the inner pointer of a temporary `CString`",
2194-
deprecation: None,
2195-
module: "methods",
2196-
},
21972190
Lint {
21982191
name: "to_digit_is_some",
21992192
group: "style",

src/tools/clippy/tests/ui/cstring.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/tools/clippy/tests/ui/cstring.stderr

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)