diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index bbbabf75d0805..0048977685858 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -637,16 +637,15 @@ impl<'hir> LoweringContext<'_, 'hir> { let (generics, (decl, fn_args)) = self.lower_generics(generics, itctx, |this| { ( // Disallow `impl Trait` in foreign items. - // Parameters are discarded because foreign functions don't have a body this.lower_fn_decl( fdec, i.id, hir_id, FnDeclKind::ExternFn, None, - DiscardParams::Yes, + DiscardParams::No, ), - this.lower_fn_params_to_idents(fdec), + this.lower_fn_params(fdec), ) }); @@ -1253,7 +1252,7 @@ impl<'hir> LoweringContext<'_, 'hir> { body_id } - fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> { + pub(super) fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> { let hir_id = self.lower_node_id(param.id); self.lower_attrs(hir_id, ¶m.attrs, param.span, AstTarget::Param(param)); hir::Param { diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 53896b05d87c0..426aaae6e0419 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1954,6 +1954,15 @@ impl<'hir> LoweringContext<'_, 'hir> { )) } + fn lower_fn_params(&mut self, decl: &FnDecl) -> &'hir [hir::Param<'hir>] { + self.arena.alloc_from_iter( + decl.inputs + .iter() + .filter(|param| !param.is_const_param()) + .map(|param| self.lower_param(param)), + ) + } + /// Lowers a function declaration. /// /// `decl`: the unlowered (AST) function declaration. diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 779b049063b8f..2ee73dbc58570 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -4876,12 +4876,7 @@ impl ForeignItem<'_> { #[derive(Debug, Clone, Copy, StableHash)] pub enum ForeignItemKind<'hir> { /// A foreign function. - /// - /// All argument idents are actually always present (i.e. `Some`), but - /// `&[Option]` is used because of code paths shared with `TraitFn` - /// and `FnPtrTy`. The sharing is due to all of these cases not allowing - /// arbitrary patterns for parameters. - Fn(FnSig<'hir>, &'hir [Option], &'hir Generics<'hir>), + Fn(FnSig<'hir>, &'hir [Param<'hir>], &'hir Generics<'hir>), /// A foreign static item (`static ext: u8`). Static(&'hir Ty<'hir>, Mutability, Safety), /// A foreign type. diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index bac88ad43ac30..cdb0cc524e6ce 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -690,11 +690,11 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>( try_visit!(visitor.visit_ident(*ident)); match *kind { - ForeignItemKind::Fn(ref sig, param_idents, ref generics) => { + ForeignItemKind::Fn(ref sig, params, ref generics) => { try_visit!(visitor.visit_generics(generics)); try_visit!(visitor.visit_fn_decl(sig.decl)); - for ident in param_idents.iter().copied() { - visit_opt!(visitor, visit_ident, ident); + for param in params { + try_visit!(visitor.visit_param(param)); } } ForeignItemKind::Static(ref typ, _, _) => { diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9bb2b89bfe6bf..ebbd62f694d4b 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -519,14 +519,15 @@ impl<'a> State<'a> { self.maybe_print_comment(item.span.lo()); self.print_attrs(self.attrs(item.hir_id())); match item.kind { - hir::ForeignItemKind::Fn(sig, arg_idents, generics) => { + hir::ForeignItemKind::Fn(sig, params, generics) => { let (cb, ib) = self.head(""); self.print_fn( sig.header, Some(item.ident.name), generics, sig.decl, - arg_idents, + &[], + params, None, ); self.end(ib); @@ -660,7 +661,15 @@ impl<'a> State<'a> { } hir::ItemKind::Fn { ident, sig, generics, body, .. } => { let (cb, ib) = self.head(""); - self.print_fn(sig.header, Some(ident.name), generics, sig.decl, &[], Some(body)); + self.print_fn( + sig.header, + Some(ident.name), + generics, + sig.decl, + &[], + &[], + Some(body), + ); self.word(" "); self.end(ib); self.end(cb); @@ -984,7 +993,7 @@ impl<'a> State<'a> { arg_idents: &[Option], body_id: Option, ) { - self.print_fn(m.header, Some(ident.name), generics, m.decl, arg_idents, body_id); + self.print_fn(m.header, Some(ident.name), generics, m.decl, arg_idents, &[], body_id); } fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) { @@ -2280,7 +2289,9 @@ impl<'a> State<'a> { name: Option, generics: &hir::Generics<'_>, decl: &hir::FnDecl<'_>, + // Will take from one of these three for the param names arg_idents: &[Option], + params: &[hir::Param<'_>], body_id: Option, ) { self.print_fn_header_info(header); @@ -2308,6 +2319,10 @@ impl<'a> State<'a> { s.word(":"); s.space(); } + } else if let Some(param) = params.get(i) { + s.print_param(param); + s.word(":"); + s.space(); } else if let Some(body_id) = body_id { s.ann.nested(s, Nested::BodyParamPat(body_id, i)); s.word(":"); @@ -2618,6 +2633,7 @@ impl<'a> State<'a> { generics, decl, arg_idents, + &[], None, ); self.end(ib); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 91afc6369d62b..b587629c1e2a6 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -2142,14 +2142,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { is_method: bool, ) -> Option<(IndexVec, FnParam<'_>)>, &hir::Generics<'_>)> { - let (sig, generics, body_id, params) = match self.tcx.hir_get_if_local(def_id)? { + let (sig, generics, params, idents) = match self.tcx.hir_get_if_local(def_id)? { hir::Node::TraitItem(&hir::TraitItem { generics, kind: hir::TraitItemKind::Fn(sig, trait_fn), .. }) => match trait_fn { hir::TraitFn::Required(params) => (sig, generics, None, Some(params)), - hir::TraitFn::Provided(body) => (sig, generics, Some(body), None), + hir::TraitFn::Provided(body) => { + (sig, generics, Some(self.tcx.hir_body(body).params), None) + } }, hir::Node::ImplItem(&hir::ImplItem { generics, @@ -2159,11 +2161,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | hir::Node::Item(&hir::Item { kind: hir::ItemKind::Fn { sig, generics, body, .. }, .. - }) => (sig, generics, Some(body), None), + }) => (sig, generics, Some(self.tcx.hir_body(body).params), None), hir::Node::ForeignItem(&hir::ForeignItem { kind: hir::ForeignItemKind::Fn(sig, params, generics), .. - }) => (sig, generics, None, Some(params)), + }) => (sig, generics, Some(params), None), _ => return None, }; @@ -2184,10 +2186,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } }); - let mut params_with_generics: IndexVec = match (body_id, params) { + let mut params_with_generics: IndexVec = match (params, idents) { (Some(_), Some(_)) | (None, None) => unreachable!(), - (Some(body), None) => { - let params = self.tcx.hir_body(body).params; + (Some(params), None) => { let params = params .get(is_method as usize..params.len() - sig.decl.c_variadic() as usize)?; debug_assert_eq!(params.len(), fn_inputs.len()); diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 66478f052d68b..2b569ea433313 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -7,7 +7,7 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{FnKind, Visitor}; -use rustc_hir::{GenericParamKind, PatExprKind, PatKind}; +use rustc_hir::{GenericParamKind, Node, PatExprKind, PatKind}; use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_middle::hir::nested_filter::All; use rustc_middle::ty::AssocContainer; @@ -439,17 +439,29 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { } fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) { - if let PatKind::Binding(_, hid, ident, _) = p.kind { - if let hir::Node::PatField(field) = cx.tcx.parent_hir_node(hid) { - if !field.is_shorthand { - // Only check if a new name has been introduced, to avoid warning - // on both the struct definition and this pattern. - self.check_snake_case(cx, "variable", &ident); - } - return; + let PatKind::Binding(_, hid, ident, _) = p.kind else { return }; + + // Ignore patterns in foreign items for + // FIXME(#33995) remove this check + if let Node::ForeignItem(_) = cx + .tcx + .hir_parent_iter(p.hir_id) + .find(|(_, n)| !matches!(n, Node::Pat(_) | Node::Param(_))) + .unwrap() + .1 + { + return; + } + + if let hir::Node::PatField(field) = cx.tcx.parent_hir_node(hid) { + if !field.is_shorthand { + // Only check if a new name has been introduced, to avoid warning + // on both the struct definition and this pattern. + self.check_snake_case(cx, "variable", &ident); } - self.check_snake_case(cx, "variable", &ident); + return; } + self.check_snake_case(cx, "variable", &ident); } fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) { diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index a1f931290f827..b0c4acd6a5950 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -310,7 +310,11 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn hir_body_param_idents(self, id: BodyId) -> impl Iterator> { - self.hir_body(id).params.iter().map(|param| match param.pat.kind { + self.param_idents(self.hir_body(id).params) + } + + pub fn param_idents(self, params: &[Param<'tcx>]) -> impl Iterator> { + params.iter().map(|param| match param.pat.kind { PatKind::Binding(_, _, ident, _) => Some(ident), PatKind::Wild => Some(Ident::new(kw::Underscore, param.pat.span)), _ => None, diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 18272069be5e7..bc1f9c1180b2b 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -479,13 +479,15 @@ pub fn provide(providers: &mut Providers) { let node = tcx.hir_node_by_def_id(def_id); if let Some(body_id) = node.body_id() { tcx.arena.alloc_from_iter(tcx.hir_body_param_idents(body_id)) + } else if let Node::ForeignItem(&ForeignItem { + kind: ForeignItemKind::Fn(_, params, _), + .. + }) = node + { + tcx.arena.alloc_from_iter(tcx.param_idents(params)) } else if let Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(_, TraitFn::Required(idents)), .. - }) - | Node::ForeignItem(&ForeignItem { - kind: ForeignItemKind::Fn(_, idents, _), - .. }) = node { idents diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ff5aeb1097799..8b27713c67939 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1112,7 +1112,7 @@ fn clean_fn_or_proc_macro<'tcx>( cx, sig, generics, - ParamsSrc::Body(body_id), + ParamsSrc::Params(cx.tcx.hir_body(body_id).params), item.owner_id.to_def_id(), ); let mut func = Function { generics, decl }; @@ -1145,8 +1145,8 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[rustc_attr_ } enum ParamsSrc<'tcx> { - Body(hir::BodyId), Idents(&'tcx [Option]), + Params(&'tcx [hir::Param<'tcx>]), } fn clean_function<'tcx>( @@ -1170,7 +1170,7 @@ fn clean_function<'tcx>( clean_poly_fn_sig(cx, Some(def_id), sig) } else { let params = match params { - ParamsSrc::Body(body_id) => clean_params_via_body(cx, sig.decl, body_id), + ParamsSrc::Params(body_id) => clean_params_via_body(cx, sig.decl, body_id), // Let's not perpetuate anon params from Rust 2015; use `_` for them. ParamsSrc::Idents(idents) => clean_params(cx, sig.decl, idents, |ident| { Some(ident.map_or(kw::Underscore, |ident| ident.name)) @@ -1203,11 +1203,11 @@ fn clean_params<'tcx>( fn clean_params_via_body<'tcx>( cx: &mut DocContext<'tcx>, decl: &hir::FnDecl<'tcx>, - body_id: hir::BodyId, + params: &'tcx [hir::Param<'tcx>], ) -> Vec { decl.inputs .iter() - .zip(cx.tcx.hir_body(body_id).params) + .zip(params) .enumerate() .map(|(i, (ty, param))| Parameter { name: Some(name_from_pat(param.pat)), @@ -1311,7 +1311,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext hir::TraitItemKind::Fn(ref sig, body) => { let (params, body) = match body { hir::TraitFn::Provided(body) => ( - ParamsSrc::Body(body), + ParamsSrc::Params(cx.tcx.hir_body(body).params), Some(Defaultness::from_trait_item(trait_item.defaultness)), ), hir::TraitFn::Required(idents) => (ParamsSrc::Idents(idents), None), @@ -1355,8 +1355,13 @@ pub(crate) fn clean_impl_item<'tcx>( })) } hir::ImplItemKind::Fn(ref sig, body) => { - let (generics, decl) = - clean_function(cx, sig, impl_.generics, ParamsSrc::Body(body), local_did); + let (generics, decl) = clean_function( + cx, + sig, + impl_.generics, + ParamsSrc::Params(cx.tcx.hir_body(body).params), + local_did, + ); ItemKind::AssocFunction(Box::new(AssocFunction { generics, decl, @@ -3373,9 +3378,9 @@ fn clean_maybe_renamed_foreign_item<'tcx>( let def_id = item.owner_id.to_def_id(); cx.with_param_env(def_id, |cx| { let kind = match item.kind { - hir::ForeignItemKind::Fn(sig, idents, generics) => { + hir::ForeignItemKind::Fn(sig, params, generics) => { let (generics, decl) = - clean_function(cx, &sig, generics, ParamsSrc::Idents(idents), def_id); + clean_function(cx, &sig, generics, ParamsSrc::Params(params), def_id); ItemKind::ForeignFunction( Box::new(Function { generics, decl }), sig.header.safety(), diff --git a/src/tools/clippy/clippy_lints/src/ignored_unit_patterns.rs b/src/tools/clippy/clippy_lints/src/ignored_unit_patterns.rs index 1a016c8862e0e..100c91206895d 100644 --- a/src/tools/clippy/clippy_lints/src/ignored_unit_patterns.rs +++ b/src/tools/clippy/clippy_lints/src/ignored_unit_patterns.rs @@ -39,7 +39,8 @@ impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns { fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx hir::Pat<'tcx>) { if matches!(pat.kind, PatKind::Wild) && !pat.span.from_expansion() - && cx.typeck_results().pat_ty(pat).peel_refs().is_unit() + && let Some(typeck_results) = cx.typeck_results + && typeck_results.pat_ty(pat).peel_refs().is_unit() { match cx.tcx.parent_hir_node(pat.hir_id) { Node::Param(param) if matches!(cx.tcx.parent_hir_node(param.hir_id), Node::Item(_)) => { diff --git a/src/tools/clippy/tests/ui/ignored_unit_patterns.fixed b/src/tools/clippy/tests/ui/ignored_unit_patterns.fixed index ed5273125e1a5..70d168fbc27ab 100644 --- a/src/tools/clippy/tests/ui/ignored_unit_patterns.fixed +++ b/src/tools/clippy/tests/ui/ignored_unit_patterns.fixed @@ -54,3 +54,16 @@ fn test_unit_ref_2(v: &[(usize, ())]) { let _ = x; } } + +unsafe extern "C" { + #[expect(improper_ctypes)] + fn test_extern_param(_: ()); +} + +trait Test { + fn test_required_param(_: ()); +} + +fn test_fn_ty() { + let x: fn(_: ()); +} diff --git a/src/tools/clippy/tests/ui/ignored_unit_patterns.rs b/src/tools/clippy/tests/ui/ignored_unit_patterns.rs index 6d6dab8cd3aa3..b377ccc6dc59c 100644 --- a/src/tools/clippy/tests/ui/ignored_unit_patterns.rs +++ b/src/tools/clippy/tests/ui/ignored_unit_patterns.rs @@ -54,3 +54,16 @@ fn test_unit_ref_2(v: &[(usize, ())]) { let _ = x; } } + +unsafe extern "C" { + #[expect(improper_ctypes)] + fn test_extern_param(_: ()); +} + +trait Test { + fn test_required_param(_: ()); +} + +fn test_fn_ty() { + let x: fn(_: ()); +} diff --git a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr index e4183e6d519ef..8204d53733aad 100644 --- a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr +++ b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr @@ -14,7 +14,7 @@ note: function defined here --> $DIR/extern-fn-arg-names.rs:2:8 | LL | fn dstfn(src: i32, dst: err); - | ^^^^^ --- + | ^^^^^ -------- help: provide the argument | LL | dstfn(1, /* dst */); diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index b7182887cfb78..e600bea41246e 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -20,7 +20,7 @@ note: function defined here --> $DIR/variadic-ffi-1.rs:22:8 | LL | fn foo(f: isize, x: u8, ...); - | ^^^ - - + | ^^^ -------- ----- help: provide the arguments | LL | foo(/* isize */, /* u8 */); @@ -36,7 +36,7 @@ note: function defined here --> $DIR/variadic-ffi-1.rs:22:8 | LL | fn foo(f: isize, x: u8, ...); - | ^^^ - + | ^^^ ----- help: provide the argument | LL | foo(1, /* u8 */); diff --git a/tests/ui/error-codes/E0060.stderr b/tests/ui/error-codes/E0060.stderr index 7065b623ad325..9bb5e6edbfef6 100644 --- a/tests/ui/error-codes/E0060.stderr +++ b/tests/ui/error-codes/E0060.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/E0060.rs:2:8 | LL | fn printf(_: *const u8, ...) -> u32; - | ^^^^^^ - + | ^^^^^^ ------------ help: provide the argument | LL | unsafe { printf(/* *const u8 */); } diff --git a/tests/ui/fn/param-mismatch-foreign.stderr b/tests/ui/fn/param-mismatch-foreign.stderr index 835e0a3343e9a..ae994bb658f25 100644 --- a/tests/ui/fn/param-mismatch-foreign.stderr +++ b/tests/ui/fn/param-mismatch-foreign.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/param-mismatch-foreign.rs:2:8 | LL | fn foo(x: i32, y: u32, z: i32); - | ^^^ - + | ^^^ ------ help: provide the argument | LL | foo(1i32, /* u32 */, 2i32); diff --git a/tests/ui/lint/lint-check-params.rs b/tests/ui/lint/lint-check-params.rs new file mode 100644 index 0000000000000..5af0144e9f136 --- /dev/null +++ b/tests/ui/lint/lint-check-params.rs @@ -0,0 +1,13 @@ +// Checks that a lint-check attribute applied to a foreign function parameter, +// only applies to that parameter + +#![deny(dead_code)] + +unsafe extern "C" { + //~v ERROR function `unused_foreign` is never used + fn unused_foreign( + #[allow(dead_code)] arg: i32, + ); +} + +fn main() {} diff --git a/tests/ui/lint/lint-check-params.stderr b/tests/ui/lint/lint-check-params.stderr new file mode 100644 index 0000000000000..0a4d19f5e9679 --- /dev/null +++ b/tests/ui/lint/lint-check-params.stderr @@ -0,0 +1,14 @@ +error: function `unused_foreign` is never used + --> $DIR/lint-check-params.rs:8:8 + | +LL | fn unused_foreign( + | ^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/lint-check-params.rs:4:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/non-snake-case/non-snake-foreign-fn-params.rs b/tests/ui/lint/non-snake-case/non-snake-foreign-fn-params.rs new file mode 100644 index 0000000000000..ebb6b1d3a7837 --- /dev/null +++ b/tests/ui/lint/non-snake-case/non-snake-foreign-fn-params.rs @@ -0,0 +1,9 @@ +//@ check-pass + +#![deny(non_snake_case)] + +extern "C" { + fn test(X: usize); // OK +} + +fn main() {} diff --git a/tests/ui/mismatched_types/issue-26480.stderr b/tests/ui/mismatched_types/issue-26480.stderr index ec91caed5e940..8e2683850c5f1 100644 --- a/tests/ui/mismatched_types/issue-26480.stderr +++ b/tests/ui/mismatched_types/issue-26480.stderr @@ -15,7 +15,7 @@ note: function defined here --> $DIR/issue-26480.rs:2:8 | LL | fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64; - | ^^^^^ ----- + | ^^^^^ ---------- help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit | LL | ($arr.len() * size_of($arr[0])).try_into().unwrap()); diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index 420b01102e41e..be15fb0df6a9c 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -86,10 +86,10 @@ hir-stats - Ptr 48 (NN.N%) 1 hir-stats - Ref 48 (NN.N%) 1 hir-stats - Path 624 (NN.N%) 13 hir-stats Generics 560 (NN.N%) 10 56 -hir-stats Pat 400 (NN.N%) 5 80 +hir-stats Pat 480 (NN.N%) 6 80 hir-stats - Struct 80 (NN.N%) 1 hir-stats - Wild 80 (NN.N%) 1 -hir-stats - Binding 240 (NN.N%) 3 +hir-stats - Binding 320 (NN.N%) 4 hir-stats GenericParam 400 (NN.N%) 5 80 hir-stats Block 288 (NN.N%) 6 48 hir-stats GenericBound 256 (NN.N%) 4 64 @@ -103,12 +103,12 @@ hir-stats Stmt 96 (NN.N%) 3 32 hir-stats - Expr 32 (NN.N%) 1 hir-stats - Let 32 (NN.N%) 1 hir-stats - Semi 32 (NN.N%) 1 +hir-stats Param 96 (NN.N%) 3 32 hir-stats Arm 80 (NN.N%) 2 40 hir-stats WherePredicate 72 (NN.N%) 3 24 hir-stats - BoundPredicate 72 (NN.N%) 3 hir-stats InlineAsm 72 (NN.N%) 1 72 hir-stats Body 72 (NN.N%) 3 24 -hir-stats Param 64 (NN.N%) 2 32 hir-stats Local 64 (NN.N%) 1 64 hir-stats GenericArg 64 (NN.N%) 4 16 hir-stats - Type 16 (NN.N%) 1 @@ -120,5 +120,5 @@ hir-stats TraitItemId 8 (NN.N%) 2 4 hir-stats ImplItemId 8 (NN.N%) 2 4 hir-stats ForeignItemId 4 (NN.N%) 1 4 hir-stats ---------------------------------------------------------------- -hir-stats Total 8_592 172 +hir-stats Total 8_704 174 hir-stats ================================================================ diff --git a/tests/ui/suggestions/suggest-null-ptr.stderr b/tests/ui/suggestions/suggest-null-ptr.stderr index 5be33d47237d2..bdc625c49c5b1 100644 --- a/tests/ui/suggestions/suggest-null-ptr.stderr +++ b/tests/ui/suggestions/suggest-null-ptr.stderr @@ -12,7 +12,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:7:8 | LL | fn foo(ptr: *const u8); - | ^^^ --- + | ^^^ -------------- help: if you meant to create a null pointer, use `std::ptr::null()` | LL - foo(0); @@ -33,7 +33,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:9:8 | LL | fn foo_mut(ptr: *mut u8); - | ^^^^^^^ --- + | ^^^^^^^ ------------ help: if you meant to create a null pointer, use `std::ptr::null_mut()` | LL - foo_mut(0); @@ -54,7 +54,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:11:8 | LL | fn usize(ptr: *const usize); - | ^^^^^ --- + | ^^^^^ ----------------- help: if you meant to create a null pointer, use `std::ptr::null()` | LL - usize(0); @@ -75,7 +75,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:13:8 | LL | fn usize_mut(ptr: *mut usize); - | ^^^^^^^^^ --- + | ^^^^^^^^^ --------------- help: if you meant to create a null pointer, use `std::ptr::null_mut()` | LL - usize_mut(0);