rust-lang / rust-lang/rust

`Self` of negative impl is not required to be well-formed

Open
#152,645 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-negative_impls requires-nightly T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

feature(negative_impls) tracking issue: https://github.com/rust-lang/rust/issues/68318

I'm not sure if this is intended behavior or not.

I tried this code:

#![feature(negative_impls)]

struct Foo<T: Sized>(T);

trait MyTrait {}

impl !MyTrait for Foo<str> {} // Foo requires T: Sized, but str: !Sized

I expected to see this happen: error[E0277]: the size for values of type `str` cannot be known at compilation time

Instead, this happened: successful compilation (playground)

Meta

rustc --version --verbose:

rustc 1.95.0-nightly (a423f68a0 2026-02-13)
binary: rustc
commit-hash: a423f68a0d75656eabab4982a06bed9f316f7109
commit-date: 2026-02-13
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

no backtrace

@rustbot label F-negative_impls requires-nightly

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided negative_impls reproducer on the reported nightly and compare its behavior with the linked negative_impls tracking issue. Trace how the compiler checks the Self type in impl !MyTrait for Foo<str>; done means the invalid str argument is rejected with the expected well-formedness error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.