-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #122653 - matthiaskrgr:rollup-28h37ym, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #120640 (Mark UEFI std support as WIP) - #121862 (Add release notes for 1.77.0) - #122572 (add test for #122301 to cover behavior that's on stable) - #122578 (Only invoke `decorate` if the diag can eventually be emitted) - #122615 (Mention Zalathar for coverage changes) - #122636 (some minor code simplifications) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
16 changed files
with
297 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//@ build-pass | ||
|
||
// issue 122301 - currently the only way to supress | ||
// const eval and codegen of code conditional on some other const | ||
|
||
struct Foo<T, const N: usize>(T); | ||
|
||
impl<T, const N: usize> Foo<T, N> { | ||
const BAR: () = if N == 0 { | ||
panic!() | ||
}; | ||
} | ||
|
||
struct Invoke<T, const N: usize>(T); | ||
|
||
impl<T, const N: usize> Invoke<T, N> { | ||
const FUN: fn() = if N != 0 { | ||
|| Foo::<T, N>::BAR | ||
} else { | ||
|| {} | ||
}; | ||
} | ||
|
||
// without closures | ||
|
||
struct S<T>(T); | ||
impl<T> S<T> { | ||
const C: () = panic!(); | ||
} | ||
|
||
const fn bar<T>() { S::<T>::C } | ||
|
||
struct ConstIf<T, const N: usize>(T); | ||
|
||
impl<T, const N: usize> ConstIf<T, N> { | ||
const VAL: () = if N != 0 { | ||
bar::<T>() // not called for N == 0, and hence not monomorphized | ||
} else { | ||
() | ||
}; | ||
} | ||
|
||
fn main() { | ||
let _val = Invoke::<(), 0>::FUN(); | ||
let _val = ConstIf::<(), 0>::VAL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Checks that the following does not ICE because `decorate` is incorrectly skipped. | ||
|
||
//@ compile-flags: -Dunused_must_use -Awarnings --crate-type=lib | ||
|
||
#[must_use] | ||
fn f() {} | ||
|
||
pub fn g() { | ||
f(); | ||
//~^ ERROR unused return value | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/lint/decorate-ice/decorate-can-emit-warnings.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: unused return value of `f` that must be used | ||
--> $DIR/decorate-can-emit-warnings.rs:9:5 | ||
| | ||
LL | f(); | ||
| ^^^ | ||
| | ||
= note: requested on the command line with `-D unused-must-use` | ||
help: use `let _ = ...` to ignore the resulting value | ||
| | ||
LL | let _ = f(); | ||
| +++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Checks that the following does not ICE. | ||
// | ||
// Previously, this test ICEs when the `unused_must_use` lint is suppressed via the combination of | ||
// `-A warnings` and `--cap-lints=warn`, because: | ||
// | ||
// - Its lint diagnostic struct `UnusedDef` implements `LintDiagnostic` manually and in the impl | ||
// `def_path_str` was called (which calls `trimmed_def_path`, which will produce a | ||
// `must_produce_diag` ICE if a trimmed def path is constructed but never emitted in a diagnostic | ||
// because it is expensive to compute). | ||
// - A `LintDiagnostic` has a `decorate_lint` method which decorates a `Diag` with lint-specific | ||
// information. This method is wrapped by a `decorate` closure in `TyCtxt` diagnostic emission | ||
// machinery, and the `decorate` closure called as late as possible. | ||
// - `decorate`'s invocation is delayed as late as possible until `lint_level` is called. | ||
// - If a lint's corresponding diagnostic is suppressed (to be effectively allow at the final | ||
// emission time) via `-A warnings` or `--cap-lints=allow` (or `-A warnings` + `--cap-lints=warn` | ||
// like in this test case), `decorate` is still called and a diagnostic is still constructed -- | ||
// but the diagnostic is never eventually emitted, triggering the aforementioned | ||
// `must_produce_diag` ICE due to use of `trimmed_def_path`. | ||
// | ||
// Issue: <https://github.com/rust-lang/rust/issues/121774>. | ||
|
||
//@ compile-flags: -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib | ||
//@ check-pass | ||
|
||
#[must_use] | ||
fn f() {} | ||
|
||
pub fn g() { | ||
f(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Checks that the following does not ICE because `decorate` is incorrectly skipped due to | ||
// `--force-warn`. | ||
|
||
//@ compile-flags: -Dunused_must_use -Awarnings --force-warn unused_must_use --crate-type=lib | ||
//@ check-pass | ||
|
||
#[must_use] | ||
fn f() {} | ||
|
||
pub fn g() { | ||
f(); | ||
//~^ WARN unused return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
warning: unused return value of `f` that must be used | ||
--> $DIR/decorate-force-warn.rs:11:5 | ||
| | ||
LL | f(); | ||
| ^^^ | ||
| | ||
= note: requested on the command line with `--force-warn unused-must-use` | ||
help: use `let _ = ...` to ignore the resulting value | ||
| | ||
LL | let _ = f(); | ||
| +++++++ | ||
|
||
warning: 1 warning emitted | ||
|
Oops, something went wrong.