Skip to content

Commit

Permalink
Rollup merge of #108449 - fee1-dead-contrib:do_not_lint_unresolved, r…
Browse files Browse the repository at this point in the history
…=compiler-errors

Do not lint ineffective unstable trait impl for unresolved trait
  • Loading branch information
compiler-errors committed Feb 25, 2023
2 parents fd548b2 + ed34354 commit 7e9f0b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true };
c.visit_ty(self_ty);
c.visit_trait_ref(t);
if c.fully_stable {

// do not lint when the trait isn't resolved, since resolution error should
// be fixed first
if t.path.res != Res::Err && c.fully_stable {
self.tcx.struct_span_lint_hir(
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
item.hir_id(),
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/stability-attribute/unresolved_stability_lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(staged_api)]
#![stable(feature = "uwu", since = "1.0.0")]

#[unstable(feature = "foo", issue = "none")]
impl Foo for () {}
//~^ ERROR cannot find trait `Foo` in this scope

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/stability-attribute/unresolved_stability_lint.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0405]: cannot find trait `Foo` in this scope
--> $DIR/unresolved_stability_lint.rs:5:6
|
LL | impl Foo for () {}
| ^^^ not found in this scope

error: aborting due to previous error

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

0 comments on commit 7e9f0b7

Please sign in to comment.