Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #127529

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
90cbd0b
impl FusedIterator and a size hint for the error sources iter
Sky9x Jun 28, 2024
321eba5
Update f16/f128 FIXMEs that needed (NEG_)INFINITY
tgross35 Jul 8, 2024
ec662e7
`#[doc(alias)]`'s doc: say that ASCII spaces are allowed
ShE3py Jul 8, 2024
96a7916
Update a f16/f128 FIXME to be more accurate
tgross35 Jul 8, 2024
7097dbc
exhaustively destructure external constraints
lcnr Jul 9, 2024
e38109d
use `update_parent_goal` for lazy updates
lcnr Jul 9, 2024
fd9a925
Automatically taint when reporting errors from ItemCtxt
oli-obk Jul 5, 2024
aece064
Remove HirTyLowerer::set_tainted_by_errors, since it is now redundant
oli-obk Jul 5, 2024
dd175fe
cycle_participants to nested_goals
lcnr Jul 9, 2024
7af825f
Split out overflow handling into its own module
compiler-errors Jul 8, 2024
cd68a28
Move some stuff into the ambiguity and suggestion modules
compiler-errors Jul 8, 2024
bbbff80
Split out fulfillment error reporting a bit more
compiler-errors Jul 8, 2024
4325467
Use verbose style when suggesting changing `const` with `let`
estebank Jul 5, 2024
a57dfdb
Account for `let foo = expr`; to suggest `const foo: Ty = expr;`
estebank Jul 8, 2024
6405df5
Fix aarch64 test
estebank Jul 9, 2024
ea392e1
Rollup merge of #127091 - Sky9x:fused-error-sources-iter, r=dtolnay
matthiaskrgr Jul 9, 2024
312a76b
Rollup merge of #127358 - oli-obk:taint_itemctxt, r=fmease
matthiaskrgr Jul 9, 2024
26569e8
Rollup merge of #127382 - estebank:const-let, r=compiler-errors
matthiaskrgr Jul 9, 2024
1df9bfe
Rollup merge of #127484 - ShE3py:rustdoc-doc-alias-whitespace-doc, r=…
matthiaskrgr Jul 9, 2024
5f64cfc
Rollup merge of #127495 - compiler-errors:more-trait-error-reworking,…
matthiaskrgr Jul 9, 2024
cdb013b
Rollup merge of #127496 - tgross35:f16-f128-pattern-fixme, r=Nadrieril
matthiaskrgr Jul 9, 2024
0cda246
Rollup merge of #127508 - lcnr:search-graph-prep, r=compiler-errors
matthiaskrgr Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use verbose style when suggesting changing const with let
  • Loading branch information
