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

Warning shown despite --cap-lints=allow: E0122 "trait bounds are not (yet) enforced in type definitions" #43134

Closed
SimonSapin opened this issue Jul 9, 2017 · 11 comments · Fixed by #114164
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

Test case:

type Foo<T: Clone> = Option<T>;

fn main() {}

With rustc 1.20.0-nightly (696412d 2017-07-06), output when compiling with --cap-lints=allow:

warning[E0122]: trait bounds are not (yet) enforced in type definitions
 --> a.rs:1:1
  |
1 | type Foo<T: Clone> = Option<T>;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

--cap-lints=allow correctly stops the dead code / unused type alias warning from being shown, but the trait bounds not enforced warning is shown anyway.

Per #34596 and #40640 (comment), this might be on purpose. I think this is the wrong decision. The point of cap-lints is to allow Cargo to inhibit warnings in external dependencies. When building Servo it is not useful to spam the console with many warnings, future-proofing or not, about code that Servo has not direct control over.

CC @nikomatsakis @aturon

@nagisa
Copy link
Member

nagisa commented Jul 9, 2017

@Mark-Simulacrum Mark-Simulacrum added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Jul 19, 2017
@Mark-Simulacrum
Copy link
Member

Nominating for discussion. Not sure if compiler team or lang team is best, though, so tagging both...

@aturon
Copy link
Member

aturon commented Jul 25, 2017

From the lang team's point of view: definitely a bug.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 28, 2017
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Aug 24, 2017

Couple of bugs here:

First off, we should not be ignoring the bounds in types. And sometimes they are needed. I'd like to fix this by not ignoring them, but I worry about the backcompat issues. Unknown risk there.

Second, if we must warn, we should be emitting a regular lint that can be silenced.

Plausibly, we should just remove the warning (eliminating the immediate problem), and prioritize trying to do a proper fix here.

@eddyb
Copy link
Member

eddyb commented Aug 24, 2017

Somewhat related to not ignoring bounds (but in the other direction): #44075.

@nikomatsakis
Copy link
Contributor

After some discussion in compiler team, decided to move this to a "future compatibility" lint, one that we will hopefully make more precise over time. Right now the check is not very good. At least this means you won't have to see it. We need some mentoring instructions though!

@nikomatsakis
Copy link
Contributor

@nikomatsakis
Copy link
Contributor

triage: P-medium

@rust-highfive rust-highfive added P-medium Medium priority and removed I-nominated labels Aug 24, 2017
@weiznich
Copy link
Contributor

I've hit this recently.
It seems like it is possible to write code that requires exactly this bound. So it is quite bad that we cannot suppress this warning.

Example code:



trait Foo {
    type A;
}

struct StructA;
struct StructB;

impl Foo for StructA {
    type A = ();
}

// Warning about not enforced trait bounds
type B<A: Foo> = A::A;

// Error with the message:  associated type `A` not found for `A`
// -> Trait bound is required
//type C<A> = A::A

type D = B<StructA>;
// As the warning says this works
type E = B<StructB>;

@nikomatsakis
Copy link
Contributor

Agreed, this is poor. There just hasn't been a lot of energy to try and improve the situation.

@Enselic
Copy link
Member

Enselic commented Jul 23, 2023

Fixed in nightly-2017-09-22, probably by #44627. We should add a regression test for this particular case before we close this issue however, since I don't think the test in the PR detects a regression for the problem described in this issue. The problem in this issue is output on stderr, not that compilation fails (rustc exit code is 0 both with and without the fix in the PR).

@rustbot label E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 28, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 28, 2023
…ompiler-errors

Add regression test for `--cap-lints allow` and trait bounds warning

Closes rust-lang#43134

I have verified that the test fails if stderr begins to contain output by making sure the test fails when I add

    eprintln!("some output on stderr");

to the compiler (I added it to `fn build_session()`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants