Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2643b16

Browse files
committed
Auto merge of rust-lang#99816 - GuillaumeGomez:rollup-tyobksa, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#94247 (Fix slice::ChunksMut aliasing) - rust-lang#99358 (Allow `ValTree::try_to_raw_bytes` on `u8` array) - rust-lang#99651 (Deeply deny fn and raw ptrs in const generics) - rust-lang#99710 (lint: add bad opt access internal lint) - rust-lang#99717 (Add some comments to the docs issue template to clarify) - rust-lang#99728 (Clean up HIR-based lifetime resolution) - rust-lang#99812 (Fix headings colors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents da5b546 + 2d52aa0 commit 2643b16

File tree

66 files changed

+1570
-1350
lines changed

Some content is hidden

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

66 files changed

+1570
-1350
lines changed

.github/ISSUE_TEMPLATE/documentation.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,28 @@ about: Create a report for a documentation problem.
44
labels: A-docs
55
---
66
<!--
7+
78
Thank you for finding a documentation problem! 📚
89
910
Documentation problems might be grammatical issues, typos, or unclear wording, please provide details regarding the documentation including where it is present.
1011
12+
Note: If your issue is for one of these, please use their dedicated issue tracker instead:
13+
14+
- The Rust Book: https://github.com/rust-lang/book/issues
15+
- Rust by Example: https://github.com/rust-lang/rust-by-example/issues
16+
- The Edition Guide: https://github.com/rust-lang/edition-guide/issues
17+
- The Cargo Book: https://github.com/rust-lang/cargo/issues
18+
- The Clippy Book: https://github.com/rust-lang/rust-clippy/issues
19+
- The Reference: https://github.com/rust-lang/reference/issues
20+
- The Rustonomicon: https://github.com/rust-lang/nomicon/issues
21+
- The Embedded Book: https://github.com/rust-embedded/book/issues
22+
23+
All other documentation issues should be filed here.
24+
25+
Or, if you find an issue related to rustdoc (e.g. doctest, rustdoc UI), please use the bug report or blank issue template instead.
26+
1127
-->
1228

1329
### Location
1430

1531
### Summary
16-

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,29 +1883,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18831883
}
18841884
hir::LifetimeName::Param(param, ParamName::Fresh)
18851885
}
1886-
LifetimeRes::Anonymous { binder, elided } => {
1887-
let mut l_name = None;
1888-
if let Some(mut captured_lifetimes) = self.captured_lifetimes.take() {
1889-
if !captured_lifetimes.binders_to_ignore.contains(&binder) {
1890-
let p_id = self.next_node_id();
1891-
let p_def_id = self.create_def(
1892-
captured_lifetimes.parent_def_id,
1893-
p_id,
1894-
DefPathData::LifetimeNs(kw::UnderscoreLifetime),
1895-
);
1896-
captured_lifetimes
1897-
.captures
1898-
.insert(p_def_id, (span, p_id, ParamName::Fresh, res));
1899-
l_name = Some(hir::LifetimeName::Param(p_def_id, ParamName::Fresh));
1900-
}
1901-
self.captured_lifetimes = Some(captured_lifetimes);
1902-
};
1903-
l_name.unwrap_or(if elided {
1904-
hir::LifetimeName::Implicit
1905-
} else {
1906-
hir::LifetimeName::Underscore
1907-
})
1908-
}
1886+
LifetimeRes::Infer => hir::LifetimeName::Infer,
19091887
LifetimeRes::Static => hir::LifetimeName::Static,
19101888
LifetimeRes::Error => hir::LifetimeName::Error,
19111889
res => panic!("Unexpected lifetime resolution {:?} for {:?} at {:?}", res, ident, span),

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
589589

