Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a917fd5
Fix diagnostic when using = instead of : in let bindings
chenyukang Feb 11, 2025
d82219a
debuginfo: Set bitwidth appropriately in enum variant tags
maurer Feb 12, 2025
e663819
Move `llvm.ccache` to `build.ccache`
Kobzol Feb 12, 2025
2c4922c
rustdoc: use better, consistent SVG icons for scraped examples
notriddle Feb 12, 2025
ab786d3
coverage: Eliminate more counters by giving them to unreachable nodes
Zalathar Feb 11, 2025
66ebee4
Compiletest should not inherit all host RUSTFLAGS
jyn514 Feb 13, 2025
a1a6fd7
Add warning about using llvm.ccache and add FIXME note
Kobzol Feb 13, 2025
8ff3639
ci: move `x86_64-gnu-debug` job to the free runner
marcoieni Feb 13, 2025
bd4f80c
Remove `llvm.ccache` option from `config.example.toml`
Kobzol Feb 13, 2025
0709ba3
unify LLVM version finding logic
onur-ozkan Feb 13, 2025
f7a03d0
Fix `x test --stage 1 ui-fulldeps` on macOS (until the next beta bump)
jyn514 Feb 13, 2025
de273e4
normalizes-to rework rigid alias handling
lcnr Feb 11, 2025
05bd5ce
rework pointee handling for the new rigid alias approach
lcnr Feb 11, 2025
059288e
adjust derive_error
lcnr Feb 12, 2025
81c6d5e
eagerly prove WF when resolving fully qualified paths
lcnr Feb 12, 2025
83a0261
fallout :skull_emoji:
lcnr Feb 12, 2025
e2ee9f7
Rollup merge of #136863 - lcnr:treat-as-rigid, r=compiler-errors
workingjubilee Feb 14, 2025
d784803
Rollup merge of #136869 - chenyukang:yukang-fix-133713-let-binding, r…
workingjubilee Feb 14, 2025
864eba9
Rollup merge of #136895 - maurer:fix-enum-discr, r=nikic
workingjubilee Feb 14, 2025
1b603f9
Rollup merge of #136928 - lcnr:method-lookup-check-wf, r=compiler-errors
workingjubilee Feb 14, 2025
9f87de6
Rollup merge of #136941 - Kobzol:ccache-build, r=onur-ozkan
workingjubilee Feb 14, 2025
82110ca
Rollup merge of #136950 - notriddle:notriddle/svg-example-buttons, r=…
workingjubilee Feb 14, 2025
d82ec95
Rollup merge of #136957 - Zalathar:counters, r=oli-obk
workingjubilee Feb 14, 2025
bde2091
Rollup merge of #136960 - jyn514:compiletest-args, r=jieyouxu
workingjubilee Feb 14, 2025
0e85960
Rollup merge of #136962 - onur-ozkan:fix-enzyme-note, r=jieyouxu
workingjubilee Feb 14, 2025
0e56579
Rollup merge of #136970 - marcoieni:no-largedisk, r=Kobzol
workingjubilee Feb 14, 2025
6eb3929
Rollup merge of #136973 - jyn514:fulldeps-stage1, r=jieyouxu
workingjubilee Feb 14, 2025
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
23 changes: 22 additions & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2347,9 +2347,14 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
// try to give a suggestion for this pattern: `name = blah`, which is common in other languages
// suggest `let name = blah` to introduce a new binding
fn let_binding_suggestion(&mut self, err: &mut Diag<'_>, ident_span: Span) -> bool {
if ident_span.from_expansion() {
return false;
}

// only suggest when the code is a assignment without prefix code
if let Some(Expr { kind: ExprKind::Assign(lhs, ..), .. }) = self.diag_metadata.in_assignment
&& let ast::ExprKind::Path(None, ref path) = lhs.kind
&& !ident_span.from_expansion()
&& self.r.tcx.sess.source_map().is_line_before_span_empty(ident_span)
{
let (span, text) = match path.segments.first() {
Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
Expand All @@ -2368,6 +2373,22 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
);
return true;
}

// a special case for #133713
// '=' maybe a typo of `:`, which is a type annotation instead of assignment
if err.code == Some(E0423)
&& let Some((let_span, None, Some(val_span))) = self.diag_metadata.current_let_binding
&& val_span.contains(ident_span)
&& val_span.lo() == ident_span.lo()
{
err.span_suggestion_verbose(
let_span.shrink_to_hi().to(val_span.shrink_to_lo()),
"you might have meant to use `:` for type annotation",
": ",
Applicability::MaybeIncorrect,
);
return true;
}
false
}

Expand Down
12 changes: 12 additions & 0 deletions tests/ui/suggestions/let-binding-suggest-issue-133713.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ run-rustfix
#![allow(dead_code)]

fn demo1() {
let _last: u64 = 0; //~ ERROR expected value, found builtin type `u64`
}

fn demo2() {
let _val: u64; //~ ERROR expected value, found builtin type `u64`
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/ui/suggestions/let-binding-suggest-issue-133713.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ run-rustfix
#![allow(dead_code)]

fn demo1() {
let _last = u64 = 0; //~ ERROR expected value, found builtin type `u64`
}

fn demo2() {
let _val = u64; //~ ERROR expected value, found builtin type `u64`
}

fn main() {}
27 changes: 27 additions & 0 deletions tests/ui/suggestions/let-binding-suggest-issue-133713.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0423]: expected value, found builtin type `u64`
--> $DIR/let-binding-suggest-issue-133713.rs:5:17
|
LL | let _last = u64 = 0;
| ^^^
|
help: you might have meant to use `:` for type annotation
|
LL - let _last = u64 = 0;
LL + let _last: u64 = 0;
|

error[E0423]: expected value, found builtin type `u64`
--> $DIR/let-binding-suggest-issue-133713.rs:9:16
|
LL | let _val = u64;
| ^^^
|
help: you might have meant to use `:` for type annotation
|
LL - let _val = u64;
LL + let _val: u64;
|

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0423`.