Skip to content

Commit

Permalink
Auto merge of rust-lang#135327 - jhpratt:rollup-5uyir52, r=jhpratt
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#132607 (Used pthread name functions returning result for FreeBSD and DragonFly)
 - rust-lang#134693 (proc_macro: Use `ToTokens` trait in `quote` macro)
 - rust-lang#134732 (Unify conditional-const error reporting with non-const error reporting)
 - rust-lang#135083 (Do not ICE when encountering predicates from other items in method error reporting)
 - rust-lang#135251 (Only treat plain literal patterns as short)
 - rust-lang#135320 (Fix typo in `#[coroutine]` gating error)
 - rust-lang#135321 (remove more redundant into() conversions)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 10, 2025
2 parents b44e14f + b557f1b commit 252b07b
Show file tree
Hide file tree
Showing 45 changed files with 1,162 additions and 399 deletions.
59 changes: 31 additions & 28 deletions compiler/rustc_const_eval/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const_eval_already_reported =
const_eval_assume_false =
`assume` called with `false`
const_eval_await_non_const =
cannot convert `{$ty}` into a future in {const_eval_const_context}s
const_eval_bounds_check_failed =
indexing out of bounds: the len is {$len} but the index is {$index}
const_eval_call_nonzero_intrinsic =
Expand All @@ -23,11 +21,6 @@ const_eval_closure_call =
closures need an RFC before allowed to be called in {const_eval_const_context}s
const_eval_closure_fndef_not_const =
function defined here, but it is not `const`
const_eval_closure_non_const =
cannot call non-const closure in {const_eval_const_context}s
const_eval_conditionally_const_call =
cannot call conditionally-const {$def_descr} `{$def_path_str}` in {const_eval_const_context}s
const_eval_consider_dereferencing =
consider dereferencing here
Expand Down Expand Up @@ -62,10 +55,6 @@ const_eval_dealloc_incorrect_layout =
const_eval_dealloc_kind_mismatch =
deallocating {$alloc}, which is {$alloc_kind} memory, using {$kind} deallocation operation
const_eval_deref_coercion_non_const =
cannot perform deref coercion on `{$ty}` in {const_eval_const_context}s
.note = attempting to deref into `{$target_ty}`
.target_note = deref defined here
const_eval_deref_function_pointer =
accessing {$allocation} which contains a function
const_eval_deref_vtable_pointer =
Expand Down Expand Up @@ -109,9 +98,6 @@ const_eval_extern_type_field = `extern type` field does not have a known offset
const_eval_fn_ptr_call =
function pointers need an RFC before allowed to be called in {const_eval_const_context}s
const_eval_for_loop_into_iter_non_const =
cannot use `for` loop on `{$ty}` in {const_eval_const_context}s
const_eval_frame_note = {$times ->
[0] {const_eval_frame_note_inner}
*[other] [... {$times} additional calls {const_eval_frame_note_inner} ...]
Expand Down Expand Up @@ -216,9 +202,6 @@ const_eval_long_running =
.label = the const evaluator is currently interpreting this expression
.help = the constant being evaluated
const_eval_match_eq_non_const = cannot match on `{$ty}` in {const_eval_const_context}s
.note = `{$ty}` cannot be compared in compile-time, and therefore cannot be used in `match`es
const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id}
const_eval_memory_access_test = memory access failed
Expand Down Expand Up @@ -249,18 +232,47 @@ const_eval_mutable_ref_escaping =
If you really want global mutable state, try using an interior mutable `static` or a `static mut`.
const_eval_nested_static_in_thread_local = #[thread_local] does not support implicit nested statics, please create explicit static items and refer to them instead
const_eval_non_const_await =
cannot convert `{$ty}` into a future in {const_eval_const_context}s
const_eval_non_const_closure =
cannot call {$non_or_conditionally}-const closure in {const_eval_const_context}s
const_eval_non_const_deref_coercion =
cannot perform {$non_or_conditionally}-const deref coercion on `{$ty}` in {const_eval_const_context}s
.note = attempting to deref into `{$target_ty}`
.target_note = deref defined here
const_eval_non_const_fmt_macro_call =
cannot call non-const formatting macro in {const_eval_const_context}s
cannot call {$non_or_conditionally}-const formatting macro in {const_eval_const_context}s
const_eval_non_const_fn_call =
cannot call non-const {$def_descr} `{$def_path_str}` in {const_eval_const_context}s
cannot call {$non_or_conditionally}-const {$def_descr} `{$def_path_str}` in {const_eval_const_context}s
const_eval_non_const_for_loop_into_iter =
cannot use `for` loop on `{$ty}` in {const_eval_const_context}s
const_eval_non_const_impl =
impl defined here, but it is not `const`
const_eval_non_const_intrinsic =
cannot call non-const intrinsic `{$name}` in {const_eval_const_context}s
const_eval_non_const_match_eq = cannot match on `{$ty}` in {const_eval_const_context}s
.note = `{$ty}` cannot be compared in compile-time, and therefore cannot be used in `match`es
const_eval_non_const_operator =
cannot call {$non_or_conditionally}-const operator in {const_eval_const_context}s
const_eval_non_const_question_branch =
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
const_eval_non_const_question_from_residual =
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
const_eval_non_const_try_block_from_output =
`try` block cannot convert `{$ty}` to the result in {const_eval_const_context}s
const_eval_not_enough_caller_args =
calling a function with fewer arguments than it requires
Expand All @@ -281,8 +293,6 @@ const_eval_offset_from_unsigned_overflow =
*[false] offset
} than second: {$a_offset} < {$b_offset}
const_eval_operator_non_const =
cannot call non-const operator in {const_eval_const_context}s
const_eval_overflow_arith =
arithmetic overflow in `{$intrinsic}`
const_eval_overflow_shift =
Expand Down Expand Up @@ -325,11 +335,6 @@ const_eval_ptr_as_bytes_1 =
const_eval_ptr_as_bytes_2 =
the absolute address of a pointer is not known at compile-time, so such operations are not supported
const_eval_question_branch_non_const =
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
const_eval_question_from_residual_non_const =
`?` is not allowed on `{$ty}` in {const_eval_const_context}s
const_eval_range = in the range {$lo}..={$hi}
const_eval_range_lower = greater or equal to {$lo}
const_eval_range_singular = equal to {$lo}
Expand Down Expand Up @@ -379,8 +384,6 @@ const_eval_too_generic =
const_eval_too_many_caller_args =
calling a function with more arguments than it expected
const_eval_try_block_from_output_non_const =
`try` block cannot convert `{$ty}` to the result in {const_eval_const_context}s
const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {const_eval_const_context}s
const_eval_unallowed_heap_allocations =
Expand Down
14 changes: 12 additions & 2 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {

if trait_is_const {
// Trait calls are always conditionally-const.
self.check_op(ops::ConditionallyConstCall { callee, args: fn_args });
self.check_op(ops::ConditionallyConstCall {
callee,
args: fn_args,
span: *fn_span,
call_source,
});
// FIXME(const_trait_impl): do a more fine-grained check whether this
// particular trait can be const-stably called.
} else {
Expand All @@ -726,7 +731,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {

// Even if we know the callee, ensure we can use conditionally-const calls.
if has_const_conditions {
self.check_op(ops::ConditionallyConstCall { callee, args: fn_args });
self.check_op(ops::ConditionallyConstCall {
callee,
args: fn_args,
span: *fn_span,
call_source,
});
}

// At this point, we are calling a function, `callee`, whose `DefId` is known...
Expand Down
Loading

0 comments on commit 252b07b

Please sign in to comment.