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 #126771

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9b22110
Add powerpc-unknown-openbsd maintaince status
ChrisDenton Jun 14, 2024
2220ef8
Add PidFd::{kill, wait, try_wait}
the8472 Apr 17, 2024
210400a
to extract a pidfd we must consume the child
the8472 Jun 13, 2024
c4ddc86
Print the tested value in int_log tests
tgross35 Jun 18, 2024
d51b446
Improve conflict marker recovery
dev-ardi Jun 7, 2024
9f63712
make this comment correct
dev-ardi Jun 10, 2024
b6d20d1
Add the target-features
sayantn Jun 18, 2024
1e1b3fc
Fix stderr cases
sayantn Jun 18, 2024
75ee1d7
rewrite relocation-model to rmake
Oneirical Jun 19, 2024
f22b5af
rewrite error-writing-dependencies to rmake
Oneirical Jun 19, 2024
a656bb6
Specify target for inaccessible-temp-dir rmake test
Hoverbear Jun 19, 2024
108b3f2
Properly gate `safe` keyword in pre-expansion
compiler-errors Jun 20, 2024
3c0a4bc
rewrite crate-name-priority to rmake
Oneirical Jun 19, 2024
3d6d9e2
Do not allow safe usafe on static and fn items
spastorino Jun 20, 2024
c0e1338
Rollup merge of #124101 - the8472:pidfd-methods, r=cuviper
workingjubilee Jun 21, 2024
b1d0604
Rollup merge of #126125 - dev-ardi:conflict-markers, r=estebank
workingjubilee Jun 21, 2024
7ba62e3
Rollup merge of #126481 - ChrisDenton:powerpc-unkown-openbsd, r=ehuss
workingjubilee Jun 21, 2024
f926188
Rollup merge of #126613 - tgross35:log-test-update, r=cuviper
workingjubilee Jun 21, 2024
1854318
Rollup merge of #126617 - sayantn:veorq, r=workingjubilee
workingjubilee Jun 21, 2024
0d83c05
Rollup merge of #126707 - ferrocene:hoverbear/fix-inaccessible-temp-d…
workingjubilee Jun 21, 2024
fb7304d
Rollup merge of #126712 - Oneirical:bootest-constestllation, r=jieyouxu
workingjubilee Jun 21, 2024
78d6afa
Rollup merge of #126757 - compiler-errors:safe, r=spastorino
workingjubilee Jun 21, 2024
ff05860
Rollup merge of #126758 - spastorino:avoid-safe-outside-unsafe-blocks…
workingjubilee Jun 21, 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
6 changes: 6 additions & 0 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetim
ast_passes_bad_c_variadic = only foreign or `unsafe extern "C"` functions may be C-variadic
ast_passes_bare_fn_invalid_safety = function pointers cannot be declared with `safe` safety qualifier
.suggestion = remove safe from this item
ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
.cannot_have = cannot have a body
.invalid = the invalid body
Expand Down Expand Up @@ -167,6 +170,9 @@ ast_passes_invalid_unnamed_field_ty =
unnamed fields can only have struct or union types
.label = not a struct or union
ast_passes_item_invalid_safety = items outside of `unsafe extern {"{ }"}` cannot be declared with `safe` safety qualifier
.suggestion = remove safe from this item
ast_passes_item_underscore = `{$kind}` items in this context need a name
.label = `_` is not a valid name for this `{$kind}` item
Expand Down
54 changes: 38 additions & 16 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,29 @@ impl<'a> AstValidator<'a> {
}
}

fn check_foreign_item_safety(&self, item_span: Span, safety: Safety) {
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
&& (self.extern_mod_safety == Some(Safety::Default)
|| !self.features.unsafe_extern_blocks)
{
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span,
block: self.current_extern_span(),
});
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(),
});
}
}
None => {
if matches!(safety, Safety::Safe(_)) {
self.dcx().emit_err(errors::InvalidSafetyOnItem { span });
}
}
}
}

fn check_bare_fn_safety(&self, span: Span, safety: Safety) {
if matches!(safety, Safety::Safe(_)) {
self.dcx().emit_err(errors::InvalidSafetyOnBareFn { span });
}
}

