Skip to content

Compilation succeeds even if there is #[inline] in the structure field. #80564

Closed
@Danue1

Description

@Danue1
Contributor

I tried this code:

struct Foo {
    #[inline]
    bar: String,
}

I expected to see this happen: Failing complilation.

Instead, this happened: Compilation success.

Meta

rustc --version --verbose:

rustc 1.49.0-beta.4 (877c7cbe1 2020-12-10)
binary: rustc
commit-hash: 877c7cbe142a373f93d38a23741dcc3a0a17a2af
commit-date: 2020-12-10
host: x86_64-apple-darwin
release: 1.49.0-beta.4

Activity

ehuss

ehuss commented on Dec 31, 2020

@ehuss
Contributor

Some validation was added in #73461, but it looks like there are a few places that are missing. The ones I can see are struct fields, match arms, and macro definitions:

struct Foo {
    #[inline]
    bar: String,
}

match foo {
    #[inline]
    _ => {}
}

#[inline]
macro_rules! foo {
    () => {};
}

I believe that CheckAttrVisitor needs to include visitor methods for visit_arm and visit_struct_field and visit_macro_def.

added
A-attributesArea: Attributes (`#[…]`, `#![…]`)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 1, 2021
Danue1

Danue1 commented on Jan 2, 2021

@Danue1
ContributorAuthor

Hmm, I think I can do it, so I'll try it.

added a commit that references this issue on Feb 1, 2021

Auto merge of rust-lang#80641 - Danue1:patch-1, r=oli-obk

Danue1

Danue1 commented on Feb 2, 2021

@Danue1
ContributorAuthor

solved!

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

    A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ehuss@Danue1@camelid

        Issue actions

          Compilation succeeds even if there is #[inline] in the structure field. · Issue #80564 · rust-lang/rust