Skip to content

Commit 1cd6ddd

Browse files
committed
Auto merge of #154192 - JonathanBrouwer:rollup-TkGjSDo, r=JonathanBrouwer
Rollup of 7 pull requests Successful merges: - #122668 (Add APIs for dealing with titlecase) - #153312 (Packages as namespaces part 1) - #153534 (Remove a flaky `got_timeout` assert from two channel tests) - #154094 (add neon load/store assembly test) - #154175 (Add new alias for Guillaume Gomez email address) - #154182 (diagnostics: avoid ICE for undeclared generic parameter in impl) - #154188 (Update the tracking issue for #[diagnostic::on_move])
2 parents 562dee4 + e271e12 commit 1cd6ddd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1196
-168
lines changed

‎.mailmap‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ Guillaume Gomez <guillaume1.gomez@gmail.com>
262262
Guillaume Gomez <guillaume1.gomez@gmail.com> ggomez <ggomez@ggo.ifr.lan>
263263
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <ggomez@ggo.ifr.lan>
264264
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <guillaume.gomez@huawei.com>
265+
Guillaume Gomez <guillaume1.gomez@gmail.com> Guillaume Gomez <contact@guillaume-gomez.fr>
265266
gnzlbg <gonzalobg88@gmail.com> <gnzlbg@users.noreply.github.com>
266267
hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
267268
Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com>

‎compiler/rustc_feature/src/unstable.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ declare_features! (
473473
/// Allows giving non-const impls custom diagnostic messages if attempted to be used as const
474474
(unstable, diagnostic_on_const, "1.93.0", Some(143874)),
475475
/// Allows giving on-move borrowck custom diagnostic messages for a type
476-
(unstable, diagnostic_on_move, "CURRENT_RUSTC_VERSION", Some(150935)),
476+
(unstable, diagnostic_on_move, "CURRENT_RUSTC_VERSION", Some(154181)),
477477
/// Allows `#[doc(cfg(...))]`.
478478
(unstable, doc_cfg, "1.21.0", Some(43781)),
479479
/// Allows `#[doc(masked)]`.

‎compiler/rustc_hir/src/def.rs‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,13 @@ pub enum Res<Id = hir::HirId> {
590590
/// **Belongs to the type namespace.**
591591
ToolMod,
592592

593+
/// The resolution for an open module in a namespaced crate. E.g. `my_api`
594+
/// in the namespaced crate `my_api::utils` when `my_api` isn't part of the
595+
/// extern prelude.
596+
///
597+
/// **Belongs to the type namespace.**
598+
OpenMod(Symbol),
599+
593600
// Macro namespace
594601
/// An attribute that is *not* implemented via macro.
595602
/// E.g., `#[inline]` and `#[rustfmt::skip]`, which are essentially directives,
@@ -838,6 +845,7 @@ impl<Id> Res<Id> {
838845
| Res::SelfTyAlias { .. }
839846
| Res::SelfCtor(..)
840847
| Res::ToolMod
848+
| Res::OpenMod(..)
841849
| Res::NonMacroAttr(..)
842850
| Res::Err => None,
843851
}
@@ -869,6 +877,7 @@ impl<Id> Res<Id> {
869877
Res::Local(..) => "local variable",
870878
Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } => "self type",
871879
Res::ToolMod => "tool module",
880+
Res::OpenMod(..) => "namespaced crate",
872881
Res::NonMacroAttr(attr_kind) => attr_kind.descr(),
873882
Res::Err => "unresolved item",
874883
}
@@ -895,6 +904,7 @@ impl<Id> Res<Id> {
895904
Res::SelfTyAlias { alias_to, is_trait_impl }
896905
}
897906
Res::ToolMod => Res::ToolMod,
907+
Res::OpenMod(sym) => Res::OpenMod(sym),
898908
Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
899909
Res::Err => Res::Err,
900910
}
@@ -911,6 +921,7 @@ impl<Id> Res<Id> {
911921
Res::SelfTyAlias { alias_to, is_trait_impl }
912922
}
913923
Res::ToolMod => Res::ToolMod,
924+
Res::OpenMod(sym) => Res::OpenMod(sym),
914925
Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
915926
Res::Err => Res::Err,
916927
})
@@ -936,9 +947,11 @@ impl<Id> Res<Id> {
936947
pub fn ns(&self) -> Option<Namespace> {
937948
match self {
938949
Res::Def(kind, ..) => kind.ns(),
939-
Res::PrimTy(..) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } | Res::ToolMod => {
940-
Some(Namespace::TypeNS)
941-
}
950+
Res::PrimTy(..)
951+
| Res::SelfTyParam { .. }
952+
| Res::SelfTyAlias { .. }
953+
| Res::ToolMod
954+
| Res::OpenMod(..) => Some(Namespace::TypeNS),
942955
Res::SelfCtor(..) | Res::Local(..) => Some(Namespace::ValueNS),
943956
Res::NonMacroAttr(..) => Some(Namespace::MacroNS),
944957
Res::Err => None,

‎compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,6 +2830,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
28302830
| Res::SelfCtor(_)
28312831
| Res::Local(_)
28322832
| Res::ToolMod
2833+
| Res::OpenMod(..)
28332834
| Res::NonMacroAttr(_)
28342835
| Res::Err) => Const::new_error_with_message(
28352836
tcx,

‎compiler/rustc_passes/src/dead.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
157157
Res::Def(_, def_id) => self.check_def_id(def_id),
158158
Res::SelfTyParam { trait_: t } => self.check_def_id(t),
159159
Res::SelfTyAlias { alias_to: i, .. } => self.check_def_id(i),
160-
Res::ToolMod | Res::NonMacroAttr(..) | Res::Err => {}
160+
Res::ToolMod | Res::NonMacroAttr(..) | Res::OpenMod(..) | Res::Err => {}
161161
}
162162
}
163163

