Skip to content

Commit b52edc2

Browse files
committed
Auto merge of #156834 - JonathanBrouwer:rollup-TdEisIq, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - #155509 ([Debug Info] Gracefully handle invalid `String`/`Vec`) - #156229 (Install additional LLVM DLL on Windows) - #152821 (Allow forbidden target features to be hard errors) - #156560 (compiler: fix duplicated "the" in two doc-comments) - #156725 (Remove stale RTN FIXME for assoc item constraint fallback) - #156803 (Fix reborrow ICE in MIR place lowering) - #156815 (rustfmt: format const trait impls to `const impl` for syntax transition) - #156818 (Privacy: enqueue type alias) - #156820 (delegation: visit body under elided-infer lifetime rib) - #156829 (Turn `lint_index` from `Option<u16>` to `u16` for LintExpectationId)
2 parents 62f36da + 29eaf53 commit b52edc2

27 files changed

Lines changed: 295 additions & 109 deletions

File tree

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
11971197
}
11981198
} else {
11991199
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
1200-
// FIXME(return_type_notation): we could issue a feature error
1201-
// if the parens are empty and there's no return type.
12021200
self.lower_angle_bracketed_parameter_data(
12031201
&data.as_angle_bracketed_args(),
12041202
ParamMode::Explicit,

compiler/rustc_borrowck/src/diagnostics/var_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use tracing::debug;
88
use crate::region_infer::RegionInferenceContext;
99

1010
impl<'tcx> RegionInferenceContext<'tcx> {
11-
/// Find the the name and span of the variable corresponding to the given region.
11+
/// Find the name and span of the variable corresponding to the given region.
1212
/// The returned var will also be ensured to actually be used in `body`.
1313
pub(crate) fn get_var_name_and_span_for_region(
1414
&self,

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,14 +1220,17 @@ pub(crate) struct UnstableCTargetFeature<'a> {
12201220

12211221
#[derive(Diagnostic)]
12221222
#[diag("target feature `{$feature}` cannot be {$enabled} with `-Ctarget-feature`: {$reason}")]
1223-
#[note(
1224-
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
1225-
)]
1226-
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
12271223
pub(crate) struct ForbiddenCTargetFeature<'a> {
12281224
pub feature: &'a str,
12291225
pub enabled: &'a str,
12301226
pub reason: &'a str,
1227+
#[note(
1228+
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
1229+
)]
1230+
#[note(
1231+
"for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>"
1232+
)]
1233+
pub future_compat_note: bool,
12311234
}
12321235

12331236
pub(crate) struct TargetFeatureDisableOrEnable<'a> {

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,19 @@ pub fn cfg_target_feature<'a, const N: usize>(
308308
sess.dcx().emit_warn(unknown_feature);
309309
}
310310
Some((_, stability, _)) => {
311-
if let Err(reason) = stability.toggle_allowed() {
312-
sess.dcx().emit_warn(errors::ForbiddenCTargetFeature {
311+
if let Stability::Forbidden { reason, hard_error } = stability {
312+
let diag = errors::ForbiddenCTargetFeature {
313313
feature: base_feature,
314314
enabled: if enable { "enabled" } else { "disabled" },
315315
reason,
316-
});
316+
future_compat_note: !hard_error,
317+
};
318+
319+
if *hard_error {
320+
sess.dcx().emit_err(diag);
321+
} else {
322+
sess.dcx().emit_warn(diag);
323+
}
317324
} else if stability.requires_nightly(/* in_cfg */ false).is_some() {
318325
// An unstable feature. Warn about using it. It makes little sense
319326
// to hard-error here since we just warn about fully unknown

compiler/rustc_lint/src/expect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
3838
(tcx.hir_attrs(id.hir_id)[id.attr_index as usize].id(), id.lint_index)
3939
}
4040
};
41-
(attr_id, lint_index.expect("fulfilled expectations must have a lint index"))
41+
(attr_id, lint_index)
4242
};
4343

4444
let fulfilled_expectations: FxHashSet<_> =

compiler/rustc_lint/src/levels.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub trait LintLevelsProvider {
233233
&self,
234234
attr_id: AttrId,
235235
attr_index: usize,
236-
lint_index: Option<u16>,
236+
lint_index: u16,
237237
) -> Self::LintExpectationId;
238238
}
239239

