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 8 pull requests #129591

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a97b41f
Use subtyping for UnsafeFnPointer coercion, too
compiler-errors Aug 20, 2024
147bb17
Rework how we emit errors for unresolved object lifetimes
compiler-errors Aug 24, 2024
e7f11b6
Removes dead code from the compiler
mu001999 Aug 8, 2024
c29e328
gitignore: ignore ICE reports regardless of directory
GrigorenkoPV Aug 24, 2024
51cd76b
warn on suspicious elision resolutions
GrigorenkoPV Aug 15, 2024
40d8379
elided_named_lifetimes: Lint stub
GrigorenkoPV Aug 15, 2024
19d11db
elided_named_lifetimes: LintDiagnostic
GrigorenkoPV Aug 16, 2024
f735c7a
elided_named_lifetimes: fix (hack) the ICE for non-static case
GrigorenkoPV Aug 16, 2024
4328e8b
elided_named_lifetimes: try to work around the issues with `NodeId`s …
GrigorenkoPV Aug 17, 2024
7a73ed4
elided_named_lifetimes: allow elided `'static` in const/static type a…
GrigorenkoPV Aug 17, 2024
3dac6f9
elided_named_lifetimes: bump to `Warn` & fix libs
GrigorenkoPV Aug 17, 2024
b977633
elided_named_lifetimes: improve the message a bit
GrigorenkoPV Aug 18, 2024
a57ebc3
Rename `allow_elided_static` to `warn_elided_static` for clarity
GrigorenkoPV Aug 18, 2024
bec8f58
elided_named_lifetimes: allow elided `'static` in assoc consts' types
GrigorenkoPV Aug 18, 2024
2822aff
bless tests
GrigorenkoPV Aug 21, 2024
0b37f75
Fix ICE & bless the remaining tests
GrigorenkoPV Aug 21, 2024
3175fac
Bless clippy tests
GrigorenkoPV Aug 22, 2024
7e74a5e
elided_named_lifetimes: add tests
GrigorenkoPV Aug 23, 2024
610f1a5
elided_named_lifetimes: add docs
GrigorenkoPV Aug 23, 2024
bacbf46
`TyCtxt::item_name` exists
GrigorenkoPV Aug 24, 2024
f0c9cec
Move the override flag for `elided_named_lifetimes`
GrigorenkoPV Aug 24, 2024
3a7d0ab
elided_named_lifetimes: get rid of `crate_node_id`
GrigorenkoPV Aug 24, 2024
ba24121
tweak rustc_allow_const_fn_unstable hint, and add back test for stabl…
RalfJung Aug 25, 2024
8750e24
Fixing span manipulation and indentation of the suggestion introduced…
surechen Aug 22, 2024
48f43fa
Avoid taking reference of &TyKind
compiler-errors Aug 25, 2024
ecd2d11
Remove redundant flags that can be inferred from the HIR
compiler-errors Aug 24, 2024
4e1a70f
Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot
matthiaskrgr Aug 25, 2024
e7aca53
Rollup merge of #129288 - compiler-errors:unsafe-fn-coercion, r=lcnr
matthiaskrgr Aug 25, 2024
614ea5a
Rollup merge of #129405 - surechen:fix_span_x, r=cjgillot
matthiaskrgr Aug 25, 2024
1fe4b67
Rollup merge of #129518 - GrigorenkoPV:gitignore-library-ice, r=tgross35
matthiaskrgr Aug 25, 2024
8a1fff1
Rollup merge of #129519 - compiler-errors:lowering-flags, r=fmease
matthiaskrgr Aug 25, 2024
65baca7
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compile…
matthiaskrgr Aug 25, 2024
b8e8a10
Rollup merge of #129553 - RalfJung:const-stability, r=compiler-errors
matthiaskrgr Aug 25, 2024
1bac9b2
Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmease
matthiaskrgr Aug 25, 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
Fix ICE & bless the remaining tests
  • Loading branch information