‎compiler/rustc_resolve/src/build_reduced_graph.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
357357
| Res::SelfTyParam { .. }
358358
| Res::SelfTyAlias { .. }
359359
| Res::SelfCtor(..)
360+
| Res::OpenMod(..)
360361
| Res::Err => bug!("unexpected resolution: {:?}", res),
361362
}
362363
}

‎compiler/rustc_resolve/src/diagnostics.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,8 +1740,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17401740
Res::Def(DefKind::Macro(kinds), _) => {
17411741
format!("{} {}", kinds.article(), kinds.descr())
17421742
}
1743-
Res::ToolMod => {
1744-
// Don't confuse the user with tool modules.
1743+
Res::ToolMod | Res::OpenMod(..) => {
1744+
// Don't confuse the user with tool modules or open modules.
17451745
continue;
17461746
}
17471747
Res::Def(DefKind::Trait, _) if macro_kind == MacroKind::Derive => {
@@ -1978,7 +1978,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19781978
let (built_in, from) = match scope {
19791979
Scope::StdLibPrelude | Scope::MacroUsePrelude => ("", " from prelude"),
19801980
Scope::ExternPreludeFlags
1981-
if self.tcx.sess.opts.externs.get(ident.as_str()).is_some() =>
1981+
if self.tcx.sess.opts.externs.get(ident.as_str()).is_some()
1982+
|| matches!(res, Res::OpenMod(..)) =>
19821983
{
19831984
("", " passed with `--extern`")
19841985
}

‎compiler/rustc_resolve/src/ident.rs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
AmbiguityError, AmbiguityKind, AmbiguityWarning, BindingKey, CmResolver, Decl, DeclKind,
2727
Determinacy, Finalize, IdentKey, ImportKind, LateDecl, Module, ModuleKind, ModuleOrUniformRoot,
2828
ParentScope, PathResult, PrivacyError, Res, ResolutionError, Resolver, Scope, ScopeSet,
29-
Segment, Stage, Used, errors,
29+
Segment, Stage, Symbol, Used, errors,
3030
};
3131

3232
#[derive(Copy, Clone)]
@@ -386,7 +386,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
386386
}
387387

388388
/// Resolve an identifier in the specified set of scopes.
389-
#[instrument(level = "debug", skip(self))]
390389
pub(crate) fn resolve_ident_in_scope_set<'r>(
391390
self: CmResolver<'r, 'ra, 'tcx>,
392391
orig_ident: Ident,
@@ -976,6 +975,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
976975
ignore_import,
977976
)
978977
}
978+
ModuleOrUniformRoot::OpenModule(sym) => {
979+
let open_ns_name = format!("{}::{}", sym.as_str(), ident.name);
980+
let ns_ident = IdentKey::with_root_ctxt(Symbol::intern(&open_ns_name));
981+
match self.extern_prelude_get_flag(ns_ident, ident.span, finalize.is_some()) {
982+
Some(decl) => Ok(decl),
983+
None => Err(Determinacy::Determined),
984+
}
985+
}
979986
ModuleOrUniformRoot::ModuleAndExternPrelude(module) => self.resolve_ident_in_scope_set(
980987
ident,
981988
ScopeSet::ModuleAndExternPrelude(ns, module),
@@ -1962,7 +1969,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19621969
}
19631970

19641971
let maybe_assoc = opt_ns != Some(MacroNS) && PathSource::Type.is_expected(res);
1965-
if let Some(def_id) = binding.res().module_like_def_id() {
1972+
if let Res::OpenMod(sym) = binding.res() {
1973+
module = Some(ModuleOrUniformRoot::OpenModule(sym));
1974+
record_segment_res(self.reborrow(), finalize, res, id);
1975+
} else if let Some(def_id) = binding.res().module_like_def_id() {
19661976
if self.mods_with_parse_errors.contains(&def_id) {
19671977
module_had_parse_errors = true;
19681978
}

‎compiler/rustc_resolve/src/imports.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type Res = def::Res<NodeId>;
4141

4242
/// A potential import declaration in the process of being planted into a module.
4343
/// Also used for lazily planting names from `--extern` flags to extern prelude.
44-
#[derive(Clone, Copy, Default, PartialEq)]
44+
#[derive(Clone, Copy, Default, PartialEq, Debug)]
4545
pub(crate) enum PendingDecl<'ra> {
4646
Ready(Option<Decl<'ra>>),
4747
#[default]

‎compiler/rustc_resolve/src/late/diagnostics.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3381,7 +3381,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
33813381
&& def_id.is_local()
33823382
&& let Some(local_def_id) = def_id.as_local()
33833383
&& let Some(struct_generics) = self.r.struct_generics.get(&local_def_id)
3384-
&& let target_param = &struct_generics.params[idx]
3384+
&& let Some(target_param) = &struct_generics.params.get(idx)
33853385
&& let GenericParamKind::Const { ty, .. } = &target_param.kind
33863386
&& let TyKind::Path(_, path) = &ty.kind
33873387
{

0 commit comments

Comments
 (0)