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

Merged
merged 32 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dee1c26
xous: ffi: fix lend_impl() return values
xobs Dec 7, 2023
944dc21
xous: ffi: correct size of freed memory
xobs Dec 24, 2023
118e8f7
xous: std: thread_parking: fix deadlocks
bunnie Dec 22, 2023
626926f
std: xous: rework condvar to fix soundness issues
xobs Dec 24, 2023
f732d2b
std: xous: pass entire memory range to flag updater
xobs Dec 29, 2023
b5c1c47
std: xous: use blocking_scalars for mutex unlock
xobs Dec 29, 2023
eabd445
std: xous: rewrite rwlock to be more robust
xobs Dec 24, 2023
762e58a
std: once: use queue implementation on Xous
xobs Dec 24, 2023
007bf7a
std: xous: fix thread_local_key under tests
xobs Dec 24, 2023
ef4f722
std: xous: share allocator symbol in tests
xobs Dec 29, 2023
aa8acc2
xous: net: initial commit of network support
xobs Nov 7, 2023
aa73860
std: xous: mark stdio structs as `repr(C)`
xobs Dec 29, 2023
99b0659
std: xous: use constants for stdout and stderr
xobs Dec 29, 2023
50e4fed
xous: thread: mark thread_main() as divergent
xobs Dec 29, 2023
89cf177
std::net: bind update for using backlog as `-1` too.
devnexen Jan 13, 2024
a8bb418
make unsafe_op_in_unsafe_fn MachineApplicable and add it to 2024 comp…
asquared31415 Jan 13, 2024
1c77f87
add help message for `exclusive_range_pattern` error
rowan-sl Jan 19, 2024
755cfbf
core: introduce split_at{,_mut}_checked
mina86 Dec 3, 2023
9c3091e
exclude unexported macro bindings from extern crate
bvanjoi Dec 28, 2023
1afd216
use u64 to represent file size
onur-ozkan Jan 21, 2024
50cbbef
review
mina86 Jan 21, 2024
802d16c
Don't actually make bound ty/const for RTN
compiler-errors Jan 21, 2024
7ce206d
Fix -Zremap-path-scope typo
micolous Jan 22, 2024
99b4f80
Rollup merge of #118578 - mina86:c, r=dtolnay
matthiaskrgr Jan 22, 2024
c5984ca
Rollup merge of #119369 - bvanjoi:fix-119301, r=petrochenkov
matthiaskrgr Jan 22, 2024
e9c2e1b
Rollup merge of #119408 - betrusted-io:xous-fixes-add-network, r=Mark…
matthiaskrgr Jan 22, 2024
8c3c8bb
Rollup merge of #119943 - devnexen:listener_update3, r=thomcc
matthiaskrgr Jan 22, 2024
34bab29
Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r…
matthiaskrgr Jan 22, 2024
9e896f4
Rollup merge of #119999 - onur-ozkan:remote-test-tools, r=Mark-Simula…
matthiaskrgr Jan 22, 2024
2346647
Rollup merge of #120152 - rowan-sl:help-message-for-range-pattern, r=…
matthiaskrgr Jan 22, 2024
ba542c8
Rollup merge of #120213 - compiler-errors:dont-make-non-lifetime-bind…
matthiaskrgr Jan 22, 2024
44e44f4
Rollup merge of #120225 - micolous:patch-1, r=michaelwoerister
matthiaskrgr Jan 22, 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
3 changes: 2 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
&self,
exclusive_range_pattern,
pattern.span,
"exclusive range pattern syntax is experimental"
"exclusive range pattern syntax is experimental",
"use an inclusive range pattern, like N..=M"
);
}
_ => {}
Expand Down
34 changes: 9 additions & 25 deletions compiler/rustc_hir_analysis/src/astconv/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
}

