|
1 |
| -error: internal compiler error: src/librustc_middle/ty/context.rs:516: node_type: no type for node `expr N (hir_id=HirId { owner: DefId(0:8 ~ could_be_const[317d]::{{impl}}[0]::const_generic_params[0]), local_id: 22 })` |
| 1 | +error: this could be a `const fn` |
| 2 | + --> $DIR/could_be_const.rs:13:5 |
| 3 | + | |
| 4 | +LL | / pub fn new() -> Self { |
| 5 | +LL | | Self { guess: 42 } |
| 6 | +LL | | } |
| 7 | + | |_____^ |
| 8 | + | |
| 9 | + = note: `-D clippy::missing-const-for-fn` implied by `-D warnings` |
2 | 10 |
|
3 |
| -thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:904:9 |
4 |
| -stack backtrace: |
5 |
| - 0: backtrace::backtrace::libunwind::trace |
6 |
| - at /cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86 |
7 |
| - 1: backtrace::backtrace::trace_unsynchronized |
8 |
| - at /cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66 |
9 |
| - 2: std::sys_common::backtrace::_print_fmt |
10 |
| - at src/libstd/sys_common/backtrace.rs:78 |
11 |
| - 3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt |
12 |
| - at src/libstd/sys_common/backtrace.rs:59 |
13 |
| - 4: core::fmt::write |
14 |
| - at src/libcore/fmt/mod.rs:1069 |
15 |
| - 5: std::io::Write::write_fmt |
16 |
| - at src/libstd/io/mod.rs:1504 |
17 |
| - 6: std::sys_common::backtrace::_print |
18 |
| - at src/libstd/sys_common/backtrace.rs:62 |
19 |
| - 7: std::sys_common::backtrace::print |
20 |
| - at src/libstd/sys_common/backtrace.rs:49 |
21 |
| - 8: std::panicking::default_hook::{{closure}} |
22 |
| - at src/libstd/panicking.rs:198 |
23 |
| - 9: std::panicking::default_hook |
24 |
| - at src/libstd/panicking.rs:218 |
25 |
| - 10: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call |
26 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/liballoc/boxed.rs:1038 |
27 |
| - 11: clippy_driver::report_clippy_ice |
28 |
| - at src/driver.rs:242 |
29 |
| - 12: <clippy_driver::ICE_HOOK as core::ops::deref::Deref>::deref::__static_ref_initialize::{{closure}} |
30 |
| - at src/driver.rs:235 |
31 |
| - 13: std::panicking::rust_panic_with_hook |
32 |
| - at src/libstd/panicking.rs:481 |
33 |
| - 14: std::panicking::begin_panic |
34 |
| - 15: rustc_errors::HandlerInner::bug |
35 |
| - 16: rustc_errors::Handler::bug |
36 |
| - 17: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}} |
37 |
| - 18: rustc_middle::ty::context::tls::with_opt::{{closure}} |
38 |
| - 19: rustc_middle::ty::context::tls::with_opt |
39 |
| - 20: rustc_middle::util::bug::opt_span_bug_fmt |
40 |
| - 21: rustc_middle::util::bug::bug_fmt |
41 |
| - 22: rustc_middle::ty::context::TypeckTables::node_type::{{closure}} |
42 |
| - 23: rustc_middle::ty::context::TypeckTables::node_type |
43 |
| - 24: <clippy_lints::use_self::ImplVisitor as rustc_hir::intravisit::Visitor>::visit_expr::expr_ty_matches |
44 |
| - at clippy_lints/src/use_self.rs:184 |
45 |
| - 25: <clippy_lints::use_self::ImplVisitor as rustc_hir::intravisit::Visitor>::visit_expr |
46 |
| - at clippy_lints/src/use_self.rs:219 |
47 |
| - 26: rustc_hir::intravisit::walk_body |
48 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:485 |
49 |
| - 27: rustc_hir::intravisit::Visitor::visit_body |
50 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:302 |
51 |
| - 28: rustc_hir::intravisit::Visitor::visit_nested_body |
52 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_ast/visit.rs:236 |
53 |
| - 29: rustc_hir::intravisit::walk_anon_const |
54 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:1061 |
55 |
| - 30: rustc_hir::intravisit::Visitor::visit_anon_const |
56 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:348 |
57 |
| - 31: rustc_hir::intravisit::walk_ty |
58 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:698 |
59 |
| - 32: <clippy_lints::use_self::ImplVisitor as rustc_hir::intravisit::Visitor>::visit_ty |
60 |
| - at clippy_lints/src/use_self.rs:179 |
61 |
| - 33: rustc_hir::intravisit::walk_ty |
62 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:679 |
63 |
| - 34: <clippy_lints::use_self::ImplVisitor as rustc_hir::intravisit::Visitor>::visit_ty |
64 |
| - at clippy_lints/src/use_self.rs:179 |
65 |
| - 35: rustc_hir::intravisit::walk_fn_decl |
66 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:901 |
67 |
| - 36: rustc_hir::intravisit::Visitor::visit_fn_decl |
68 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:366 |
69 |
| - 37: rustc_hir::intravisit::walk_fn |
70 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:924 |
71 |
| - 38: rustc_hir::intravisit::Visitor::visit_fn |
72 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:369 |
73 |
| - 39: rustc_hir::intravisit::walk_impl_item |
74 |
| - at /rustc/7f3b3df9e2f2efe3434b4f6fc76462d2c8ad332f/src/librustc_hir/intravisit.rs:997 |
75 |
| - 40: <clippy_lints::use_self::ImplVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item |
76 |
| - at clippy_lints/src/use_self.rs:240 |
77 |
| - 41: <clippy_lints::use_self::UseSelf as rustc_lint::passes::LateLintPass>::check_item |
78 |
| - at clippy_lints/src/use_self.rs:276 |
79 |
| - 42: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_item |
80 |
| - 43: rustc_hir::intravisit::Visitor::visit_nested_item |
81 |
| - 44: rustc_hir::intravisit::walk_crate |
82 |
| - 45: rustc_lint::late::late_lint_pass_crate |
83 |
| - 46: rustc_session::utils::<impl rustc_session::session::Session>::time |
84 |
| - 47: rustc_session::utils::<impl rustc_session::session::Session>::time |
85 |
| - 48: rustc_interface::passes::analysis::{{closure}}::{{closure}} |
86 |
| - 49: rustc_session::utils::<impl rustc_session::session::Session>::time |
87 |
| - 50: rustc_interface::passes::analysis |
88 |
| - 51: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute |
89 |
| - 52: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl |
90 |
| - 53: rustc_query_system::query::plumbing::get_query |
91 |
| - 54: rustc_middle::ty::context::tls::enter_global |
92 |
| - 55: rustc_interface::interface::run_compiler_in_existing_thread_pool |
93 |
| - 56: scoped_tls::ScopedKey<T>::set |
94 |
| - 57: rustc_ast::attr::with_globals |
95 |
| -note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. |
| 11 | +error: this could be a `const fn` |
| 12 | + --> $DIR/could_be_const.rs:17:5 |
| 13 | + | |
| 14 | +LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { |
| 15 | +LL | | b |
| 16 | +LL | | } |
| 17 | + | |_____^ |
96 | 18 |
|
97 |
| -note: the compiler unexpectedly panicked. this is a bug. |
| 19 | +error: this could be a `const fn` |
| 20 | + --> $DIR/could_be_const.rs:23:1 |
| 21 | + | |
| 22 | +LL | / fn one() -> i32 { |
| 23 | +LL | | 1 |
| 24 | +LL | | } |
| 25 | + | |_^ |
98 | 26 |
|
99 |
| -note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new |
| 27 | +error: this could be a `const fn` |
| 28 | + --> $DIR/could_be_const.rs:28:1 |
| 29 | + | |
| 30 | +LL | / fn two() -> i32 { |
| 31 | +LL | | let abc = 2; |
| 32 | +LL | | abc |
| 33 | +LL | | } |
| 34 | + | |_^ |
100 | 35 |
|
101 |
| -note: Clippy version: clippy 0.0.212 (87a6f3fc 2020-04-26) |
| 36 | +error: this could be a `const fn` |
| 37 | + --> $DIR/could_be_const.rs:34:1 |
| 38 | + | |
| 39 | +LL | / fn string() -> String { |
| 40 | +LL | | String::new() |
| 41 | +LL | | } |
| 42 | + | |_^ |
102 | 43 |
|
103 |
| -query stack during panic: |
104 |
| -#0 [analysis] running analysis passes on this crate |
105 |
| -end of query stack |
106 |
| -error: aborting due to previous error |
| 44 | +error: this could be a `const fn` |
| 45 | + --> $DIR/could_be_const.rs:39:1 |
| 46 | + | |
| 47 | +LL | / unsafe fn four() -> i32 { |
| 48 | +LL | | 4 |
| 49 | +LL | | } |
| 50 | + | |_^ |
| 51 | + |
| 52 | +error: this could be a `const fn` |
| 53 | + --> $DIR/could_be_const.rs:44:1 |
| 54 | + | |
| 55 | +LL | / fn generic<T>(t: T) -> T { |
| 56 | +LL | | t |
| 57 | +LL | | } |
| 58 | + | |_^ |
| 59 | + |
| 60 | +error: this could be a `const fn` |
| 61 | + --> $DIR/could_be_const.rs:48:1 |
| 62 | + | |
| 63 | +LL | / fn sub(x: u32) -> usize { |
| 64 | +LL | | unsafe { transmute(&x) } |
| 65 | +LL | | } |
| 66 | + | |_^ |
| 67 | + |
| 68 | +error: this could be a `const fn` |
| 69 | + --> $DIR/could_be_const.rs:67:9 |
| 70 | + | |
| 71 | +LL | / pub fn b(self, a: &A) -> B { |
| 72 | +LL | | B |
| 73 | +LL | | } |
| 74 | + | |_________^ |
| 75 | + |
| 76 | +error: aborting due to 9 previous errors |
107 | 77 |
|
0 commit comments