Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e9ea578
Move vcall_visibility_metadata optimization hint out of a debuginfo g…
bjorn3 Mar 30, 2024
7f44532
Remove PrintBackendInfo trait
bjorn3 Mar 30, 2024
98e8601
Remove const_bitcast from ConstMethods
bjorn3 Mar 30, 2024
e32eb4c
Dedup some intrinsic handling code for caller_location
bjorn3 Mar 30, 2024
22b3243
Move all intrinsic handling code in codegen_call_terminators together
bjorn3 Mar 30, 2024
aacdce3
Remove check_overflow method from MiscMethods
bjorn3 Mar 30, 2024
887f57f
Remove type_i1 and type_struct from cg_ssa
bjorn3 Mar 30, 2024
84f45bb
Fix doc comment
bjorn3 Mar 30, 2024
8a87f02
Improve error message in tidy
Kobzol Jun 25, 2024
151986f
Implement `x perf` as a separate tool
Kobzol Jun 27, 2024
a62cbda
Add feature diagnostic for unsafe_extern_blocks
spastorino Jun 29, 2024
50edb32
Fix a error suggestion for E0121 when using placeholder _ as return t…
surechen Jun 29, 2024
4442fd7
Add a run-make test that LLD is not being used by default on the x64 …
Kobzol Jun 28, 2024
9c0ce05
Show `used attribute`'s kind for user when find it isn't applied to a…
surechen Jun 29, 2024
8dc36c1
fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer
linyihai Jun 29, 2024
5dece2b
Remove uneccessary condition in `div_ceil`
TDecking Jun 29, 2024
f6f21a8
Review changes
Kobzol Jun 29, 2024
6a2638e
Autolabel `rustc-perf-wrapper` changes with t-bootstrap label
Kobzol Jun 29, 2024
15d5dac
Avoid suggesting to add unsafe when the extern block is already unsafe
spastorino Jun 29, 2024
5b90824
Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errors
matthiaskrgr Jun 29, 2024
6df6879
Rollup merge of #126960 - Kobzol:tidy-venv-message, r=tgross35
matthiaskrgr Jun 29, 2024
6d74ffd
Rollup merge of #127002 - Kobzol:bootstrap-perf-tool, r=onur-ozkan
matthiaskrgr Jun 29, 2024
fafb2ea
Rollup merge of #127081 - Kobzol:lld-test, r=onur-ozkan
matthiaskrgr Jun 29, 2024
7715295
Rollup merge of #127106 - spastorino:improve-unsafe-extern-blocks-dia…
matthiaskrgr Jun 29, 2024
80cf576
Rollup merge of #127110 - surechen:fix_125488_06, r=compiler-errors
matthiaskrgr Jun 29, 2024
9879b46
Rollup merge of #127114 - linyihai:issue-126863, r=Nadrieril
matthiaskrgr Jun 29, 2024
5ea1a03
Rollup merge of #127118 - surechen:fix_126789, r=jieyouxu
matthiaskrgr Jun 29, 2024
c79e08d
Rollup merge of #127122 - TDecking:div_ceil, r=Nilstrieb
matthiaskrgr Jun 29, 2024
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
29 changes: 21 additions & 8 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,18 @@ impl<'a> AstValidator<'a> {
fn check_item_safety(&self, span: Span, safety: Safety) {
match self.extern_mod_safety {
Some(extern_safety) => {
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
&& (extern_safety == Safety::Default || !self.features.unsafe_extern_blocks)
{
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: self.current_extern_span().shrink_to_lo(),
});
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_)) {
if extern_safety == Safety::Default {
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: Some(self.current_extern_span().shrink_to_lo()),
});
} else if !self.features.unsafe_extern_blocks {
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: None,
});
}
}
}
None => {
Expand Down Expand Up @@ -1098,7 +1103,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
}
} else if let &Safety::Unsafe(span) = safety {
this.dcx().emit_err(errors::UnsafeItem { span, kind: "extern block" });
let mut diag = this
.dcx()
.create_err(errors::UnsafeItem { span, kind: "extern block" });
rustc_session::parse::add_feature_diagnostics(
&mut diag,
self.session,
sym::unsafe_extern_blocks,
);
diag.emit();
}

if abi.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub struct InvalidSafetyOnExtern {
#[primary_span]
pub item_span: Span,
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
pub block: Span,
pub block: Option<Span>,
}

#[derive(Diagnostic)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ error: extern block cannot be declared unsafe
|
LL | unsafe extern "C" {
| ^^^^^^
|
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
= help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
--> $DIR/feature-gate-unsafe-extern-blocks.rs:9:5
Expand Down
9 changes: 4 additions & 5 deletions tests/ui/parser/unsafe-foreign-mod-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ error: extern block cannot be declared unsafe
|
LL | extern "C" unsafe {
| ^^^^^^
|
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
= help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: items in unadorned `extern` blocks cannot have safety qualifiers
--> $DIR/unsafe-foreign-mod-2.rs:4:5
|
LL | unsafe fn foo();
| ^^^^^^^^^^^^^^^^
|
help: add unsafe to this `extern` block
|
LL | unsafe extern "C" unsafe {
| ++++++

error: aborting due to 3 previous errors

4 changes: 4 additions & 0 deletions tests/ui/parser/unsafe-foreign-mod.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ error: extern block cannot be declared unsafe
|
LL | unsafe extern "C" {
| ^^^^^^
|
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
= help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 1 previous error