590590
hir::LifetimeName::Param(_, hir::ParamName::Fresh)
591591
| hir::LifetimeName::ImplicitObjectLifetimeDefault
592-
| hir::LifetimeName::Implicit
593-
| hir::LifetimeName::Underscore => {
592+
| hir::LifetimeName::Infer => {
594593
// In this case, the user left off the lifetime; so
595594
// they wrote something like:
596595
//

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Qualif for CustomEq {
226226
// because that component may be part of an enum variant (e.g.,
227227
// `Option::<NonStructuralMatchTy>::Some`), in which case some values of this type may be
228228
// structural-match (`Option::None`).
229-
traits::search_for_structural_match_violation(cx.body.span, cx.tcx, ty, true).is_some()
229+
traits::search_for_structural_match_violation(cx.body.span, cx.tcx, ty).is_some()
230230
}
231231

232232
fn in_adt_inherently<'tcx>(

compiler/rustc_driver/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ impl Callbacks for TimePassesCallbacks {
123123
fn config(&mut self, config: &mut interface::Config) {
124124
// If a --prints=... option has been given, we don't print the "total"
125125
// time because it will mess up the --prints output. See #64339.
126-
self.time_passes = config.opts.prints.is_empty()
127-
&& (config.opts.unstable_opts.time_passes || config.opts.unstable_opts.time);
126+
self.time_passes = config.opts.prints.is_empty() && config.opts.time_passes();
128127
config.opts.trimmed_def_paths = TrimmedDefPaths::GoodPath;
129128
}
130129
}
@@ -249,7 +248,7 @@ fn run_compiler(
249248
if sopts.describe_lints {
250249
let mut lint_store = rustc_lint::new_lint_store(
251250
sopts.unstable_opts.no_interleave_lints,
252-
compiler.session().unstable_options(),
251+
compiler.session().enable_internal_lints(),
253252
);
254253
let registered_lints =
255254
if let Some(register_lints) = compiler.register_lints() {

compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,9 @@ passes-unused-duplicate = unused attribute
256256
passes-unused-multiple = multiple `{$name}` attributes
257257
.suggestion = remove this attribute
258258
.note = attribute also specified here
259+
260+
passes-rustc-lint-opt-ty = `#[rustc_lint_opt_ty]` should be applied to a struct
261+
.label = not a struct
262+
263+
passes-rustc-lint-opt-deny-field-access = `#[rustc_lint_opt_deny_field_access]` should be applied to a field
264+
.label = not a field

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
619619
// Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints
620620
// to assist in changes to diagnostic APIs.
621621
rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
622+
// Used by the `rustc::bad_opt_access` lint to identify `DebuggingOptions` and `CodegenOptions`
623+
// types (as well as any others in future).
624+
rustc_attr!(rustc_lint_opt_ty, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
625+
// Used by the `rustc::bad_opt_access` lint on fields
626+
// types (as well as any others in future).
627+
rustc_attr!(rustc_lint_opt_deny_field_access, Normal, template!(List: "message"), WarnFollowing, INTERNAL_UNSTABLE),
622628

623629
// ==========================================================================
624630
// Internal attributes, Const related:

compiler/rustc_hir/src/def.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -738,13 +738,8 @@ pub enum LifetimeRes {
738738
binder: NodeId,
739739
},
740740
/// This variant is used for anonymous lifetimes that we did not resolve during
741-
/// late resolution. Shifting the work to the HIR lifetime resolver.
742-
Anonymous {
743-
/// Id of the introducing place. See `Param`.
744-
binder: NodeId,
745-
/// Whether this lifetime was spelled or elided.
746-
elided: bool,
747-
},
741+
/// late resolution. Those lifetimes will be inferred by typechecking.
742+
Infer,
748743
/// Explicit `'static` lifetime.
749744
Static,
750745
/// Resolution failure.

compiler/rustc_hir/src/hir.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ pub enum LifetimeName {
9090
/// User-given names or fresh (synthetic) names.
9191
Param(LocalDefId, ParamName),
9292

93-
/// User wrote nothing (e.g., the lifetime in `&u32`).
94-
Implicit,
95-
9693
/// Implicit lifetime in a context like `dyn Foo`. This is
9794
/// distinguished from implicit lifetimes elsewhere because the
9895
/// lifetime that they default to must appear elsewhere within the
@@ -110,8 +107,9 @@ pub enum LifetimeName {
110107
/// that was already reported.
111108
Error,
112109

113-
/// User wrote specifies `'_`.
114-
Underscore,
110+
/// User wrote an anonymous lifetime, either `'_` or nothing.
111+
/// The semantics of this lifetime should be inferred by typechecking code.
112+
Infer,
115113

116114
/// User wrote `'static`.
117115
Static,
@@ -120,10 +118,8 @@ pub enum LifetimeName {
120118
impl LifetimeName {
121119
pub fn ident(&self) -> Ident {
122120
match *self {
123-
LifetimeName::ImplicitObjectLifetimeDefault
124-
| LifetimeName::Implicit
125-
| LifetimeName::Error => Ident::empty(),
126-
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
121+
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Error => Ident::empty(),
122+
LifetimeName::Infer => Ident::with_dummy_span(kw::UnderscoreLifetime),
127123
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
128124
LifetimeName::Param(_, param_name) => param_name.ident(),
129125
}
@@ -132,8 +128,7 @@ impl LifetimeName {
132128
pub fn is_anonymous(&self) -> bool {
133129
match *self {
134130
LifetimeName::ImplicitObjectLifetimeDefault
135-
| LifetimeName::Implicit
136-
| LifetimeName::Underscore
131+
| LifetimeName::Infer
137132
| LifetimeName::Param(_, ParamName::Fresh)
138133
| LifetimeName::Error => true,
139134
LifetimeName::Static | LifetimeName::Param(..) => false,
@@ -142,9 +137,7 @@ impl LifetimeName {
142137

143138
pub fn is_elided(&self) -> bool {
144139
match self {
145-
LifetimeName::ImplicitObjectLifetimeDefault
146-
| LifetimeName::Implicit
147-
| LifetimeName::Underscore => true,
140+
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,
148141

149142
// It might seem surprising that `Fresh` counts as
150143
// *not* elided -- but this is because, as far as the code

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,8 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime
496496
| LifetimeName::Param(_, ParamName::Error)
497497
| LifetimeName::Static
498498
| LifetimeName::Error
499-
| LifetimeName::Implicit
500499
| LifetimeName::ImplicitObjectLifetimeDefault
501-
| LifetimeName::Underscore => {}
500+
| LifetimeName::Infer => {}
502501
}
503502
}
504503

0 commit comments

Comments
 (0)