mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #154469 - reddevilmidzy:mgca-lower, r=BoxyUwU
mGCA: Lower spans for literal const args resolve: https://github.com/rust-lang/rust/issues/152653 resolve: https://github.com/rust-lang/rust/issues/154636
This commit is contained in:
@@ -2683,7 +2683,7 @@ fn lower_expr_to_const_arg_direct(&mut self, expr: &Expr) -> hir::ConstArg<'hir>
|
||||
overly_complex_const(self)
|
||||
}
|
||||
ExprKind::Lit(literal) => {
|
||||
let span = expr.span;
|
||||
let span = self.lower_span(expr.span);
|
||||
let literal = self.lower_lit(literal, span);
|
||||
|
||||
ConstArg {
|
||||
@@ -2695,7 +2695,7 @@ fn lower_expr_to_const_arg_direct(&mut self, expr: &Expr) -> hir::ConstArg<'hir>
|
||||
ExprKind::Unary(UnOp::Neg, inner_expr)
|
||||
if let ExprKind::Lit(literal) = &inner_expr.kind =>
|
||||
{
|
||||
let span = expr.span;
|
||||
let span = self.lower_span(expr.span);
|
||||
let literal = self.lower_lit(literal, span);
|
||||
|
||||
if !matches!(literal.node, LitKind::Int(..)) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/152653>
|
||||
//! <https://github.com/rust-lang/rust/issues/154636>
|
||||
//@ incremental
|
||||
#![feature(min_generic_const_args)]
|
||||
type const R: usize = 1_i32; //~ ERROR: the constant `1` is not of type `usize`
|
||||
type const U: usize = -1_i32; //~ ERROR: the constant `-1` is not of type `usize`
|
||||
type const S: bool = 1i32; //~ ERROR: the constant `1` is not of type `bool`
|
||||
type const T: bool = -1i32; //~ ERROR: the constant `-1` is not of type `bool`
|
||||
|
||||
fn main() {
|
||||
R;
|
||||
U;
|
||||
S;
|
||||
T;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
error: the constant `1` is not of type `usize`
|
||||
--> $DIR/type_const-mismatched-type-incremental.rs:5:1
|
||||
|
|
||||
LL | type const R: usize = 1_i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i32`
|
||||
|
||||
error: the constant `-1` is not of type `usize`
|
||||
--> $DIR/type_const-mismatched-type-incremental.rs:6:1
|
||||
|
|
||||
LL | type const U: usize = -1_i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i32`
|
||||
|
||||
error: the constant `1` is not of type `bool`
|
||||
--> $DIR/type_const-mismatched-type-incremental.rs:7:1
|
||||
|
|
||||
LL | type const S: bool = 1i32;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `bool`, found `i32`
|
||||
|
||||
error: the constant `-1` is not of type `bool`
|
||||
--> $DIR/type_const-mismatched-type-incremental.rs:8:1
|
||||
|
|
||||
LL | type const T: bool = -1i32;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `bool`, found `i32`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Reference in New Issue
Block a user