@@ -258,7 +258,7 @@ impl LintLevelsProvider for TopDown {
258258
&self,
259259
attr_id: AttrId,
260260
_attr_index: usize,
261-
lint_index: Option<u16>,
261+
lint_index: u16,
262262
) -> Self::LintExpectationId {
263263
UnstableLintExpectationId { attr_id, lint_index }
264264
}
@@ -296,7 +296,7 @@ impl LintLevelsProvider for LintLevelQueryMap<'_> {
296296
&self,
297297
_attr_id: AttrId,
298298
attr_index: usize,
299-
lint_index: Option<u16>,
299+
lint_index: u16,
300300
) -> Self::LintExpectationId {
301301
let attr_index = attr_index.try_into().unwrap();
302302
StableLintExpectationId { hir_id: self.cur, attr_index, lint_index }
@@ -740,11 +740,7 @@ where
740740
// `Expect` is the only lint level with a `LintExpectationId` that can be created
741741
// from an attribute.
742742
let lint_id = (level == Level::Expect).then(|| {
743-
self.provider.mk_lint_expectation_id(
744-
attr.id(),
745-
attr_index,
746-
Some(lint_index as u16),
747-
)
743+
self.provider.mk_lint_expectation_id(attr.id(), attr_index, lint_index as u16)
748744
});
749745

750746
let sp = li.span();

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub enum LintExpectationId {
109109
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Encodable, Decodable)]
110110
pub struct UnstableLintExpectationId {
111111
pub attr_id: AttrId,
112-
pub lint_index: Option<u16>,
112+
pub lint_index: u16,
113113
}
114114

115115
impl From<UnstableLintExpectationId> for LintExpectationId {
@@ -125,7 +125,7 @@ impl From<UnstableLintExpectationId> for LintExpectationId {
125125
pub struct StableLintExpectationId {
126126
pub hir_id: HirId,
127127
pub attr_index: u16,
128-
pub lint_index: Option<u16>,
128+
pub lint_index: u16,
129129
}
130130

131131
impl StableHash for StableLintExpectationId {
@@ -135,7 +135,7 @@ impl StableHash for StableLintExpectationId {
135135

136136
hir_id.stable_hash(hcx, hasher);
137137
attr_index.stable_hash(hcx, hasher);
138-
lint_index.expect("must be filled to call `stable_hash`").stable_hash(hcx, hasher);
138+
lint_index.stable_hash(hcx, hasher);
139139
}
140140
}
141141

compiler/rustc_mir_build/src/builder/expr/as_place.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,19 +583,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
583583
| ExprKind::ThreadLocalRef(_)
584584
| ExprKind::Call { .. }
585585
| ExprKind::ByUse { .. }
586+
// A reborrow is an rvalue. If a place is needed for it, materialize
587+
// the rvalue in a temporary instead of treating the reborrow
588+
// expression itself as an assignable place.
589+
| ExprKind::Reborrow { .. }
586590
| ExprKind::WrapUnsafeBinder { .. } => {
587591
// these are not places, so we need to make a temporary.
588592
debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Place)));
589593
let temp_lifetime = this.region_scope_tree.temporary_scope(expr.temp_scope_id);
590594
let temp = unpack!(block = this.as_temp(block, temp_lifetime, expr_id, mutability));
591595
block.and(PlaceBuilder::from(temp))
592596
}
593-
ExprKind::Reborrow { .. } => {
594-
// FIXME(reborrow): it should currently be impossible to end up evaluating a
595-
// Reborrow expression as a place. That might not in the future, but what this then
596-
// evaluates to requires further thought.
597-
unreachable!();
598-
}
599597
}
600598
}
601599

compiler/rustc_mir_build/src/builder/expr/category.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ impl Category {
4343
| ExprKind::PlaceTypeAscription { .. }
4444
| ExprKind::ValueTypeAscription { .. }
4545
| ExprKind::PlaceUnwrapUnsafeBinder { .. }
46-
| ExprKind::ValueUnwrapUnsafeBinder { .. }
47-
| ExprKind::Reborrow { .. } => Some(Category::Place),
46+
| ExprKind::ValueUnwrapUnsafeBinder { .. } => Some(Category::Place),
4847

4948
ExprKind::LogicalOp { .. }
5049
| ExprKind::Match { .. }
@@ -70,6 +69,10 @@ impl Category {
7069
| ExprKind::Repeat { .. }
7170
| ExprKind::Assign { .. }
7271
| ExprKind::AssignOp { .. }
72+
// A reborrow expression produces a value represented in MIR as
73+
// `Rvalue::Reborrow`. Its source may be a place, but the reborrow
74+
// expression itself does not denote an assignable place.
75+
| ExprKind::Reborrow { .. }
7376
| ExprKind::ThreadLocalRef(_)
7477
| ExprKind::WrapUnsafeBinder { .. } => Some(Category::Rvalue(RvalueFunc::AsRvalue)),
7578

compiler/rustc_privacy/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
783783
}
784784
}
785785

786-
DefKind::TraitAlias | DefKind::Fn => {
786+
DefKind::TraitAlias | DefKind::Fn | DefKind::TyAlias => {
787787
self.ev.queue.insert(def_id);
788788
}
789789

@@ -808,7 +808,6 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
808808

809809
// Can't be reached
810810
DefKind::Impl { .. }
811-
| DefKind::TyAlias
812811
| DefKind::Field
813812
| DefKind::Variant
814813
| DefKind::Static { .. }

0 commit comments

Comments
 (0)