let projection_ty = if let ty::AssocKind::Fn = assoc_kind {
let mut emitted_bad_param_err = false;
let mut emitted_bad_param_err = None;
// If we have an method return type bound, then we need to substitute
// the method's early bound params with suitable late-bound params.
let mut num_bound_vars = candidate.bound_vars().len();
Expand All @@ -346,46 +346,30 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
)
.into(),
ty::GenericParamDefKind::Type { .. } => {
if !emitted_bad_param_err {
let guar = *emitted_bad_param_err.get_or_insert_with(|| {
tcx.dcx().emit_err(
crate::errors::ReturnTypeNotationIllegalParam::Type {
span: path_span,
param_span: tcx.def_span(param.def_id),
},
);
emitted_bad_param_err = true;
}
Ty::new_bound(
tcx,
ty::INNERMOST,
ty::BoundTy {
var: ty::BoundVar::from_usize(num_bound_vars),
kind: ty::BoundTyKind::Param(param.def_id, param.name),
},
)
.into()
)
});
Ty::new_error(tcx, guar).into()
}
ty::GenericParamDefKind::Const { .. } => {
if !emitted_bad_param_err {
let guar = *emitted_bad_param_err.get_or_insert_with(|| {
tcx.dcx().emit_err(
crate::errors::ReturnTypeNotationIllegalParam::Const {
span: path_span,
param_span: tcx.def_span(param.def_id),
},
);
emitted_bad_param_err = true;
}
)
});
let ty = tcx
.type_of(param.def_id)
.no_bound_vars()
.expect("ct params cannot have early bound vars");
ty::Const::new_bound(
tcx,
ty::INNERMOST,
ty::BoundVar::from_usize(num_bound_vars),
ty,
)
.into()
ty::Const::new_error(tcx, guar, ty).into()
}
};
num_bound_vars += 1;
Expand Down
52 changes: 52 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,11 @@ declare_lint! {
pub UNSAFE_OP_IN_UNSAFE_FN,
Allow,
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
reference: "issue #71668 <https://github.com/rust-lang/rust/issues/71668>",
explain_reason: false
};
@edition Edition2024 => Warn;
}

Expand Down Expand Up @@ -4604,3 +4609,50 @@ declare_lint! {
reference: "issue #X <https://github.com/rust-lang/rust/issues/X>",
};
}

declare_lint! {
/// The `private_macro_use` lint detects private macros that are imported
/// with `#[macro_use]`.
///
/// ### Example
///
/// ```rust,ignore (needs extern crate)
/// // extern_macro.rs
/// macro_rules! foo_ { () => {}; }
/// use foo_ as foo;
///
/// // code.rs
///
/// #![deny(private_macro_use)]
///
/// #[macro_use]
/// extern crate extern_macro;
///
/// fn main() {
/// foo!();
/// }
/// ```
///
/// This will produce:
///
/// ```text
/// error: cannot find macro `foo` in this scope
/// ```
///
/// ### Explanation
///
/// This lint arises from overlooking visibility checks for macros
/// in an external crate.
///
/// This is a [future-incompatible] lint to transition this to a
/// hard error in the future.
///
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub PRIVATE_MACRO_USE,
Warn,
"detects certain macro bindings that should not be re-exported",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #120192 <https://github.com/rust-lang/rust/issues/120192>",
};
}
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl AddToDiagnostic for UnsafeNotInheritedLintNote {
diag.tool_only_multipart_suggestion(
fluent::mir_build_wrap_suggestion,
vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
Applicability::MaybeIncorrect,
Applicability::MachineApplicable,
);
}
}
Expand Down
24 changes: 19 additions & 5 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,9 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
}
}

