Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7a812c1
Clarify how to choose a FutureIncompatibilityReason variant.
ehuss Nov 15, 2023
b7a23bc
On borrow return type, suggest borrowing from arg or owned return type
estebank Nov 14, 2023
5fce361
Account for impl Trait in lifetime suggestion
estebank Nov 14, 2023
d30252e
Tweak wording
estebank Nov 14, 2023
dec7f00
Fix incorrect lifetime suggestion
estebank Nov 15, 2023
2a92d82
Suggest 'a when trait object assoc type has '_
estebank Nov 15, 2023
85f26ad
Account for '_ in lifetime suggestion
estebank Nov 15, 2023
bb9d720
Do not consider traits as ownable in suggestion
estebank Nov 15, 2023
02bea16
Rely in resolve and not on path name for `&str` -> `String` suggestion
estebank Nov 15, 2023
eee4cc6
let-chain fmt
estebank Nov 16, 2023
69a2bd6
report_not_const_evaluatable_error to avoid ICEing on ConstKind::Expr
lenko-d Oct 14, 2023
226edf6
Improve an error involving attribute values.
nnethercote Dec 11, 2023
4f80833
rustdoc-search: clean up parser
notriddle Dec 12, 2023
f44ccba
rustc_codegen_llvm: Enforce `rustc::potential_query_instability` lint
Enselic Dec 12, 2023
46a8015
llvm-wrapper: adapt for LLVM API change
krasimirgg Dec 12, 2023
e274372
Correctly gate the parsing of match arms without body
Nadrieril Dec 12, 2023
19e0c98
Don't gate the feature twice
Nadrieril Dec 12, 2023
41c9404
tests: CGU tests require build-pass, not check-pass (remove FIXME)
Enselic Dec 12, 2023
b2a0175
Rollup merge of #116740 - lenko-d:const_evaluatable_failed_for_non_un…
matthiaskrgr Dec 12, 2023
ffdb471
Rollup merge of #117914 - estebank:issue-85843, r=wesleywiser
matthiaskrgr Dec 12, 2023
111c40e
Rollup merge of #117927 - ehuss:future-incompat-docs, r=wesleywiser
matthiaskrgr Dec 12, 2023
cd7809b
Rollup merge of #118855 - nnethercote:improve-attribute-value-error, …
matthiaskrgr Dec 12, 2023
6459121
Rollup merge of #118856 - notriddle:notriddle/search-js, r=GuillaumeG…
matthiaskrgr Dec 12, 2023
04c77a5
Rollup merge of #118865 - Enselic:rustc_codegen_llvm-lint-fix, r=petr…
matthiaskrgr Dec 12, 2023
9ed12f8
Rollup merge of #118866 - krasimirgg:llvm-18-ref, r=durin42
matthiaskrgr Dec 12, 2023
d661974
Rollup merge of #118868 - Nadrieril:correctly-gate-never_patterns-par…
matthiaskrgr Dec 12, 2023
010f301
Rollup merge of #118877 - Enselic:remove-cgu-fixme, r=Nilstrieb
matthiaskrgr Dec 12, 2023
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
271 changes: 259 additions & 12 deletions compiler/rustc_resolve/src/late/diagnostics.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: usize = 1852;
const ROOT_ENTRY_LIMIT: usize = 867;
const ROOT_ENTRY_LIMIT: usize = 866;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ LL | fn elision<T: Fn() -> &i32>() {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn elision<T: Fn() -> &'static i32>() {
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL - fn elision<T: Fn() -> &i32>() {
LL + fn elision<T: Fn() -> i32>() {
|

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ LL | fn elision(_: fn() -> &i32) {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn elision(_: fn() -> &'static i32) {
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL - fn elision(_: fn() -> &i32) {
LL + fn elision(_: fn() -> i32) {
|

error: aborting due to 1 previous error

Expand Down
11 changes: 10 additions & 1 deletion tests/ui/c-variadic/variadic-ffi-6.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ LL | ) -> &usize {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | ) -> &'static usize {
| +++++++
help: instead, you are more likely to want to change one of the arguments to be borrowed...
|
LL | x: &usize,
| +
help: ...or alternatively, you might want to return an owned value
|
LL - ) -> &usize {
LL + ) -> usize {
|

error: aborting due to 1 previous error

Expand Down
8 changes: 0 additions & 8 deletions tests/ui/foreign-fn-return-lifetime.fixed

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/foreign-fn-return-lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// run-rustfix

extern "C" {
pub fn g(_: &u8) -> &u8; // OK
pub fn f() -> &u8; //~ ERROR missing lifetime specifier
Expand Down
9 changes: 7 additions & 2 deletions tests/ui/foreign-fn-return-lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
error[E0106]: missing lifetime specifier
--> $DIR/foreign-fn-return-lifetime.rs:5:19
--> $DIR/foreign-fn-return-lifetime.rs:3:19
|
LL | pub fn f() -> &u8;
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | pub fn f() -> &'static u8;
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL - pub fn f() -> &u8;
LL + pub fn f() -> u8;
|

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/issue-70304.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> {
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'static>> {
| ~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn d() -> impl Fn() -> (impl Debug + '_) {
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
LL | fn d() -> impl Fn() -> (impl Debug + 'static) {
| ~~~~~~~
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/issues/issue-13497.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ LL | &str
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | &'static str
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL | String
| ~~~~~~

error: aborting due to 1 previous error

Expand Down
16 changes: 14 additions & 2 deletions tests/ui/lifetimes/issue-26638.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &'static str { iter() }
| +++++++
help: instead, you are more likely to want to change the argument to be borrowed...
|
LL | fn parse_type_2(iter: &fn(&u8)->&u8) -> &str { iter() }
| +
help: ...or alternatively, you might want to return an owned value
|
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> String { iter() }
| ~~~~~~

error[E0106]: missing lifetime specifier
--> $DIR/issue-26638.rs:10:22
Expand All @@ -29,10 +37,14 @@ LL | fn parse_type_3() -> &str { unimplemented!() }
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn parse_type_3() -> &'static str { unimplemented!() }
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL | fn parse_type_3() -> String { unimplemented!() }
| ~~~~~~

error[E0308]: mismatched types
--> $DIR/issue-26638.rs:1:69
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ LL | fn f() -> &isize {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn f() -> &'static isize {
| +++++++
help: instead, you are more likely to want to return an owned value
|
LL - fn f() -> &isize {
LL + fn f() -> isize {
|

error[E0106]: missing lifetime specifier
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:7:33
Expand Down Expand Up @@ -41,10 +46,19 @@ LL | fn i(_x: isize) -> &isize {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn i(_x: isize) -> &'static isize {
| +++++++
help: instead, you are more likely to want to change the argument to be borrowed...
|
LL | fn i(_x: &isize) -> &isize {
| +
help: ...or alternatively, you might want to return an owned value
|
LL - fn i(_x: isize) -> &isize {
LL + fn i(_x: isize) -> isize {
|

error[E0106]: missing lifetime specifier
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:34:24
Expand All @@ -53,10 +67,19 @@ LL | fn j(_x: StaticStr) -> &isize {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn j(_x: StaticStr) -> &'static isize {
| +++++++
help: instead, you are more likely to want to change the argument to be borrowed...
|
LL | fn j(_x: &StaticStr) -> &isize {
| +
help: ...or alternatively, you might want to return an owned value
|
LL - fn j(_x: StaticStr) -> &isize {
LL + fn j(_x: StaticStr) -> isize {
|

error[E0106]: missing lifetime specifier
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:40:49
Expand Down
11 changes: 10 additions & 1 deletion tests/ui/self/elision/nested-item.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &'static () {
| +++++++
help: instead, you are more likely to want to change the argument to be borrowed...
|
LL | fn wrap(self: &Wrap<{ fn bar(&self) {} }>) -> &() {
| +
help: ...or alternatively, you might want to return an owned value
|
LL - fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() {
LL + fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> () {
|

error[E0412]: cannot find type `Wrap` in this scope
--> $DIR/nested-item.rs:5:15
Expand Down
66 changes: 60 additions & 6 deletions tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() }
| +++++++
help: consider introducing a named lifetime parameter
|
LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() }
| ++++ ~~~ ~~~
help: alternatively, you might want to return an owned value
|
LL - fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
LL + fn g(mut x: impl Iterator<Item = &()>) -> Option<()> { x.next() }
|

error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime-gated.rs:19:60
Expand All @@ -17,10 +26,19 @@ LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next()
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() }
| +++++++
help: consider introducing a named lifetime parameter
|
LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() }
| ++++ ~~~ ~~~
help: alternatively, you might want to return an owned value
|
LL - async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
LL + async fn i(mut x: impl Iterator<Item = &()>) -> Option<()> { x.next() }
|

error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime-gated.rs:27:58
Expand All @@ -29,10 +47,19 @@ LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next()
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
| ~~~~~~~
help: consider introducing a named lifetime parameter
|
LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() }
| ++++ ~~~ ~~~
help: alternatively, you might want to return an owned value
|
LL - fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
LL + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|

error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime-gated.rs:37:64
Expand All @@ -41,10 +68,19 @@ LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.n
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() }
| ~~~~~~~
help: consider introducing a named lifetime parameter
|
LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() }
| ++++ ~~~ ~~~
help: alternatively, you might want to return an owned value
|
LL - async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|

error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime-gated.rs:47:37
Expand All @@ -53,10 +89,19 @@ LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn g(mut x: impl Foo) -> Option<&'static ()> { x.next() }
| +++++++
help: consider introducing a named lifetime parameter
|
LL | fn g<'a>(mut x: impl Foo) -> Option<&'a ()> { x.next() }
| ++++ ~~~
help: alternatively, you might want to return an owned value
|
LL - fn g(mut x: impl Foo) -> Option<&()> { x.next() }
LL + fn g(mut x: impl Foo) -> Option<()> { x.next() }
|

error[E0106]: missing lifetime specifier
--> $DIR/impl-trait-missing-lifetime-gated.rs:58:41
Expand All @@ -65,10 +110,19 @@ LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
LL | fn g(mut x: impl Foo<()>) -> Option<&'static ()> { x.next() }
| +++++++
help: consider introducing a named lifetime parameter
|
LL | fn g<'a>(mut x: impl Foo<()>) -> Option<&'a ()> { x.next() }
| ++++ ~~~
help: alternatively, you might want to return an owned value
|
LL - fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
LL + fn g(mut x: impl Foo<()>) -> Option<()> { x.next() }
|

error[E0658]: anonymous lifetimes in `impl Trait` are unstable
--> $DIR/impl-trait-missing-lifetime-gated.rs:6:35
Expand Down
Loading