Skip to content

Commit 03b5019

Browse files
committed
Auto merge of rust-lang#119421 - matthiaskrgr:rollup-dbera1b, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#119322 (Couple of random coroutine pass simplifications) - rust-lang#119374 (Italicise "bytes" in the docs of some `Vec` methods) - rust-lang#119388 (rustc_lint: Prevent triplication of various lints) - rust-lang#119406 (Add non-regression test for ATPIT ICE rust-lang#114325) - rust-lang#119410 (Rename test to be more descriptive) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3cdd004 + bfc1643 commit 03b5019

Some content is hidden

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

43 files changed

+142
-696
lines changed

compiler/rustc_error_codes/src/error_codes/E0453.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Example of erroneous code:
88
99
#[allow(non_snake_case)]
1010
fn main() {
11-
let MyNumber = 2; // error: allow(non_snake_case) overruled by outer
12-
// forbid(non_snake_case)
11+
// error: allow(non_snake_case) incompatible with previous forbid
12+
let MyNumber = 2;
1313
}
1414
```
1515

compiler/rustc_lint/src/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ impl<'a> EarlyContext<'a> {
10691069
pub(crate) fn new(
10701070
sess: &'a Session,
10711071
features: &'a Features,
1072-
warn_about_weird_lints: bool,
1072+
lint_added_lints: bool,
10731073
lint_store: &'a LintStore,
10741074
registered_tools: &'a RegisteredTools,
10751075
buffered: LintBuffer,
@@ -1078,7 +1078,7 @@ impl<'a> EarlyContext<'a> {
10781078
builder: LintLevelsBuilder::new(
10791079
sess,
10801080
features,
1081-
warn_about_weird_lints,
1081+
lint_added_lints,
10821082
lint_store,
10831083
registered_tools,
10841084
),

compiler/rustc_lint/src/levels.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
135135
unstable_to_stable_ids: FxHashMap::default(),
136136
empty: FxHashMap::default(),
137137
},
138-
warn_about_weird_lints: false,
138+
lint_added_lints: false,
139139
store,
140140
registered_tools: tcx.registered_tools(()),
141141
};
@@ -164,7 +164,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
164164
empty: FxHashMap::default(),
165165
attrs,
166166
},
167-
warn_about_weird_lints: false,
167+
lint_added_lints: false,
168168
store,
169169
registered_tools: tcx.registered_tools(()),
170170
};
@@ -451,7 +451,7 @@ pub struct LintLevelsBuilder<'s, P> {
451451
sess: &'s Session,
452452
features: &'s Features,
453453
provider: P,
454-
warn_about_weird_lints: bool,
454+
lint_added_lints: bool,
455455
store: &'s LintStore,
456456
registered_tools: &'s RegisteredTools,
457457
}
@@ -464,15 +464,15 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
464464
pub(crate) fn new(
465465
sess: &'s Session,
466466
features: &'s Features,
467-
warn_about_weird_lints: bool,
467+
lint_added_lints: bool,
468468
store: &'s LintStore,
469469
registered_tools: &'s RegisteredTools,
470470
) -> Self {
471471
let mut builder = LintLevelsBuilder {
472472
sess,
473473
features,
474474
provider: TopDown { sets: LintLevelSets::new(), cur: COMMAND_LINE },
475-
warn_about_weird_lints,
475+
lint_added_lints,
476476
store,
477477
registered_tools,
478478
};
@@ -642,7 +642,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
642642
//
643643
// This means that this only errors if we're truly lowering the lint
644644
// level from forbid.
645-
if level != Level::Forbid {
645+
if self.lint_added_lints && level != Level::Forbid {
646646
if let Level::Forbid = old_level {
647647
// Backwards compatibility check:
648648
//
@@ -968,7 +968,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
968968
continue;
969969
}
970970

971-
_ if !self.warn_about_weird_lints => {}
971+
_ if !self.lint_added_lints => {}
972972

973973
CheckLintNameResult::Renamed(ref replace) => {
974974
let suggestion =
@@ -1029,7 +1029,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10291029
}
10301030
}
10311031

1032-
if !is_crate_node {
1032+
if self.lint_added_lints && !is_crate_node {
10331033
for (id, &(level, ref src)) in self.current_specs().iter() {
10341034
if !id.lint.crate_level_only {
10351035
continue;
@@ -1054,33 +1054,33 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10541054
/// Checks if the lint is gated on a feature that is not enabled.
10551055
///
10561056
/// Returns `true` if the lint's feature is enabled.
1057-
// FIXME only emit this once for each attribute, instead of repeating it 4 times for
1058-
// pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
10591057
#[track_caller]
10601058
fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool {
10611059
if let Some(feature) = lint_id.lint.feature_gate {
10621060
if !self.features.active(feature) {
1063-
let lint = builtin::UNKNOWN_LINTS;
1064-
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
1065-
struct_lint_level(
1066-
self.sess,
1067-
lint,
1068-
level,
1069-
src,
1070-
Some(span.into()),
1071-
fluent::lint_unknown_gated_lint,
1072-
|lint| {
1073-
lint.set_arg("name", lint_id.lint.name_lower());
1074-
lint.note(fluent::lint_note);
1075-
rustc_session::parse::add_feature_diagnostics_for_issue(
1076-
lint,
1077-
&self.sess.parse_sess,
1078-
feature,
1079-
GateIssue::Language,
1080-
lint_from_cli,
1081-
);
1082-
},
1083-
);
1061+
if self.lint_added_lints {
1062+
let lint = builtin::UNKNOWN_LINTS;
1063+
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
1064+
struct_lint_level(
1065+
self.sess,
1066+
lint,
1067+
level,
1068+
src,
1069+
Some(span.into()),
1070+
fluent::lint_unknown_gated_lint,
1071+
|lint| {
1072+
lint.set_arg("name", lint_id.lint.name_lower());
1073+
lint.note(fluent::lint_note);
1074+
rustc_session::parse::add_feature_diagnostics_for_issue(
1075+
lint,
1076+
&self.sess.parse_sess,
1077+
feature,
1078+
GateIssue::Language,
1079+
lint_from_cli,
1080+
);
1081+
},
1082+
);
1083+
}
10841084
return false;
10851085
}
10861086
}

compiler/rustc_mir_transform/src/coroutine.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -1417,20 +1417,18 @@ fn create_coroutine_resume_function<'tcx>(
14171417
cases.insert(0, (UNRESUMED, START_BLOCK));
14181418

14191419
// Panic when resumed on the returned or poisoned state
1420-
let coroutine_kind = body.coroutine_kind().unwrap();
1421-
14221420
if can_unwind {
14231421
cases.insert(
14241422
1,
1425-
(POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(coroutine_kind))),
1423+
(POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(transform.coroutine_kind))),
14261424
);
14271425
}
14281426

14291427
if can_return {
1430-
let block = match coroutine_kind {
1428+
let block = match transform.coroutine_kind {
14311429
CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
14321430
| CoroutineKind::Coroutine(_) => {
1433-
insert_panic_block(tcx, body, ResumedAfterReturn(coroutine_kind))
1431+
insert_panic_block(tcx, body, ResumedAfterReturn(transform.coroutine_kind))
14341432
}
14351433
CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)
14361434
| CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => {
@@ -1444,7 +1442,7 @@ fn create_coroutine_resume_function<'tcx>(
14441442

14451443
make_coroutine_state_argument_indirect(tcx, body);
14461444

1447-
match coroutine_kind {
1445+
match transform.coroutine_kind {
14481446
// Iterator::next doesn't accept a pinned argument,
14491447
// unlike for all other coroutine kinds.
14501448
CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => {}
@@ -1614,12 +1612,6 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
16141612
}
16151613
};
16161614

1617-
let is_async_kind =
1618-
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Async, _));
1619-
let is_async_gen_kind =
1620-
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _));
1621-
let is_gen_kind =
1622-
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _));
16231615
let new_ret_ty = match coroutine_kind {
16241616
CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
16251617
// Compute Poll<return_ty>
@@ -1653,7 +1645,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
16531645
let old_ret_local = replace_local(RETURN_PLACE, new_ret_ty, body, tcx);
16541646

16551647
// Replace all occurrences of `ResumeTy` with `&mut Context<'_>` within async bodies.
1656-
if is_async_kind || is_async_gen_kind {
1648+
if matches!(
1649+
coroutine_kind,
1650+
CoroutineKind::Desugared(CoroutineDesugaring::Async | CoroutineDesugaring::AsyncGen, _)
1651+
) {
16571652
transform_async_context(tcx, body);
16581653
}
16591654

@@ -1662,11 +1657,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
16621657
// case there is no `Assign` to it that the transform can turn into a store to the coroutine
16631658
// state. After the yield the slot in the coroutine state would then be uninitialized.
16641659
let resume_local = Local::new(2);
1665-
let resume_ty = if is_async_kind {
1666-
Ty::new_task_context(tcx)
1667-
} else {
1668-
body.local_decls[resume_local].ty
1669-
};
1660+
let resume_ty = body.local_decls[resume_local].ty;
16701661
let old_resume_local = replace_local(resume_local, resume_ty, body, tcx);
16711662

16721663
// When first entering the coroutine, move the resume argument into its old local
@@ -1709,11 +1700,11 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
17091700
// Run the transformation which converts Places from Local to coroutine struct
17101701
// accesses for locals in `remap`.
17111702
// It also rewrites `return x` and `yield y` as writing a new coroutine state and returning
1712-
// either CoroutineState::Complete(x) and CoroutineState::Yielded(y),
1713-
// or Poll::Ready(x) and Poll::Pending respectively depending on `is_async_kind`.
1703+
// either `CoroutineState::Complete(x)` and `CoroutineState::Yielded(y)`,
1704+
// or `Poll::Ready(x)` and `Poll::Pending` respectively depending on the coroutine kind.
17141705
let mut transform = TransformVisitor {
17151706
tcx,
1716-
coroutine_kind: body.coroutine_kind().unwrap(),
1707+
coroutine_kind,
17171708
remap,
17181709
storage_liveness,
17191710
always_live_locals,
@@ -1730,7 +1721,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
17301721
body.spread_arg = None;
17311722

17321723
// Remove the context argument within generator bodies.
1733-
if is_gen_kind {
1724+
if matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) {
17341725
transform_gen_context(tcx, body);
17351726
}
17361727

library/alloc/src/raw_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<T, A: Allocator> RawVec<T, A> {
284284
///
285285
/// # Panics
286286
///
287-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
287+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
288288
///
289289
/// # Aborts
290290
///
@@ -342,7 +342,7 @@ impl<T, A: Allocator> RawVec<T, A> {
342342
///
343343
/// # Panics
344344
///
345-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
345+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
346346
///
347347
/// # Aborts
348348
///

library/alloc/src/vec/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl<T> Vec<T> {
445445
///
446446
/// # Panics
447447
///
448-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
448+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
449449
///
450450
/// # Examples
451451
///
@@ -633,7 +633,7 @@ impl<T, A: Allocator> Vec<T, A> {
633633
///
634634
/// # Panics
635635
///
636-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
636+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
637637
///
638638
/// # Examples
639639
///
@@ -896,7 +896,7 @@ impl<T, A: Allocator> Vec<T, A> {
896896
///
897897
/// # Panics
898898
///
899-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
899+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
900900
///
901901
/// # Examples
902902
///
@@ -926,7 +926,7 @@ impl<T, A: Allocator> Vec<T, A> {
926926
///
927927
/// # Panics
928928
///
929-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
929+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
930930
///
931931
/// # Examples
932932
///
@@ -1900,7 +1900,7 @@ impl<T, A: Allocator> Vec<T, A> {
19001900
///
19011901
/// # Panics
19021902
///
1903-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
1903+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
19041904
///
19051905
/// # Examples
19061906
///
@@ -2003,7 +2003,7 @@ impl<T, A: Allocator> Vec<T, A> {
20032003
///
20042004
/// # Panics
20052005
///
2006-
/// Panics if the new capacity exceeds `isize::MAX` bytes.
2006+
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
20072007
///
20082008
/// # Examples
20092009
///

tests/ui/error-codes/E0453.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
#[allow(non_snake_case)]
44
//~^ ERROR allow(non_snake_case) incompatible
5-
//~| ERROR allow(non_snake_case) incompatible
65
fn main() {
76
}

tests/ui/error-codes/E0453.stderr

+1-12
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ LL |
77
LL | #[allow(non_snake_case)]
88
| ^^^^^^^^^^^^^^ overruled by previous forbid
99

10-
error[E0453]: allow(non_snake_case) incompatible with previous forbid
11-
--> $DIR/E0453.rs:3:9
12-
|
13-
LL | #![forbid(non_snake_case)]
14-
| -------------- `forbid` level set here
15-
LL |
16-
LL | #[allow(non_snake_case)]
17-
| ^^^^^^^^^^^^^^ overruled by previous forbid
18-
|
19-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
20-
21-
error: aborting due to 2 previous errors
10+
error: aborting due to 1 previous error
2211

2312
For more information about this error, try `rustc --explain E0453`.

tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
#![deny(multiple_supertrait_upcastable)]
44
//~^ WARNING unknown lint: `multiple_supertrait_upcastable`
5-
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
6-
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
75
#![warn(multiple_supertrait_upcastable)]
86
//~^ WARNING unknown lint: `multiple_supertrait_upcastable`
9-
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
10-
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
117

128
fn main() {}

0 commit comments

Comments
 (0)