Skip to content

relaxing a non-Sized bounds is a hard-warning #135809

Closed
@lcnr

Description

@lcnr
Contributor

let mut seen_sized_unbound = false;
for unbound in unbounds {
if let Some(sized_def_id) = sized_def_id
&& unbound.trait_ref.path.res == Res::Def(DefKind::Trait, sized_def_id)
{
seen_sized_unbound = true;
continue;
}
// There was a `?Trait` bound, but it was not `?Sized`; warn.
self.dcx().span_warn(
unbound.span,
"relaxing a default bound only does something for `?Sized`; \
all other traits are not bound by default",
);
}

fn foo() -> impl ?Send {}
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
 --> src/lib.rs:1:18
  |
1 | fn foo() -> impl ?Send {}
  |                  ^^^^^

This should either be a (future-compat) lint or a hard-error.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 21, 2025
lcnr

lcnr commented on Jan 21, 2025

@lcnr
ContributorAuthor

this warning exists since pre 1.0 🤔

added
C-bugCategory: This is a bug.
C-discussionCategory: Discussion or questions that doesn't represent real issues.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
C-discussionCategory: Discussion or questions that doesn't represent real issues.
on Jan 23, 2025
theemathas

theemathas commented on Jan 30, 2025

@theemathas
Contributor

This code compiles. Is it supposed to?

trait Generic<T> {}
trait Huh {
    type Assoc;
}
pub fn f<T: ?Generic<<T as Huh>::Assoc>>() {}
theemathas

theemathas commented on Jan 30, 2025

@theemathas
Contributor

Clearly this isn't supposed to compile, right?

trait Generic<const N: usize> {}

pub fn f<T: ?Generic<{ panic!() }>>() {}
lcnr

lcnr commented on Jan 30, 2025

@lcnr
ContributorAuthor

This code compiles. Is it supposed to?

Clearly this isn't supposed to compile, right?

I don't think they should, which is why I opened this issue. We should move all of these to a hard error

added 2 commits that reference this issue on Feb 13, 2025

Rollup merge of rust-lang#135841 - oli-obk:push-qxlnokwrkkym, r=compi…

9ffdfca

Rollup merge of rust-lang#135841 - oli-obk:push-qxlnokwrkkym, r=compi…

6b9b0a0

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @theemathas@fmease@lcnr@jieyouxu@rustbot

      Issue actions

        relaxing a non-`Sized` bounds is a hard-warning · Issue #135809 · rust-lang/rust