estebank committed Jul 9, 2024
commit 43254672bdef83fa9d69da3b875bd79f249f62f7
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ impl<'a> Parser<'a> {
self.dcx().struct_span_err(non_item_span, "non-item in item list");
self.consume_block(Delimiter::Brace, ConsumeClosingDelim::Yes);
if is_let {
err.span_suggestion(
err.span_suggestion_verbose(
non_item_span,
"consider using `const` instead of `let` for associated const",
"const",
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {

let ((with, with_label), without) = match sp {
Some(sp) if !self.tcx.sess.source_map().is_multiline(sp) => {
let sp = sp.with_lo(BytePos(sp.lo().0 - (current.len() as u32)));
let sp = sp
.with_lo(BytePos(sp.lo().0 - (current.len() as u32)))
.until(ident.span);
(
(Some(errs::AttemptToUseNonConstantValueInConstantWithSuggestion {
span: sp,
ident,
suggestion,
current,
}), Some(errs::AttemptToUseNonConstantValueInConstantLabelWithSuggestion {span})),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ pub(crate) struct AttemptToUseNonConstantValueInConstant<'a> {
#[derive(Subdiagnostic)]
#[suggestion(
resolve_attempt_to_use_non_constant_value_in_constant_with_suggestion,
code = "{suggestion} {ident}",
code = "{suggestion} ",
style = "verbose",
applicability = "maybe-incorrect"
)]
pub(crate) struct AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
#[primary_span]
pub(crate) span: Span,
pub(crate) ident: Ident,
pub(crate) suggestion: &'a str,
pub(crate) current: &'a str,
}
Expand Down
40 changes: 25 additions & 15 deletions tests/ui/asm/parse-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -371,47 +371,57 @@ LL | global_asm!("{}", label {});
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/parse-error.rs:39:37
|
LL | let mut foo = 0;
| ----------- help: consider using `const` instead of `let`: `const foo`
...
LL | asm!("{}", options(), const foo);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/parse-error.rs:71:44
|
LL | let mut foo = 0;
| ----------- help: consider using `const` instead of `let`: `const foo`
...
LL | asm!("{}", clobber_abi("C"), const foo);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/parse-error.rs:74:55
|
LL | let mut foo = 0;
| ----------- help: consider using `const` instead of `let`: `const foo`
...
LL | asm!("{}", options(), clobber_abi("C"), const foo);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/parse-error.rs:76:31
|
LL | let mut foo = 0;
| ----------- help: consider using `const` instead of `let`: `const foo`
...
LL | asm!("{a}", a = const foo, a = const bar);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/parse-error.rs:76:46
|
LL | let mut bar = 0;
| ----------- help: consider using `const` instead of `let`: `const bar`
...
LL | asm!("{a}", a = const foo, a = const bar);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const bar = 0;
| ~~~~~

error: aborting due to 64 previous errors

Expand Down
24 changes: 15 additions & 9 deletions tests/ui/asm/type-check-1.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/type-check-1.rs:41:26
|
LL | let x = 0;
| ----- help: consider using `const` instead of `let`: `const x`
...
LL | asm!("{}", const x);
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const x = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/type-check-1.rs:44:36
|
LL | let x = 0;
| ----- help: consider using `const` instead of `let`: `const x`
...
LL | asm!("{}", const const_foo(x));
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const x = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/type-check-1.rs:47:36
|
LL | let x = 0;
| ----- help: consider using `const` instead of `let`: `const x`
...
LL | asm!("{}", const const_bar(x));
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const x = 0;
| ~~~~~

error: invalid `sym` operand
--> $DIR/type-check-1.rs:49:24
Expand Down
24 changes: 15 additions & 9 deletions tests/ui/asm/x86_64/x86_64_parse_error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,35 @@ LL | asm!("{1}", in("eax") foo, const bar);
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:13:46
|
LL | let mut bar = 0;
| ----------- help: consider using `const` instead of `let`: `const bar`
...
LL | asm!("{a}", in("eax") foo, a = const bar);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const bar = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:15:46
|
LL | let mut bar = 0;
| ----------- help: consider using `const` instead of `let`: `const bar`
...
LL | asm!("{a}", in("eax") foo, a = const bar);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const bar = 0;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/x86_64_parse_error.rs:17:42
|
LL | let mut bar = 0;
| ----------- help: consider using `const` instead of `let`: `const bar`
...
LL | asm!("{1}", in("eax") foo, const bar);
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const bar = 0;
| ~~~~~

error: aborting due to 5 previous errors

Expand Down
7 changes: 5 additions & 2 deletions tests/ui/const-generics/legacy-const-generics-bad.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/legacy-const-generics-bad.rs:7:35
|
LL | let a = 1;
| ----- help: consider using `const` instead of `let`: `const a`
LL | legacy_const_generics::foo(0, a, 2);
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const a = 1;
| ~~~~~

error: generic parameters may not be used in const operations
--> $DIR/legacy-const-generics-bad.rs:12:35
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/consts/issue-3521.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-3521.rs:8:15
|
LL | let foo: isize = 100;
| ------- help: consider using `const` instead of `let`: `const foo`
...
LL | Bar = foo
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo: isize = 100;
| ~~~~~

error: aborting due to 1 previous error

Expand Down
16 changes: 10 additions & 6 deletions tests/ui/consts/issue-91560.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-91560.rs:10:19
|
LL | let mut length: usize = 2;
| -------------- help: consider using `const` instead of `let`: `const length`
LL |
LL | let arr = [0; length];
| ^^^^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const length: usize = 2;
| ~~~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-91560.rs:17:19
|
LL | let length: usize = 2;
| ------------ help: consider using `const` instead of `let`: `const length`
LL |
LL | let arr = [0; length];
| ^^^^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const length: usize = 2;
| ~~~~~

error: aborting due to 2 previous errors

Expand Down
17 changes: 11 additions & 6 deletions tests/ui/consts/non-const-value-in-const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/non-const-value-in-const.rs:3:20
|
LL | const Y: i32 = x;
| ------- ^ non-constant value
| |
| help: consider using `let` instead of `const`: `let Y`
| ^ non-constant value
|
help: consider using `let` instead of `const`
|
LL | let Y: i32 = x;
| ~~~

error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/non-const-value-in-const.rs:6:17
|
LL | let x = 5;
| ----- help: consider using `const` instead of `let`: `const x`
...
LL | let _ = [0; x];
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const x = 5;
| ~~~~~

error: aborting due to 2 previous errors

Expand Down
7 changes: 5 additions & 2 deletions tests/ui/error-codes/E0435.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/E0435.rs:5:17
|
LL | let foo: usize = 42;
| ------- help: consider using `const` instead of `let`: `const foo`
LL | let _: [u8; foo];
| ^^^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const foo: usize = 42;
| ~~~~~

error: aborting due to 1 previous error

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/issues/issue-27433.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-27433.rs:5:23
|
LL | const FOO : u32 = foo;
| --------- ^^^ non-constant value
| |
| help: consider using `let` instead of `const`: `let FOO`
| ^^^ non-constant value
|
help: consider using `let` instead of `const`
|
LL | let FOO : u32 = foo;
| ~~~

error: aborting due to 1 previous error

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/issues/issue-3521-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-3521-2.rs:5:23
|
LL | static y: isize = foo + 1;
| -------- ^^^ non-constant value
| |
| help: consider using `let` instead of `static`: `let y`
| ^^^ non-constant value
|
help: consider using `let` instead of `static`
|
LL | let y: isize = foo + 1;
| ~~~

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-3668-2.rs:4:27
|
LL | static child: isize = x + 1;
| ------------ ^ non-constant value
| |
| help: consider using `let` instead of `static`: `let child`
| ^ non-constant value
|
help: consider using `let` instead of `static`
|
LL | let child: isize = x + 1;
| ~~~

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-3668.rs:8:34
|
LL | static childVal: Box<P> = self.child.get();
| --------------- ^^^^ non-constant value
| |
| help: consider using `let` instead of `static`: `let childVal`
| ^^^^ non-constant value
|
help: consider using `let` instead of `static`
|
LL | let childVal: Box<P> = self.child.get();
| ~~~

error: aborting due to 1 previous error

Expand Down
8 changes: 5 additions & 3 deletions tests/ui/issues/issue-44239.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
error[E0435]: attempt to use a non-constant value in a constant
--> $DIR/issue-44239.rs:8:26
|
LL | let n: usize = 0;
| ----- help: consider using `const` instead of `let`: `const n`
...
LL | const N: usize = n;
| ^ non-constant value
|
help: consider using `const` instead of `let`
|
LL | const n: usize = 0;
| ~~~~~

error: aborting due to 1 previous error

Expand Down
Loading