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 5 pull requests #119421

Merged
merged 14 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0453.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Example of erroneous code:

#[allow(non_snake_case)]
fn main() {
let MyNumber = 2; // error: allow(non_snake_case) overruled by outer
// forbid(non_snake_case)
// error: allow(non_snake_case) incompatible with previous forbid
let MyNumber = 2;
}
```

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ impl<'a> EarlyContext<'a> {
pub(crate) fn new(
sess: &'a Session,
features: &'a Features,
warn_about_weird_lints: bool,
lint_added_lints: bool,
lint_store: &'a LintStore,
registered_tools: &'a RegisteredTools,
buffered: LintBuffer,
Expand All @@ -1078,7 +1078,7 @@ impl<'a> EarlyContext<'a> {
builder: LintLevelsBuilder::new(
sess,
features,
warn_about_weird_lints,
lint_added_lints,
lint_store,
registered_tools,
),
Expand Down
62 changes: 31 additions & 31 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
unstable_to_stable_ids: FxHashMap::default(),
empty: FxHashMap::default(),
},
warn_about_weird_lints: false,
lint_added_lints: false,
store,
registered_tools: tcx.registered_tools(()),
};
Expand Down Expand Up @@ -164,7 +164,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
empty: FxHashMap::default(),
attrs,
},
warn_about_weird_lints: false,
lint_added_lints: false,
store,
registered_tools: tcx.registered_tools(()),
};
Expand Down Expand Up @@ -451,7 +451,7 @@ pub struct LintLevelsBuilder<'s, P> {
sess: &'s Session,
features: &'s Features,
provider: P,
warn_about_weird_lints: bool,
lint_added_lints: bool,
store: &'s LintStore,
registered_tools: &'s RegisteredTools,
}
Expand All @@ -464,15 +464,15 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
pub(crate) fn new(
sess: &'s Session,
features: &'s Features,
warn_about_weird_lints: bool,
lint_added_lints: bool,
store: &'s LintStore,
registered_tools: &'s RegisteredTools,
) -> Self {
let mut builder = LintLevelsBuilder {
sess,
features,
provider: TopDown { sets: LintLevelSets::new(), cur: COMMAND_LINE },
warn_about_weird_lints,
lint_added_lints,
store,
registered_tools,
};
Expand Down Expand Up @@ -642,7 +642,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
//
// This means that this only errors if we're truly lowering the lint
// level from forbid.
if level != Level::Forbid {
if self.lint_added_lints && level != Level::Forbid {
if let Level::Forbid = old_level {
// Backwards compatibility check:
//
Expand Down Expand Up @@ -968,7 +968,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
continue;
}

_ if !self.warn_about_weird_lints => {}
_ if !self.lint_added_lints => {}

CheckLintNameResult::Renamed(ref replace) => {
let suggestion =
Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
}
}

if !is_crate_node {
if self.lint_added_lints && !is_crate_node {
for (id, &(level, ref src)) in self.current_specs().iter() {
if !id.lint.crate_level_only {
continue;
Expand All @@ -1054,33 +1054,33 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
/// Checks if the lint is gated on a feature that is not enabled.
///
/// Returns `true` if the lint's feature is enabled.
// FIXME only emit this once for each attribute, instead of repeating it 4 times for
// pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
#[track_caller]
fn check_gated_lint(&self, lint_id: LintId, span: Span, lint_from_cli: bool) -> bool {
if let Some(feature) = lint_id.lint.feature_gate {
if !self.features.active(feature) {
let lint = builtin::UNKNOWN_LINTS;
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
struct_lint_level(
self.sess,
lint,
level,
src,
Some(span.into()),
fluent::lint_unknown_gated_lint,
|lint| {
lint.set_arg("name", lint_id.lint.name_lower());
lint.note(fluent::lint_note);
rustc_session::parse::add_feature_diagnostics_for_issue(
lint,
&self.sess.parse_sess,
feature,
GateIssue::Language,
lint_from_cli,
);
},
);
if self.lint_added_lints {
let lint = builtin::UNKNOWN_LINTS;
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
struct_lint_level(
self.sess,
lint,
level,
src,
Some(span.into()),
fluent::lint_unknown_gated_lint,
|lint| {
lint.set_arg("name", lint_id.lint.name_lower());
lint.note(fluent::lint_note);
rustc_session::parse::add_feature_diagnostics_for_issue(
lint,
&self.sess.parse_sess,
feature,
GateIssue::Language,
lint_from_cli,
);
},
);
}
return false;
}
}
Expand Down
35 changes: 13 additions & 22 deletions compiler/rustc_mir_transform/src/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,20 +1417,18 @@ fn create_coroutine_resume_function<'tcx>(
cases.insert(0, (UNRESUMED, START_BLOCK));

// Panic when resumed on the returned or poisoned state
let coroutine_kind = body.coroutine_kind().unwrap();

if can_unwind {
cases.insert(
1,
(POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(coroutine_kind))),
(POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(transform.coroutine_kind))),
);
}

if can_return {
let block = match coroutine_kind {
let block = match transform.coroutine_kind {
CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
| CoroutineKind::Coroutine(_) => {
insert_panic_block(tcx, body, ResumedAfterReturn(coroutine_kind))
insert_panic_block(tcx, body, ResumedAfterReturn(transform.coroutine_kind))
}
CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)
| CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => {
Expand All @@ -1444,7 +1442,7 @@ fn create_coroutine_resume_function<'tcx>(

make_coroutine_state_argument_indirect(tcx, body);

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

let is_async_kind =
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Async, _));
let is_async_gen_kind =
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _));
let is_gen_kind =
matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _));
let new_ret_ty = match coroutine_kind {
CoroutineKind::Desugared(CoroutineDesugaring::Async, _) => {
// Compute Poll<return_ty>
Expand Down Expand Up @@ -1653,7 +1645,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
let old_ret_local = replace_local(RETURN_PLACE, new_ret_ty, body, tcx);

// Replace all occurrences of `ResumeTy` with `&mut Context<'_>` within async bodies.
if is_async_kind || is_async_gen_kind {
if matches!(
coroutine_kind,
CoroutineKind::Desugared(CoroutineDesugaring::Async | CoroutineDesugaring::AsyncGen, _)
) {
transform_async_context(tcx, body);
}

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

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

// Remove the context argument within generator bodies.
if is_gen_kind {
if matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) {
transform_gen_context(tcx, body);
}

Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl<T, A: Allocator> RawVec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Aborts
///
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<T, A: Allocator> RawVec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Aborts
///
Expand Down
12 changes: 6 additions & 6 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl<T> Vec<T> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down Expand Up @@ -633,7 +633,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down Expand Up @@ -896,7 +896,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down Expand Up @@ -926,7 +926,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down Expand Up @@ -1900,7 +1900,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down Expand Up @@ -2003,7 +2003,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// # Panics
///
/// Panics if the new capacity exceeds `isize::MAX` bytes.
/// Panics if the new capacity exceeds `isize::MAX` _bytes_.
///
/// # Examples
///
Expand Down
1 change: 0 additions & 1 deletion tests/ui/error-codes/E0453.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

#[allow(non_snake_case)]
//~^ ERROR allow(non_snake_case) incompatible
//~| ERROR allow(non_snake_case) incompatible
fn main() {
}
13 changes: 1 addition & 12 deletions tests/ui/error-codes/E0453.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ LL |
LL | #[allow(non_snake_case)]
| ^^^^^^^^^^^^^^ overruled by previous forbid

error[E0453]: allow(non_snake_case) incompatible with previous forbid
--> $DIR/E0453.rs:3:9
|
LL | #![forbid(non_snake_case)]
| -------------- `forbid` level set here
LL |
LL | #[allow(non_snake_case)]
| ^^^^^^^^^^^^^^ overruled by previous forbid
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0453`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

#![deny(multiple_supertrait_upcastable)]
//~^ WARNING unknown lint: `multiple_supertrait_upcastable`
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
#![warn(multiple_supertrait_upcastable)]
//~^ WARNING unknown lint: `multiple_supertrait_upcastable`
//~| WARNING unknown lint: `multiple_supertrait_upcastable`
//~| WARNING unknown lint: `multiple_supertrait_upcastable`

fn main() {}
Loading