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 12 pull requests #138146

Closed
wants to merge 35 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
93ef808
Revert vita's c_char back to i8
pheki Feb 7, 2025
7e5b1c2
Windows: Use MoveFileEx by default in `fs:rename`
ChrisDenton Feb 24, 2025
67cc82a
Inline VecDeque<u8> and BorrowedCursor methods
thaliaarchi Feb 15, 2025
41bdd2b
Override default Write methods for cursor-like types
thaliaarchi Feb 16, 2025
a8d78fe
Specialize OsString::push for strings
thaliaarchi Feb 28, 2025
83407b8
Specialize constructing OsString from strings
thaliaarchi Feb 28, 2025
b119671
Tweak BufReader::peek() doctest to expose bug in Buffer::read_more()
wgwoods Mar 1, 2025
6d07144
Fix logic error in Buffer::read_more()
wgwoods Mar 1, 2025
489e9c4
std: move stdio to `sys`
joboet Feb 9, 2025
9d8ce72
compiler: factor Windows x86-32 ABI impl into its own file
workingjubilee Feb 21, 2025
1b21952
Also add a MIR pre-codegen test for the derived `PartialOrd::le`
scottmcm Mar 2, 2025
eae5ed6
Make `is_le` and friends work like clang's
scottmcm Mar 2, 2025
3a726b1
Return OutOfMemoryError and update docs
ChrisDenton Mar 6, 2025
ab82a2c
tests: fix `issue-107495-archive-permissions` to not rely on `rustc_p…
jieyouxu Feb 24, 2025
4d77c4c
tests: fix `cross-lang-lto` to not use `path_file_prefix`
jieyouxu Feb 24, 2025
5b0b58d
run-make-support: temporarily depend on `os_pipe` and re-export it
jieyouxu Feb 24, 2025
bf88a6b
tests: fix `broken-pipe-no-ice` to not depend on unstable `anonymous_…
jieyouxu Feb 24, 2025
4e178a7
compiletest: prevent `rmake.rs` from using any nightly/unstable features
jieyouxu Feb 24, 2025
dcc4c6c
rustc-dev-guide: document `rmake.rs` may not use unstable features
jieyouxu Feb 24, 2025
ac40ea7
Suggest typo fix for static lifetime
compiler-errors Mar 6, 2025
98dc15f
stabilize const_char_classify
RalfJung Mar 6, 2025
8f8c7fc
stabilize const_sockaddr_setters
RalfJung Mar 6, 2025
2458ccd
Simplify printf and shell format suggestions
thaliaarchi Mar 1, 2025
5e3a5c6
Rollup merge of #136667 - vita-rust:revert-vita-c-char, r=cuviper
workingjubilee Mar 7, 2025
7ae8314
Rollup merge of #136780 - joboet:move_pal_stdio, r=Amanieu
workingjubilee Mar 7, 2025
3d25394
Rollup merge of #137107 - thaliaarchi:io-optional-methods/cursors, r=…
workingjubilee Mar 7, 2025
08b6d0d
Rollup merge of #137363 - workingjubilee:untangle-x86-abi-impl, r=jie…
workingjubilee Mar 7, 2025
bcb3cf3
Rollup merge of #137528 - ChrisDenton:rename-win, r=joboet
workingjubilee Mar 7, 2025
2cdca2e
Rollup merge of #137537 - jieyouxu:daily-rmake, r=Kobzol
workingjubilee Mar 7, 2025
1e74f48
Rollup merge of #137777 - thaliaarchi:os_string-push-str, r=joboet
workingjubilee Mar 7, 2025
5b5695c
Rollup merge of #137832 - wgwoods:fix-bufreader-peek, r=joboet
workingjubilee Mar 7, 2025
a727e02
Rollup merge of #137904 - scottmcm:ordering-is, r=workingjubilee
workingjubilee Mar 7, 2025
1175f71
Rollup merge of #138115 - compiler-errors:static-typo, r=BoxyUwU
workingjubilee Mar 7, 2025
421d17e
Rollup merge of #138125 - thaliaarchi:defer-alloc-printf-suggestion, …
workingjubilee Mar 7, 2025
9872133
Rollup merge of #138129 - RalfJung:stabilize-const-things, r=tgross35
workingjubilee Mar 7, 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
Prev Previous commit
Next Next commit
Suggest typo fix for static lifetime
compiler-errors committed Mar 6, 2025
commit ac40ea7129447abbd004859957bf00a374e8a739
48 changes: 30 additions & 18 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_hir::{MissingLifetimeKind, PrimTy};
use rustc_middle::ty;
use rustc_session::{Session, lint};
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::edit_distance::{edit_distance, find_best_match_for_name};
use rustc_span::edition::Edition;
use rustc_span::hygiene::MacroKind;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
@@ -2874,23 +2874,35 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
)
.with_span_label(lifetime_ref.ident.span, "undeclared lifetime")
};
self.suggest_introducing_lifetime(
&mut err,
Some(lifetime_ref.ident.name.as_str()),
|err, _, span, message, suggestion, span_suggs| {
err.multipart_suggestion_with_style(
message,
std::iter::once((span, suggestion)).chain(span_suggs.clone()).collect(),
Applicability::MaybeIncorrect,
if span_suggs.is_empty() {
SuggestionStyle::ShowCode
} else {
SuggestionStyle::ShowAlways
},
);
true
},
);

// Check if this is a typo of `'static`.
if edit_distance(lifetime_ref.ident.name.as_str(), "'static", 2).is_some() {
err.span_suggestion_verbose(
lifetime_ref.ident.span,
"you may have misspelled the `'static` lifetime",
"'static",
Applicability::MachineApplicable,
);
} else {
self.suggest_introducing_lifetime(
&mut err,
Some(lifetime_ref.ident.name.as_str()),
|err, _, span, message, suggestion, span_suggs| {
err.multipart_suggestion_with_style(
message,
std::iter::once((span, suggestion)).chain(span_suggs.clone()).collect(),
Applicability::MaybeIncorrect,
if span_suggs.is_empty() {
SuggestionStyle::ShowCode
} else {
SuggestionStyle::ShowAlways
},
);
true
},
);
}

err.emit();
}

7 changes: 7 additions & 0 deletions tests/ui/lifetimes/static-typos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn stati<T: 'stati>() {}
//~^ ERROR use of undeclared lifetime name `'stati`

fn statoc<T: 'statoc>() {}
//~^ ERROR use of undeclared lifetime name `'statoc`

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/lifetimes/static-typos.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0261]: use of undeclared lifetime name `'stati`
--> $DIR/static-typos.rs:1:13
|
LL | fn stati<T: 'stati>() {}
| ^^^^^^ undeclared lifetime
|
help: you may have misspelled the `'static` lifetime
|
LL | fn stati<T: 'static>() {}
| +

error[E0261]: use of undeclared lifetime name `'statoc`
--> $DIR/static-typos.rs:4:14
|
LL | fn statoc<T: 'statoc>() {}
| ^^^^^^^ undeclared lifetime
|
help: you may have misspelled the `'static` lifetime
|
LL - fn statoc<T: 'statoc>() {}
LL + fn statoc<T: 'static>() {}
|

error: aborting due to 2 previous errors

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