let macro_use_import = |this: &Self, span| {
let macro_use_import = |this: &Self, span, warn_private| {
this.r.arenas.alloc_import(ImportData {
kind: ImportKind::MacroUse,
kind: ImportKind::MacroUse { warn_private },
root_id: item.id,
parent_scope: this.parent_scope,
imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
Expand All @@ -1048,11 +1048,25 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {

let allow_shadowing = self.parent_scope.expansion == LocalExpnId::ROOT;
if let Some(span) = import_all {
let import = macro_use_import(self, span);
let import = macro_use_import(self, span, false);
self.r.potentially_unused_imports.push(import);
module.for_each_child(self, |this, ident, ns, binding| {
if ns == MacroNS {
let imported_binding = this.r.import(binding, import);
let imported_binding =
if this.r.is_accessible_from(binding.vis, this.parent_scope.module) {
this.r.import(binding, import)
} else if !this.r.is_builtin_macro(binding.res())
&& !this.r.macro_use_prelude.contains_key(&ident.name)
{
// - `!r.is_builtin_macro(res)` excluding the built-in macros such as `Debug` or `Hash`.
// - `!r.macro_use_prelude.contains_key(name)` excluding macros defined in other extern
// crates such as `std`.
// FIXME: This branch should eventually be removed.
let import = macro_use_import(this, span, true);
this.r.import(binding, import)
} else {
return;
};
this.add_macro_use_binding(ident.name, imported_binding, span, allow_shadowing);
}
});
Expand All @@ -1065,7 +1079,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
&self.parent_scope,
);
if let Ok(binding) = result {
let import = macro_use_import(self, ident.span);
let import = macro_use_import(self, ident.span, false);
self.r.potentially_unused_imports.push(import);
let imported_binding = self.r.import(binding, import);
self.add_macro_use_binding(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl Resolver<'_, '_> {
|| import.expect_vis().is_public()
|| import.span.is_dummy() =>
{
if let ImportKind::MacroUse = import.kind {
if let ImportKind::MacroUse { .. } = import.kind {
if !import.span.is_dummy() {
self.lint_buffer.buffer_lint(
MACRO_USE_EXTERN_CRATE,
Expand All @@ -315,7 +315,7 @@ impl Resolver<'_, '_> {
maybe_unused_extern_crates.insert(id, import.span);
}
}
ImportKind::MacroUse => {
ImportKind::MacroUse { .. } => {
let msg = "unused `#[macro_use]` import";
self.lint_buffer.buffer_lint(UNUSED_IMPORTS, import.root_id, import.span, msg);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
use NameBindingKind::Import;
let can_suggest = |binding: NameBinding<'_>, import: self::Import<'_>| {
!binding.span.is_dummy()
&& !matches!(import.kind, ImportKind::MacroUse | ImportKind::MacroExport)
&& !matches!(import.kind, ImportKind::MacroUse { .. } | ImportKind::MacroExport)
};
let import = match (&new_binding.kind, &old_binding.kind) {
// If there are two imports where one or both have attributes then prefer removing the
Expand Down Expand Up @@ -1819,9 +1819,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
next_ident = source;
Some(binding)
}
ImportKind::Glob { .. } | ImportKind::MacroUse | ImportKind::MacroExport => {
Some(binding)
}
ImportKind::Glob { .. }
| ImportKind::MacroUse { .. }
| ImportKind::MacroExport => Some(binding),
ImportKind::ExternCrate { .. } => None,
},
_ => None,
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ pub(crate) enum ImportKind<'a> {
target: Ident,
id: NodeId,
},
MacroUse,
MacroUse {
/// A field has been added indicating whether it should be reported as a lint,
/// addressing issue#119301.
warn_private: bool,
},
MacroExport,
}

Expand Down Expand Up @@ -127,7 +131,7 @@ impl<'a> std::fmt::Debug for ImportKind<'a> {
.field("target", target)
.field("id", id)
.finish(),
MacroUse => f.debug_struct("MacroUse").finish(),
MacroUse { .. } => f.debug_struct("MacroUse").finish(),
MacroExport => f.debug_struct("MacroExport").finish(),
}
}
Expand Down Expand Up @@ -197,7 +201,7 @@ impl<'a> ImportData<'a> {
ImportKind::Single { id, .. }
| ImportKind::Glob { id, .. }
| ImportKind::ExternCrate { id, .. } => Some(id),
ImportKind::MacroUse | ImportKind::MacroExport => None,
ImportKind::MacroUse { .. } | ImportKind::MacroExport => None,
}
}

Expand All @@ -207,7 +211,7 @@ impl<'a> ImportData<'a> {
ImportKind::Single { id, .. } => Reexport::Single(to_def_id(id)),
ImportKind::Glob { id, .. } => Reexport::Glob(to_def_id(id)),
ImportKind::ExternCrate { id, .. } => Reexport::ExternCrate(to_def_id(id)),
ImportKind::MacroUse => Reexport::MacroUse,
ImportKind::MacroUse { .. } => Reexport::MacroUse,
ImportKind::MacroExport => Reexport::MacroExport,
}
}
Expand Down Expand Up @@ -1482,7 +1486,7 @@ fn import_kind_to_string(import_kind: &ImportKind<'_>) -> String {
ImportKind::Single { source, .. } => source.to_string(),
ImportKind::Glob { .. } => "*".to_string(),
ImportKind::ExternCrate { .. } => "<extern crate>".to_string(),
ImportKind::MacroUse => "#[macro_use]".to_string(),
ImportKind::MacroUse { .. } => "#[macro_use]".to_string(),
ImportKind::MacroExport => "#[macro_export]".to_string(),
}
}
5 changes: 5 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::{self, MainDefinition, RegisteredTools, TyCtxt};
use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
use rustc_session::lint::LintBuffer;
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
Expand Down Expand Up @@ -1799,6 +1800,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}
if let NameBindingKind::Import { import, binding, ref used } = used_binding.kind {
if let ImportKind::MacroUse { warn_private: true } = import.kind {
let msg = format!("macro `{ident}` is private");
self.lint_buffer().buffer_lint(PRIVATE_MACRO_USE, import.root_id, ident.span, msg);
}
// Avoid marking `extern crate` items that refer to a name from extern prelude,
// but not introduce it, as used if they are accessed from lexical scope.
if is_lexical_scope {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
#![feature(set_ptr_value)]
#![feature(slice_ptr_get)]
#![feature(slice_split_at_unchecked)]
#![feature(split_at_checked)]
#![feature(str_internals)]
#![feature(str_split_inclusive_remainder)]
#![feature(str_split_remainder)]
Expand Down
Loading
Loading