From 03936115eff4c1aa2be1ceeea87238ec7c822d90 Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Mon, 1 Jan 2018 21:42:12 +0100 Subject: Check all repr hints together when checking for mis-applied attributes Fixes #47094 Besides fixing that bug, this change has a user-visible effect on the spans in the "incompatible repr hints" warning and another error: they now point at `foo` and/or `bar` in `repr(foo, bar)` instead of the whole attribute. This is sometimes more precise (e.g., `#[repr(C, packed)]` on an enum points at the `packed`) but sometimes not. I moved a compile-fail test to a ui test to illustrate how it now looks in the common case of only one attribute. --- src/test/compile-fail/attr-usage-repr.rs | 45 -------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/test/compile-fail/attr-usage-repr.rs (limited to 'src/test/compile-fail') diff --git a/src/test/compile-fail/attr-usage-repr.rs b/src/test/compile-fail/attr-usage-repr.rs deleted file mode 100644 index c0bfd3690c8..00000000000 --- a/src/test/compile-fail/attr-usage-repr.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![feature(attr_literals)] -#![feature(repr_simd)] - -#[repr(C)] //~ ERROR: attribute should be applied to struct, enum or union -fn f() {} - -#[repr(C)] -struct SExtern(f64, f64); - -#[repr(packed)] -struct SPacked(f64, f64); - -#[repr(simd)] -struct SSimd(f64, f64); - -#[repr(i8)] //~ ERROR: attribute should be applied to enum -struct SInt(f64, f64); - -#[repr(C)] -enum EExtern { A, B } - -#[repr(align(8))] //~ ERROR: attribute should be applied to struct -enum EAlign { A, B } - -#[repr(packed)] //~ ERROR: attribute should be applied to struct -enum EPacked { A, B } - -#[repr(simd)] //~ ERROR: attribute should be applied to struct -enum ESimd { A, B } - -#[repr(i8)] -enum EInt { A, B } - -fn main() {} -- cgit 1.4.1-3-g733a5