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

Rollup of 9 pull requests #88556

Merged
merged 21 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
21f07b5
Fix the flock fallback implementation
bjorn3 Aug 15, 2021
f33f266
BTree: remove Ord bound from new
nbdd0121 Aug 15, 2021
5802f60
add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower…
programmerjake Aug 26, 2021
fc125a5
emit specific warning to clarify that foreign items can't have no_mangle
asquared31415 Aug 30, 2021
026322c
fix(rustc_typeck): produce better errors for dyn auto trait
notriddle Aug 31, 2021
435cdd0
Update E0785.md
notriddle Aug 31, 2021
6e70678
Change wording to less jaron-y "non-auto trait"
notriddle Aug 31, 2021
87e39ac
Remove bolding on associated constants
camelid Aug 23, 2021
0e0c8ae
Use the return value of readdir_r() instead of errno
tavianator Aug 31, 2021
753dac1
Stabilize `UnsafeCell::raw_get()`
inquisitivecrystal Aug 31, 2021
06dd4c0
Stabilize `Iterator::intersperse()`
inquisitivecrystal Aug 31, 2021
227e004
Add a few tests for `UnsafeCell`
inquisitivecrystal Aug 31, 2021
dcefd68
Rollup merge of #86376 - asquared31415:extern-no-mangle-84204, r=Mark…
m-ou-se Sep 1, 2021
5878780
Rollup merge of #88040 - nbdd0121:btreemap, r=m-ou-se
m-ou-se Sep 1, 2021
8fd53e3
Rollup merge of #88053 - bjorn3:fix_flock_fallback_impl, r=cjgillot
m-ou-se Sep 1, 2021
494c563
Rollup merge of #88350 - programmerjake:add-ppc-cr-xer-clobbers, r=Am…
m-ou-se Sep 1, 2021
75b2ae5
Rollup merge of #88410 - camelid:fix-assoc-bold, r=GuillaumeGomez
m-ou-se Sep 1, 2021
bbc94ed
Rollup merge of #88525 - notriddle:notriddle/coherence-dyn-auto-trait…
m-ou-se Sep 1, 2021
59588a9
Rollup merge of #88542 - tavianator:readdir_r-errno, r=jyn514
m-ou-se Sep 1, 2021
f436b6d
Rollup merge of #88548 - inquisitivecrystal:intersperse, r=m-ou-se
m-ou-se Sep 1, 2021
d313529
Rollup merge of #88551 - inquisitivecrystal:unsafe_cell_raw_get, r=m-…
m-ou-se Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,36 @@ impl CheckAttrVisitor<'tcx> {
Target::Field | Target::Arm | Target::MacroDef => {
self.inline_attr_str_error_with_macro_def(hir_id, attr, "no_mangle");
}
// FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
// The error should specify that the item that is wrong is specifically a *foreign* fn/static
// otherwise the error seems odd
Target::ForeignFn | Target::ForeignStatic => {
let foreign_item_kind = match target {
Target::ForeignFn => "function",
Target::ForeignStatic => "static",
_ => unreachable!(),
};
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
lint.build(&format!(
"`#[no_mangle]` has no effect on a foreign {}",
foreign_item_kind
))
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
)
.span_label(*span, format!("foreign {}", foreign_item_kind))
.note("symbol names in extern blocks are not mangled")
.span_suggestion(
attr.span,
"remove this attribute",
String::new(),
Applicability::MachineApplicable,
)
.emit();
});
}
_ => {
// FIXME: #[no_mangle] was previously allowed on non-functions/statics and some
// crates used this, so only emit a warning.
Expand Down
30 changes: 30 additions & 0 deletions src/test/ui/extern/extern-no-mangle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![warn(unused_attributes)]

// Tests that placing the #[no_mangle] attribute on a foreign fn or static emits
// a specialized warning.
// The previous warning only talks about a "function or static" but foreign fns/statics
// are also not allowed to have #[no_mangle]

// build-pass

extern "C" {
#[no_mangle]
//~^ WARNING `#[no_mangle]` has no effect on a foreign static
//~^^ WARNING this was previously accepted by the compiler
pub static FOO: u8;

#[no_mangle]
//~^ WARNING `#[no_mangle]` has no effect on a foreign function
//~^^ WARNING this was previously accepted by the compiler
pub fn bar();
}

fn no_new_warn() {
// Should emit the generic "not a function or static" warning
#[no_mangle]
//~^ WARNING attribute should be applied to a free function, impl method or static
//~^^ WARNING this was previously accepted by the compiler
let x = 0_u8;
}

fn main() {}
42 changes: 42 additions & 0 deletions src/test/ui/extern/extern-no-mangle.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
warning: attribute should be applied to a free function, impl method or static
--> $DIR/extern-no-mangle.rs:24:5
|
LL | #[no_mangle]
| ^^^^^^^^^^^^
...
LL | let x = 0_u8;
| ------------- not a free function, impl method or static
|
note: the lint level is defined here
--> $DIR/extern-no-mangle.rs:1:9
|
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[no_mangle]` has no effect on a foreign static
--> $DIR/extern-no-mangle.rs:11:5
|
LL | #[no_mangle]
| ^^^^^^^^^^^^ help: remove this attribute
...
LL | pub static FOO: u8;
| ------------------- foreign static
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: symbol names in extern blocks are not mangled

warning: `#[no_mangle]` has no effect on a foreign function
--> $DIR/extern-no-mangle.rs:16:5
|
LL | #[no_mangle]
| ^^^^^^^^^^^^ help: remove this attribute
...
LL | pub fn bar();
| ------------- foreign function
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: symbol names in extern blocks are not mangled

warning: 3 warnings emitted