GrigorenkoPV committed Aug 25, 2024
commit 0b37f75910a7c20ad37036f204acf3db46749047
7 changes: 4 additions & 3 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,9 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {

/// We need some "real" `NodeId` to emit
/// [`elided_named_lifetimes`](lint::builtin::ELIDED_NAMED_LIFETIMES).
/// See comments in [`MissingLifetime::id_if_not_fake_or`].
/// See comments in [`MissingLifetime::id_if_exists_in_source_or`].
crate_node_id: NodeId,

/// Don't emit [`elided_named_lifetimes`](lint::builtin::ELIDED_NAMED_LIFETIMES)
/// when we are in a type annotation for a `const` or `static`.
/// ```rust
Expand Down Expand Up @@ -2072,7 +2073,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
if self.warn_elided_static {
self.r.lint_buffer.buffer_lint(
lint::builtin::ELIDED_NAMED_LIFETIMES,
missing.id_if_not_fake_or(self.crate_node_id),
missing.id_if_exists_in_source_or(self.crate_node_id),
missing.span,
BuiltinLintDiag::ElidedIsStatic { elided },
);
Expand All @@ -2086,7 +2087,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// but `binder` sounds like a more appropriate place than the crate,
// and to convert `param` from `LocalDefId` to `NodeId`,
// we would have to do some additional work.
missing.id_if_not_fake_or(binder),
missing.id_if_exists_in_source_or(binder),
missing.span,
BuiltinLintDiag::ElidedIsParam { elided, param },
);
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ impl MissingLifetime {
/// in a sense that they are temporary and not get preserved down the line,
/// which means that the lints for those nodes will not get emitted.
/// To combat this, we can try to use some other `NodeId`s as a fallback option.
pub(super) fn id_if_not_fake_or(self, fallback: NodeId) -> NodeId {
pub(super) fn id_if_exists_in_source_or(self, fallback: NodeId) -> NodeId {
match self.kind {
MissingLifetimeKind::Underscore
| MissingLifetimeKind::Comma
| MissingLifetimeKind::Brackets => self.id,
MissingLifetimeKind::Ampersand => fallback,
MissingLifetimeKind::Underscore => self.id,
MissingLifetimeKind::Ampersand
| MissingLifetimeKind::Brackets
| MissingLifetimeKind::Comma => fallback,
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/const-generics/type-dependent/issue-71348.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: elided lifetime has a name
--> $DIR/issue-71348.rs:18:68
|
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
= note: `#[warn(elided_named_lifetimes)]` on by default

warning: 1 warning emitted

10 changes: 9 additions & 1 deletion tests/ui/const-generics/type-dependent/issue-71348.min.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
warning: elided lifetime has a name
--> $DIR/issue-71348.rs:18:68
|
LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
= note: `#[warn(elided_named_lifetimes)]` on by default

error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/issue-71348.rs:10:24
|
Expand Down Expand Up @@ -30,5 +38,5 @@ help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
LL + #![feature(unsized_const_params)]
|

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 1 warning emitted

1 change: 1 addition & 0 deletions tests/ui/const-generics/type-dependent/issue-71348.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trait Get<'a, const N: &'static str> {
impl Foo {
fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
//~^^ WARNING elided lifetime has a name
where
Self: Get<'a, N>,
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

type Opaque2<T> = impl Sized;
type Opaque<'a, T> = Opaque2<T>;
fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } //~ WARNING elided lifetime has a name
//~^ ERROR: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds

fn main() {}
12 changes: 11 additions & 1 deletion tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
warning: elided lifetime has a name
--> $DIR/missing_lifetime_bound.rs:5:41
|
LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
| -- ^ this elided lifetime gets resolved as `'a`
| |
| lifetime `'a` declared here
|
= note: `#[warn(elided_named_lifetimes)]` on by default

error[E0700]: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds
--> $DIR/missing_lifetime_bound.rs:5:47
|
Expand All @@ -9,6 +19,6 @@ LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
| |
| hidden type `&'a i32` captures the lifetime `'a` as defined here

error: aborting due to 1 previous error
error: aborting due to 1 previous error; 1 warning emitted

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