Expand Down Expand Up @@ -746,6 +760,7 @@ impl<'a> AstValidator<'a> {
fn visit_ty_common(&mut self, ty: &'a Ty) {
match &ty.kind {
TyKind::BareFn(bfty) => {
self.check_bare_fn_safety(bfty.decl_span, bfty.safety);
self.check_fn_decl(&bfty.decl, SelfSemantic::No);
Self::check_decl_no_pat(&bfty.decl, |span, _, _| {
self.dcx().emit_err(errors::PatternFnPointer { span });
Expand Down Expand Up @@ -1174,11 +1189,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
});
}
}
ItemKind::Static(box StaticItem { expr: None, .. }) => {
self.dcx().emit_err(errors::StaticWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
ItemKind::Static(box StaticItem { expr, safety, .. }) => {
self.check_item_safety(item.span, *safety);

if expr.is_none() {
self.dcx().emit_err(errors::StaticWithoutBody {
span: item.span,
replace_span: self.ending_semi_or_hi(item.span),
});
}
}
ItemKind::TyAlias(
ty_alias @ box TyAlias { defaultness, bounds, where_clauses, ty, .. },
Expand Down Expand Up @@ -1212,7 +1231,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
match &fi.kind {
ForeignItemKind::Fn(box Fn { defaultness, sig, body, .. }) => {
self.check_foreign_item_safety(fi.span, sig.header.safety);
self.check_defaultness(fi.span, *defaultness);
self.check_foreign_fn_bodyless(fi.ident, body.as_deref());
self.check_foreign_fn_headerless(sig.header);
Expand All @@ -1233,7 +1251,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self.check_foreign_item_ascii_only(fi.ident);
}
ForeignItemKind::Static(box StaticForeignItem { expr, safety, .. }) => {
self.check_foreign_item_safety(fi.span, *safety);
self.check_item_safety(fi.span, *safety);
self.check_foreign_kind_bodyless(fi.ident, "static", expr.as_ref().map(|b| b.span));
self.check_foreign_item_ascii_only(fi.ident);
}
Expand Down Expand Up @@ -1453,6 +1471,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
};
self.check_fn_decl(fk.decl(), self_semantic);

if let Some(&FnHeader { safety, .. }) = fk.header() {
self.check_item_safety(span, safety);
}

self.check_c_variadic_type(fk);

// Functions cannot both be `const async` or `const gen`
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ pub struct InvalidSafetyOnExtern {
pub block: Span,
}

#[derive(Diagnostic)]
#[diag(ast_passes_item_invalid_safety)]
pub struct InvalidSafetyOnItem {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_passes_bare_fn_invalid_safety)]
pub struct InvalidSafetyOnBareFn {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_passes_bound_in_context)]
pub struct BoundInContext<'a> {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
gate_all!(global_registration, "global registration is experimental");
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
gate_all!(
unsafe_extern_blocks,
"`unsafe extern {}` blocks and `safe` keyword are experimental"
);

if !visitor.features.never_patterns {
if let Some(spans) = spans.get(&sym::never_patterns) {
Expand Down
58 changes: 42 additions & 16 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,9 +2965,10 @@ impl<'a> Parser<'a> {

/// This checks if this is a conflict marker, depending of the parameter passed.
///
/// * `>>>>>`
/// * `=====`
/// * `<<<<<`
/// * `<<<<<<<`
/// * `|||||||`
/// * `=======`
/// * `>>>>>>>`
///
pub(super) fn is_vcs_conflict_marker(
&mut self,
Expand Down Expand Up @@ -2997,14 +2998,18 @@ impl<'a> Parser<'a> {
}

pub(crate) fn err_vcs_conflict_marker(&mut self) -> PResult<'a, ()> {
// <<<<<<<
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt)
else {
return Ok(());
};
let mut spans = Vec::with_capacity(3);
spans.push(start);
// |||||||
let mut middlediff3 = None;
// =======
let mut middle = None;
// >>>>>>>
let mut end = None;
loop {
if self.token.kind == TokenKind::Eof {
Expand All @@ -3025,29 +3030,50 @@ impl<'a> Parser<'a> {
}
self.bump();
}

let mut err = self.dcx().struct_span_err(spans, "encountered diff marker");
err.span_label(start, "after this is the code before the merge");
if let Some(middle) = middlediff3 {
err.span_label(middle, "");
}
match middlediff3 {
// We're using diff3
Some(middlediff3) => {
err.span_label(
start,
"between this marker and `|||||||` is the code that we're merging into",
);
err.span_label(middlediff3, "between this marker and `=======` is the base code (what the two refs diverged from)");
}
None => {
err.span_label(
start,
"between this marker and `=======` is the code that we're merging into",
);
}
};

if let Some(middle) = middle {
err.span_label(middle, "");
err.span_label(middle, "between this marker and `>>>>>>>` is the incoming code");
}
if let Some(end) = end {
err.span_label(end, "above this are the incoming code changes");
err.span_label(end, "this marker concludes the conflict region");
}
err.help(
"if you're having merge conflicts after pulling new code, the top section is the code \
you already had and the bottom section is the remote code",
err.note(
"conflict markers indicate that a merge was started but could not be completed due \
to merge conflicts\n\
to resolve a conflict, keep only the code you want and then delete the lines \
containing conflict markers",
);
err.help(
"if you're in the middle of a rebase, the top section is the code being rebased onto \
and the bottom section is the code coming from the current commit being rebased",
"if you're having merge conflicts after pulling new code:\n\
the top section is the code you already had and the bottom section is the remote code\n\
if you're in the middle of a rebase:\n\
the top section is the code being rebased onto and the bottom section is the code \
coming from the current commit being rebased",
);

err.note(
"for an explanation on these markers from the `git` documentation, visit \
<https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
"for an explanation on these markers from the `git` documentation:\n\
visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
);

Err(err)
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ impl<'a> Parser<'a> {
if self.eat_keyword_case(kw::Unsafe, case) {
Safety::Unsafe(self.prev_token.uninterpolated_span())
} else if self.eat_keyword_case(kw::Safe, case) {
self.psess
.gated_spans
.gate(sym::unsafe_extern_blocks, self.prev_token.uninterpolated_span());
Safety::Safe(self.prev_token.uninterpolated_span())
} else {
Safety::Default
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ const X86_ALLOWED_FEATURES: &[(&str, Stability)] = &[
("avx512vnni", Unstable(sym::avx512_target_feature)),
("avx512vp2intersect", Unstable(sym::avx512_target_feature)),
("avx512vpopcntdq", Unstable(sym::avx512_target_feature)),
("avxifma", Unstable(sym::avx512_target_feature)),
("avxneconvert", Unstable(sym::avx512_target_feature)),
("avxvnni", Unstable(sym::avx512_target_feature)),
("avxvnniint16", Unstable(sym::avx512_target_feature)),
("avxvnniint8", Unstable(sym::avx512_target_feature)),
("bmi1", Stable),
("bmi2", Stable),
("cmpxchg16b", Stable),
Expand Down
26 changes: 13 additions & 13 deletions library/core/tests/num/int_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ fn checked_ilog() {

#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_ilog(4), None);
assert_eq!(i.checked_ilog(4), None, "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32));
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32));
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}");
}
}

Expand All @@ -49,30 +49,30 @@ fn checked_ilog2() {
assert_eq!(0i16.checked_ilog2(), None);

for i in 1..=u8::MAX {
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
// Guard against Android's imprecise f32::ilog2 implementation.
if i != 8192 && i != 32768 {
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}");
}
}
for i in i8::MIN..=0 {
assert_eq!(i.checked_ilog2(), None);
assert_eq!(i.checked_ilog2(), None, "checking {i}");
}
for i in 1..=i8::MAX {
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_ilog2(), None);
assert_eq!(i.checked_ilog2(), None, "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
// Guard against Android's imprecise f32::ilog2 implementation.
if i != 8192 {
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}");
}
}
}
Expand All @@ -95,19 +95,19 @@ fn checked_ilog10() {

#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_ilog10(), None);
assert_eq!(i.checked_ilog10(), None, "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}");
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=100_000u32 {
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}");
}
}

Expand Down
Loading
Loading