Auto merge of #138031 - workingjubilee:rollup-5bsotpz, r=workingjubilee
Rollup of 15 pull requests Successful merges: - #137829 (Stabilize [T]::split_off... methods) - #137850 (Stabilize `box_uninit_write`) - #137912 (Do not recover missing lifetime with random in-scope lifetime) - #137913 (Allow struct field default values to reference struct's generics) - #137923 (Simplify `<Postorder as Iterator>::size_hint`) - #137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK) - #137963 (Add ``dyn`` keyword to `E0373` examples) - #137975 (Remove unused `PpMode::needs_hir`) - #137981 (rustdoc search: increase strictness of typechecking) - #137986 (Fix some typos) - #137991 (Add `avr-none` to SUMMARY.md and platform-support.md) - #137993 (Remove obsolete comment from DeduceReadOnly) - #137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"") - #138019 (Pretty-print `#[deprecated]` attribute in HIR.) - #138026 (Make CrateItem::body() function return an option) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
4559163ccb
57 changed files with 427 additions and 401 deletions
|
@ -18,7 +18,7 @@ For submodules, changes need to be made against the repository corresponding the
|
||||||
submodule, and not the main `rust-lang/rust` repository.
|
submodule, and not the main `rust-lang/rust` repository.
|
||||||
|
|
||||||
For subtrees, prefer sending a PR against the subtree's repository if it does
|
For subtrees, prefer sending a PR against the subtree's repository if it does
|
||||||
not need to be made against the main `rust-lang/rust` repostory (e.g. a
|
not need to be made against the main `rust-lang/rust` repository (e.g. a
|
||||||
rustc-dev-guide change that does not accompany a compiler change).
|
rustc-dev-guide change that does not accompany a compiler change).
|
||||||
|
|
||||||
## About the [rustc-dev-guide]
|
## About the [rustc-dev-guide]
|
||||||
|
|
10
INSTALL.md
10
INSTALL.md
|
@ -210,9 +210,13 @@ itself back on after some time).
|
||||||
|
|
||||||
### MSVC
|
### MSVC
|
||||||
|
|
||||||
MSVC builds of Rust additionally require an installation of Visual Studio 2017
|
MSVC builds of Rust additionally requires an installation of:
|
||||||
(or later) so `rustc` can use its linker. The simplest way is to get
|
|
||||||
[Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload.
|
- Visual Studio 2022 (or later) build tools so `rustc` can use its linker. Older
|
||||||
|
Visual Studio versions such as 2019 *may* work but aren't actively tested.
|
||||||
|
- A recent Windows 10 or 11 SDK.
|
||||||
|
|
||||||
|
The simplest way is to get [Visual Studio], check the "C++ build tools".
|
||||||
|
|
||||||
[Visual Studio]: https://visualstudio.microsoft.com/downloads/
|
[Visual Studio]: https://visualstudio.microsoft.com/downloads/
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,12 @@ pub struct WorkerLocal<T> {
|
||||||
registry: Registry,
|
registry: Registry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is safe because the `deref` call will return a reference to a `T` unique to each thread
|
||||||
|
// or it will panic for threads without an associated local. So there isn't a need for `T` to do
|
||||||
|
// it's own synchronization. The `verify` method on `RegistryId` has an issue where the id
|
||||||
|
// can be reused, but `WorkerLocal` has a reference to `Registry` which will prevent any reuse.
|
||||||
|
unsafe impl<T: Send> Sync for WorkerLocal<T> {}
|
||||||
|
|
||||||
impl<T> WorkerLocal<T> {
|
impl<T> WorkerLocal<T> {
|
||||||
/// Creates a new worker local where the `initial` closure computes the
|
/// Creates a new worker local where the `initial` closure computes the
|
||||||
/// value this worker local should take for each thread in the registry.
|
/// value this worker local should take for each thread in the registry.
|
||||||
|
@ -132,11 +138,6 @@ impl<T> Deref for WorkerLocal<T> {
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
// This is safe because `verify` will only return values less than
|
// This is safe because `verify` will only return values less than
|
||||||
// `self.registry.thread_limit` which is the size of the `self.locals` array.
|
// `self.registry.thread_limit` which is the size of the `self.locals` array.
|
||||||
|
|
||||||
// The `deref` call will return a reference to a `T` unique to each thread
|
|
||||||
// or it will panic for threads without an associated local. So there isn't a need for `T` to do
|
|
||||||
// it's own synchronization. The `verify` method on `RegistryId` has an issue where the id
|
|
||||||
// can be reused, but `WorkerLocal` has a reference to `Registry` which will prevent any reuse.
|
|
||||||
unsafe { &self.locals.get_unchecked(self.registry.id().verify()).0 }
|
unsafe { &self.locals.get_unchecked(self.registry.id().verify()).0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ A captured variable in a closure may not live long enough.
|
||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
```compile_fail,E0373
|
```compile_fail,E0373
|
||||||
fn foo() -> Box<Fn(u32) -> u32> {
|
fn foo() -> Box<dyn Fn(u32) -> u32> {
|
||||||
let x = 0u32;
|
let x = 0u32;
|
||||||
Box::new(|y| x + y)
|
Box::new(|y| x + y)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ This approach moves (or copies, where possible) data into the closure, rather
|
||||||
than taking references to it. For example:
|
than taking references to it. For example:
|
||||||
|
|
||||||
```
|
```
|
||||||
fn foo() -> Box<Fn(u32) -> u32> {
|
fn foo() -> Box<dyn Fn(u32) -> u32> {
|
||||||
let x = 0u32;
|
let x = 0u32;
|
||||||
Box::new(move |y| x + y)
|
Box::new(move |y| x + y)
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,8 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
||||||
Some(parent_did)
|
Some(parent_did)
|
||||||
}
|
}
|
||||||
Node::TyPat(_) => Some(parent_did),
|
Node::TyPat(_) => Some(parent_did),
|
||||||
|
// Field default values inherit the ADT's generics.
|
||||||
|
Node::Field(_) => Some(parent_did),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,80 @@ impl<'a> State<'a> {
|
||||||
));
|
));
|
||||||
self.hardbreak()
|
self.hardbreak()
|
||||||
}
|
}
|
||||||
|
hir::Attribute::Parsed(AttributeKind::Deprecation { deprecation, .. }) => {
|
||||||
|
self.word("#[deprecated");
|
||||||
|
|
||||||
|
// There are three possible forms here:
|
||||||
|
// 1. a form with explicit components like
|
||||||
|
// `#[deprecated(since = "1.2.3", note = "some note", suggestion = "something")]`
|
||||||
|
// where each component may be present or absent.
|
||||||
|
// 2. `#[deprecated = "message"]`
|
||||||
|
// 3. `#[deprecated]`
|
||||||
|
//
|
||||||
|
// Let's figure out which we need.
|
||||||
|
// If there's a `since` or `suggestion` value, we're definitely in form 1.
|
||||||
|
if matches!(
|
||||||
|
deprecation.since,
|
||||||
|
rustc_attr_parsing::DeprecatedSince::RustcVersion(..)
|
||||||
|
| rustc_attr_parsing::DeprecatedSince::Future
|
||||||
|
| rustc_attr_parsing::DeprecatedSince::NonStandard(..)
|
||||||
|
) || deprecation.suggestion.is_some()
|
||||||
|
{
|
||||||
|
self.word("(");
|
||||||
|
let mut use_comma = false;
|
||||||
|
|
||||||
|
match &deprecation.since {
|
||||||
|
rustc_attr_parsing::DeprecatedSince::RustcVersion(rustc_version) => {
|
||||||
|
self.word("since = \"");
|
||||||
|
self.word(format!(
|
||||||
|
"{}.{}.{}",
|
||||||
|
rustc_version.major, rustc_version.minor, rustc_version.patch
|
||||||
|
));
|
||||||
|
self.word("\"");
|
||||||
|
use_comma = true;
|
||||||
|
}
|
||||||
|
rustc_attr_parsing::DeprecatedSince::Future => {
|
||||||
|
self.word("since = \"future\"");
|
||||||
|
use_comma = true;
|
||||||
|
}
|
||||||
|
rustc_attr_parsing::DeprecatedSince::NonStandard(symbol) => {
|
||||||
|
self.word("since = \"");
|
||||||
|
self.word(symbol.to_ident_string());
|
||||||
|
self.word("\"");
|
||||||
|
use_comma = true;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(note) = &deprecation.note {
|
||||||
|
if use_comma {
|
||||||
|
self.word(", ");
|
||||||
|
}
|
||||||
|
self.word("note = \"");
|
||||||
|
self.word(note.to_ident_string());
|
||||||
|
self.word("\"");
|
||||||
|
use_comma = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(suggestion) = &deprecation.suggestion {
|
||||||
|
if use_comma {
|
||||||
|
self.word(", ");
|
||||||
|
}
|
||||||
|
self.word("suggestion = \"");
|
||||||
|
self.word(suggestion.to_ident_string());
|
||||||
|
self.word("\"");
|
||||||
|
}
|
||||||
|
} else if let Some(note) = &deprecation.note {
|
||||||
|
// We're in form 2: `#[deprecated = "message"]`.
|
||||||
|
self.word(" = \"");
|
||||||
|
self.word(note.to_ident_string());
|
||||||
|
self.word("\"");
|
||||||
|
} else {
|
||||||
|
// We're in form 3: `#[deprecated]`. Nothing to do here.
|
||||||
|
}
|
||||||
|
|
||||||
|
self.word("]");
|
||||||
|
}
|
||||||
hir::Attribute::Parsed(pa) => {
|
hir::Attribute::Parsed(pa) => {
|
||||||
self.word("#[attr=\"");
|
self.word("#[attr=\"");
|
||||||
pa.print_attribute(self);
|
pa.print_attribute(self);
|
||||||
|
|
|
@ -23,19 +23,13 @@ pub struct Preorder<'a, 'tcx> {
|
||||||
body: &'a Body<'tcx>,
|
body: &'a Body<'tcx>,
|
||||||
visited: DenseBitSet<BasicBlock>,
|
visited: DenseBitSet<BasicBlock>,
|
||||||
worklist: Vec<BasicBlock>,
|
worklist: Vec<BasicBlock>,
|
||||||
root_is_start_block: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Preorder<'a, 'tcx> {
|
impl<'a, 'tcx> Preorder<'a, 'tcx> {
|
||||||
pub fn new(body: &'a Body<'tcx>, root: BasicBlock) -> Preorder<'a, 'tcx> {
|
pub fn new(body: &'a Body<'tcx>, root: BasicBlock) -> Preorder<'a, 'tcx> {
|
||||||
let worklist = vec![root];
|
let worklist = vec![root];
|
||||||
|
|
||||||
Preorder {
|
Preorder { body, visited: DenseBitSet::new_empty(body.basic_blocks.len()), worklist }
|
||||||
body,
|
|
||||||
visited: DenseBitSet::new_empty(body.basic_blocks.len()),
|
|
||||||
worklist,
|
|
||||||
root_is_start_block: root == START_BLOCK,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,15 +65,11 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
// All the blocks, minus the number of blocks we've visited.
|
// The worklist might be only things already visited.
|
||||||
let upper = self.body.basic_blocks.len() - self.visited.count();
|
let lower = 0;
|
||||||
|
|
||||||
let lower = if self.root_is_start_block {
|
// This is extremely loose, but it's not worth a popcnt loop to do better.
|
||||||
// We will visit all remaining blocks exactly once.
|
let upper = self.body.basic_blocks.len();
|
||||||
upper
|
|
||||||
} else {
|
|
||||||
self.worklist.len()
|
|
||||||
};
|
|
||||||
|
|
||||||
(lower, Some(upper))
|
(lower, Some(upper))
|
||||||
}
|
}
|
||||||
|
@ -108,7 +98,6 @@ pub struct Postorder<'a, 'tcx> {
|
||||||
basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
|
basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
|
||||||
visited: DenseBitSet<BasicBlock>,
|
visited: DenseBitSet<BasicBlock>,
|
||||||
visit_stack: Vec<(BasicBlock, Successors<'a>)>,
|
visit_stack: Vec<(BasicBlock, Successors<'a>)>,
|
||||||
root_is_start_block: bool,
|
|
||||||
/// A non-empty `extra` allows for a precise calculation of the successors.
|
/// A non-empty `extra` allows for a precise calculation of the successors.
|
||||||
extra: Option<(TyCtxt<'tcx>, Instance<'tcx>)>,
|
extra: Option<(TyCtxt<'tcx>, Instance<'tcx>)>,
|
||||||
}
|
}
|
||||||
|
@ -123,7 +112,6 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
||||||
basic_blocks,
|
basic_blocks,
|
||||||
visited: DenseBitSet::new_empty(basic_blocks.len()),
|
visited: DenseBitSet::new_empty(basic_blocks.len()),
|
||||||
visit_stack: Vec::new(),
|
visit_stack: Vec::new(),
|
||||||
root_is_start_block: root == START_BLOCK,
|
|
||||||
extra,
|
extra,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -211,16 +199,13 @@ impl<'tcx> Iterator for Postorder<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
// All the blocks, minus the number of blocks we've visited.
|
// These bounds are not at all tight, but that's fine.
|
||||||
let upper = self.basic_blocks.len() - self.visited.count();
|
// It's not worth a popcnt loop in `DenseBitSet` to improve the upper,
|
||||||
|
// and in mono-reachable we can't be precise anyway.
|
||||||
let lower = if self.root_is_start_block {
|
// Leaning on amortized growth is fine.
|
||||||
// We will visit all remaining blocks exactly once.
|
|
||||||
upper
|
|
||||||
} else {
|
|
||||||
self.visit_stack.len()
|
|
||||||
};
|
|
||||||
|
|
||||||
|
let lower = self.visit_stack.len();
|
||||||
|
let upper = self.basic_blocks.len();
|
||||||
(lower, Some(upper))
|
(lower, Some(upper))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,35 +80,6 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
|
||||||
// `f` passes. Note that function arguments are the only situation in which this problem can
|
// `f` passes. Note that function arguments are the only situation in which this problem can
|
||||||
// arise: every other use of `move` in MIR doesn't actually write to the value it moves
|
// arise: every other use of `move` in MIR doesn't actually write to the value it moves
|
||||||
// from.
|
// from.
|
||||||
//
|
|
||||||
// Anyway, right now this situation doesn't actually arise in practice. Instead, the MIR for
|
|
||||||
// that function looks like this:
|
|
||||||
//
|
|
||||||
// fn f(_1: BigStruct) -> () {
|
|
||||||
// let mut _0: ();
|
|
||||||
// let mut _2: BigStruct;
|
|
||||||
// bb0: {
|
|
||||||
// _2 = move _1;
|
|
||||||
// _0 = g(move _2) -> bb1;
|
|
||||||
// }
|
|
||||||
// ...
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Because of that extra move that MIR construction inserts, `x` (i.e. `_1`) can *in
|
|
||||||
// practice* safely be marked `readonly`.
|
|
||||||
//
|
|
||||||
// To handle the possibility that other optimizations (for example, destination propagation)
|
|
||||||
// might someday generate MIR like the first example above, we panic upon seeing an argument
|
|
||||||
// to *our* function that is directly moved into *another* function as an argument. Having
|
|
||||||
// eliminated that problematic case, we can safely treat moves as copies in this analysis.
|
|
||||||
//
|
|
||||||
// In the future, if MIR optimizations cause arguments of a caller to be directly moved into
|
|
||||||
// the argument of a callee, we can just add that argument to `mutated_args` instead of
|
|
||||||
// panicking.
|
|
||||||
//
|
|
||||||
// Note that, because the problematic MIR is never actually generated, we can't add a test
|
|
||||||
// case for this.
|
|
||||||
|
|
||||||
if let TerminatorKind::Call { ref args, .. } = terminator.kind {
|
if let TerminatorKind::Call { ref args, .. } = terminator.kind {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if let Operand::Move(place) = arg.node {
|
if let Operand::Move(place) = arg.node {
|
||||||
|
|
|
@ -78,6 +78,7 @@ struct IsNeverPattern;
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
enum AnonConstKind {
|
enum AnonConstKind {
|
||||||
EnumDiscriminant,
|
EnumDiscriminant,
|
||||||
|
FieldDefaultValue,
|
||||||
InlineConst,
|
InlineConst,
|
||||||
ConstArg(IsRepeatExpr),
|
ConstArg(IsRepeatExpr),
|
||||||
}
|
}
|
||||||
|
@ -1406,7 +1407,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
|
||||||
visit_opt!(self, visit_ident, ident);
|
visit_opt!(self, visit_ident, ident);
|
||||||
try_visit!(self.visit_ty(ty));
|
try_visit!(self.visit_ty(ty));
|
||||||
if let Some(v) = &default {
|
if let Some(v) = &default {
|
||||||
self.resolve_anon_const(v, AnonConstKind::ConstArg(IsRepeatExpr::No));
|
self.resolve_anon_const(v, AnonConstKind::FieldDefaultValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4659,6 +4660,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||||
AnonConstKind::EnumDiscriminant => {
|
AnonConstKind::EnumDiscriminant => {
|
||||||
ConstantHasGenerics::No(NoConstantGenericsReason::IsEnumDiscriminant)
|
ConstantHasGenerics::No(NoConstantGenericsReason::IsEnumDiscriminant)
|
||||||
}
|
}
|
||||||
|
AnonConstKind::FieldDefaultValue => ConstantHasGenerics::Yes,
|
||||||
AnonConstKind::InlineConst => ConstantHasGenerics::Yes,
|
AnonConstKind::InlineConst => ConstantHasGenerics::Yes,
|
||||||
AnonConstKind::ConstArg(_) => {
|
AnonConstKind::ConstArg(_) => {
|
||||||
if self.r.tcx.features().generic_const_exprs() || is_trivial_const_arg {
|
if self.r.tcx.features().generic_const_exprs() || is_trivial_const_arg {
|
||||||
|
|
|
@ -3515,12 +3515,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record as using the suggested resolution.
|
|
||||||
let (_, (_, res)) = in_scope_lifetimes[0];
|
|
||||||
for < in &lifetime_refs {
|
|
||||||
self.r.lifetimes_res_map.insert(lt.id, res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let lifetime_spans: Vec<_> =
|
let lifetime_spans: Vec<_> =
|
||||||
|
|
|
@ -2887,14 +2887,6 @@ impl PpMode {
|
||||||
| StableMir => true,
|
| StableMir => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn needs_hir(&self) -> bool {
|
|
||||||
use PpMode::*;
|
|
||||||
match *self {
|
|
||||||
Source(_) | AstTree | AstTreeExpanded => false,
|
|
||||||
|
|
||||||
Hir(_) | HirTree | ThirTree | ThirFlat | Mir | MirCFG | StableMir => true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn needs_analysis(&self) -> bool {
|
pub fn needs_analysis(&self) -> bool {
|
||||||
use PpMode::*;
|
use PpMode::*;
|
||||||
|
|
|
@ -129,13 +129,21 @@ crate_def_with_ty! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CrateItem {
|
impl CrateItem {
|
||||||
/// This will return the body of an item.
|
/// This will return the body of an item or panic if it's not available.
|
||||||
///
|
pub fn expect_body(&self) -> mir::Body {
|
||||||
/// This will panic if no body is available.
|
|
||||||
pub fn body(&self) -> mir::Body {
|
|
||||||
with(|cx| cx.mir_body(self.0))
|
with(|cx| cx.mir_body(self.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the body of an item if available.
|
||||||
|
pub fn body(&self) -> Option<mir::Body> {
|
||||||
|
with(|cx| cx.has_body(self.0).then(|| cx.mir_body(self.0)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a body is available for this item.
|
||||||
|
pub fn has_body(&self) -> bool {
|
||||||
|
with(|cx| cx.has_body(self.0))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn span(&self) -> Span {
|
pub fn span(&self) -> Span {
|
||||||
with(|cx| cx.span_of_an_item(self.0))
|
with(|cx| cx.span_of_an_item(self.0))
|
||||||
}
|
}
|
||||||
|
@ -156,8 +164,11 @@ impl CrateItem {
|
||||||
with(|cx| cx.is_foreign_item(self.0))
|
with(|cx| cx.is_foreign_item(self.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Emit MIR for this item body.
|
||||||
pub fn emit_mir<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
|
pub fn emit_mir<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
|
||||||
self.body().dump(w, &self.name())
|
self.body()
|
||||||
|
.ok_or_else(|| io::Error::other(format!("No body found for `{}`", self.name())))?
|
||||||
|
.dump(w, &self.name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -937,8 +937,6 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(box_uninit_write)]
|
|
||||||
///
|
|
||||||
/// let big_box = Box::<[usize; 1024]>::new_uninit();
|
/// let big_box = Box::<[usize; 1024]>::new_uninit();
|
||||||
///
|
///
|
||||||
/// let mut array = [0; 1024];
|
/// let mut array = [0; 1024];
|
||||||
|
@ -954,7 +952,7 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
|
||||||
/// assert_eq!(*x, i);
|
/// assert_eq!(*x, i);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "box_uninit_write", issue = "129397")]
|
#[stable(feature = "box_uninit_write", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
|
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(async_fn_traits)]
|
#![feature(async_fn_traits)]
|
||||||
#![feature(async_iterator)]
|
#![feature(async_iterator)]
|
||||||
#![feature(box_uninit_write)]
|
|
||||||
#![feature(bstr)]
|
#![feature(bstr)]
|
||||||
#![feature(bstr_internals)]
|
#![feature(bstr_internals)]
|
||||||
#![feature(char_max_len)]
|
#![feature(char_max_len)]
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub use raw::{from_raw_parts, from_raw_parts_mut};
|
||||||
|
|
||||||
/// Calculates the direction and split point of a one-sided range.
|
/// Calculates the direction and split point of a one-sided range.
|
||||||
///
|
///
|
||||||
/// This is a helper function for `take` and `take_mut` that returns
|
/// This is a helper function for `split_off` and `split_off_mut` that returns
|
||||||
/// the direction of the split (front or back) as well as the index at
|
/// the direction of the split (front or back) as well as the index at
|
||||||
/// which to split. Returns `None` if the split index would overflow.
|
/// which to split. Returns `None` if the split index would overflow.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -4313,8 +4313,6 @@ impl<T> [T] {
|
||||||
/// Splitting off the first three elements of a slice:
|
/// Splitting off the first three elements of a slice:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
||||||
/// let mut first_three = slice.split_off(..3).unwrap();
|
/// let mut first_three = slice.split_off(..3).unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4325,8 +4323,6 @@ impl<T> [T] {
|
||||||
/// Splitting off the last two elements of a slice:
|
/// Splitting off the last two elements of a slice:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
||||||
/// let mut tail = slice.split_off(2..).unwrap();
|
/// let mut tail = slice.split_off(2..).unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4337,8 +4333,6 @@ impl<T> [T] {
|
||||||
/// Getting `None` when `range` is out of bounds:
|
/// Getting `None` when `range` is out of bounds:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
|
||||||
///
|
///
|
||||||
/// assert_eq!(None, slice.split_off(5..));
|
/// assert_eq!(None, slice.split_off(5..));
|
||||||
|
@ -4349,7 +4343,7 @@ impl<T> [T] {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use = "method does not modify the slice if the range is out of bounds"]
|
#[must_use = "method does not modify the slice if the range is out of bounds"]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off<'a, R: OneSidedRange<usize>>(
|
pub fn split_off<'a, R: OneSidedRange<usize>>(
|
||||||
self: &mut &'a Self,
|
self: &mut &'a Self,
|
||||||
range: R,
|
range: R,
|
||||||
|
@ -4385,8 +4379,6 @@ impl<T> [T] {
|
||||||
/// Splitting off the first three elements of a slice:
|
/// Splitting off the first three elements of a slice:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
||||||
/// let mut first_three = slice.split_off_mut(..3).unwrap();
|
/// let mut first_three = slice.split_off_mut(..3).unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4397,8 +4389,6 @@ impl<T> [T] {
|
||||||
/// Taking the last two elements of a slice:
|
/// Taking the last two elements of a slice:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
||||||
/// let mut tail = slice.split_off_mut(2..).unwrap();
|
/// let mut tail = slice.split_off_mut(2..).unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4409,8 +4399,6 @@ impl<T> [T] {
|
||||||
/// Getting `None` when `range` is out of bounds:
|
/// Getting `None` when `range` is out of bounds:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
|
||||||
///
|
///
|
||||||
/// assert_eq!(None, slice.split_off_mut(5..));
|
/// assert_eq!(None, slice.split_off_mut(5..));
|
||||||
|
@ -4421,7 +4409,7 @@ impl<T> [T] {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use = "method does not modify the slice if the range is out of bounds"]
|
#[must_use = "method does not modify the slice if the range is out of bounds"]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off_mut<'a, R: OneSidedRange<usize>>(
|
pub fn split_off_mut<'a, R: OneSidedRange<usize>>(
|
||||||
self: &mut &'a mut Self,
|
self: &mut &'a mut Self,
|
||||||
range: R,
|
range: R,
|
||||||
|
@ -4451,8 +4439,6 @@ impl<T> [T] {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &[_] = &['a', 'b', 'c'];
|
/// let mut slice: &[_] = &['a', 'b', 'c'];
|
||||||
/// let first = slice.split_off_first().unwrap();
|
/// let first = slice.split_off_first().unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4460,7 +4446,7 @@ impl<T> [T] {
|
||||||
/// assert_eq!(first, &'a');
|
/// assert_eq!(first, &'a');
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off_first<'a>(self: &mut &'a Self) -> Option<&'a T> {
|
pub fn split_off_first<'a>(self: &mut &'a Self) -> Option<&'a T> {
|
||||||
let (first, rem) = self.split_first()?;
|
let (first, rem) = self.split_first()?;
|
||||||
*self = rem;
|
*self = rem;
|
||||||
|
@ -4475,8 +4461,6 @@ impl<T> [T] {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
|
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
|
||||||
/// let first = slice.split_off_first_mut().unwrap();
|
/// let first = slice.split_off_first_mut().unwrap();
|
||||||
/// *first = 'd';
|
/// *first = 'd';
|
||||||
|
@ -4485,7 +4469,7 @@ impl<T> [T] {
|
||||||
/// assert_eq!(first, &'d');
|
/// assert_eq!(first, &'d');
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off_first_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
|
pub fn split_off_first_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
|
||||||
let (first, rem) = mem::take(self).split_first_mut()?;
|
let (first, rem) = mem::take(self).split_first_mut()?;
|
||||||
*self = rem;
|
*self = rem;
|
||||||
|
@ -4500,8 +4484,6 @@ impl<T> [T] {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &[_] = &['a', 'b', 'c'];
|
/// let mut slice: &[_] = &['a', 'b', 'c'];
|
||||||
/// let last = slice.split_off_last().unwrap();
|
/// let last = slice.split_off_last().unwrap();
|
||||||
///
|
///
|
||||||
|
@ -4509,7 +4491,7 @@ impl<T> [T] {
|
||||||
/// assert_eq!(last, &'c');
|
/// assert_eq!(last, &'c');
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off_last<'a>(self: &mut &'a Self) -> Option<&'a T> {
|
pub fn split_off_last<'a>(self: &mut &'a Self) -> Option<&'a T> {
|
||||||
let (last, rem) = self.split_last()?;
|
let (last, rem) = self.split_last()?;
|
||||||
*self = rem;
|
*self = rem;
|
||||||
|
@ -4524,8 +4506,6 @@ impl<T> [T] {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(slice_take)]
|
|
||||||
///
|
|
||||||
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
|
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
|
||||||
/// let last = slice.split_off_last_mut().unwrap();
|
/// let last = slice.split_off_last_mut().unwrap();
|
||||||
/// *last = 'd';
|
/// *last = 'd';
|
||||||
|
@ -4534,7 +4514,7 @@ impl<T> [T] {
|
||||||
/// assert_eq!(last, &'d');
|
/// assert_eq!(last, &'d');
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "slice_take", issue = "62280")]
|
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_off_last_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
|
pub fn split_off_last_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
|
||||||
let (last, rem) = mem::take(self).split_last_mut()?;
|
let (last, rem) = mem::take(self).split_last_mut()?;
|
||||||
*self = rem;
|
*self = rem;
|
||||||
|
|
|
@ -73,7 +73,6 @@
|
||||||
#![feature(slice_internals)]
|
#![feature(slice_internals)]
|
||||||
#![feature(slice_partition_dedup)]
|
#![feature(slice_partition_dedup)]
|
||||||
#![feature(slice_split_once)]
|
#![feature(slice_split_once)]
|
||||||
#![feature(slice_take)]
|
|
||||||
#![feature(split_array)]
|
#![feature(split_array)]
|
||||||
#![feature(split_as_slice)]
|
#![feature(split_as_slice)]
|
||||||
#![feature(std_internals)]
|
#![feature(std_internals)]
|
||||||
|
|
|
@ -757,7 +757,7 @@ mod uefi_command_internal {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a map of environment variable changes. Allows efficient setting and rolling back of
|
/// Create a map of environment variable changes. Allows efficient setting and rolling back of
|
||||||
/// enviroment variable changes.
|
/// environment variable changes.
|
||||||
///
|
///
|
||||||
/// Entry: (Old Value, New Value)
|
/// Entry: (Old Value, New Value)
|
||||||
fn env_changes(env: &CommandEnv) -> Option<BTreeMap<EnvKey, (Option<OsString>, Option<OsString>)>> {
|
fn env_changes(env: &CommandEnv) -> Option<BTreeMap<EnvKey, (Option<OsString>, Option<OsString>)>> {
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
- [\*-linux-ohos](platform-support/openharmony.md)
|
- [\*-linux-ohos](platform-support/openharmony.md)
|
||||||
- [\*-hurd-gnu](platform-support/hurd.md)
|
- [\*-hurd-gnu](platform-support/hurd.md)
|
||||||
- [aarch64-unknown-teeos](platform-support/aarch64-unknown-teeos.md)
|
- [aarch64-unknown-teeos](platform-support/aarch64-unknown-teeos.md)
|
||||||
|
- [avr-none](platform-support/avr-none.md)
|
||||||
- [\*-espidf](platform-support/esp-idf.md)
|
- [\*-espidf](platform-support/esp-idf.md)
|
||||||
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
|
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
|
||||||
- [\*-unknown-trusty](platform-support/trusty.md)
|
- [\*-unknown-trusty](platform-support/trusty.md)
|
||||||
|
|
|
@ -301,7 +301,7 @@ target | std | host | notes
|
||||||
[`armv8r-none-eabihf`](platform-support/armv8r-none-eabihf.md) | * | | Bare Armv8-R, hardfloat
|
[`armv8r-none-eabihf`](platform-support/armv8r-none-eabihf.md) | * | | Bare Armv8-R, hardfloat
|
||||||
[`armv7a-nuttx-eabi`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX
|
[`armv7a-nuttx-eabi`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX
|
||||||
[`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX, hardfloat
|
[`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX, hardfloat
|
||||||
`avr-none` | * | | AVR; requires `-Zbuild-std=core` and `-Ctarget-cpu=...`
|
[`avr-none`](platform-support/avr-none.md) | * | | AVR; requires `-Zbuild-std=core` and `-Ctarget-cpu=...`
|
||||||
`bpfeb-unknown-none` | * | | BPF (big endian)
|
`bpfeb-unknown-none` | * | | BPF (big endian)
|
||||||
`bpfel-unknown-none` | * | | BPF (little endian)
|
`bpfel-unknown-none` | * | | BPF (little endian)
|
||||||
`csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux (little endian)
|
`csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux (little endian)
|
||||||
|
|
|
@ -65,7 +65,7 @@ section below.
|
||||||
|
|
||||||
A RISC-V toolchain can be obtained for Windows/Mac/Linux from the
|
A RISC-V toolchain can be obtained for Windows/Mac/Linux from the
|
||||||
[`riscv-gnu-toolchain`](https://github.com/riscv-collab/riscv-gnu-toolchain)
|
[`riscv-gnu-toolchain`](https://github.com/riscv-collab/riscv-gnu-toolchain)
|
||||||
repostory. Binaries are available via
|
repository. Binaries are available via
|
||||||
[embecosm](https://www.embecosm.com/resources/tool-chain-downloads/#riscv-linux),
|
[embecosm](https://www.embecosm.com/resources/tool-chain-downloads/#riscv-linux),
|
||||||
and may also be available from your OS's package manager.
|
and may also be available from your OS's package manager.
|
||||||
|
|
||||||
|
|
17
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
17
src/librustdoc/html/static/js/rustdoc.d.ts
vendored
|
@ -123,7 +123,7 @@ declare namespace rustdoc {
|
||||||
* Same as QueryElement, but bindings and typeFilter support strings
|
* Same as QueryElement, but bindings and typeFilter support strings
|
||||||
*/
|
*/
|
||||||
interface ParserQueryElement {
|
interface ParserQueryElement {
|
||||||
name: string,
|
name: string|null,
|
||||||
id: number|null,
|
id: number|null,
|
||||||
fullPath: Array<string>,
|
fullPath: Array<string>,
|
||||||
pathWithoutLast: Array<string>,
|
pathWithoutLast: Array<string>,
|
||||||
|
@ -131,10 +131,16 @@ declare namespace rustdoc {
|
||||||
normalizedPathLast: string,
|
normalizedPathLast: string,
|
||||||
generics: Array<ParserQueryElement>,
|
generics: Array<ParserQueryElement>,
|
||||||
bindings: Map<string, Array<ParserQueryElement>>,
|
bindings: Map<string, Array<ParserQueryElement>>,
|
||||||
bindingName: {name: string, generics: ParserQueryElement[]}|null,
|
bindingName: {name: string|null, generics: ParserQueryElement[]}|null,
|
||||||
typeFilter: string|null,
|
typeFilter: number|string|null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as ParserQueryElement, but all fields are optional.
|
||||||
|
*/
|
||||||
|
type ParserQueryElementFields = {
|
||||||
|
[K in keyof ParserQueryElement]?: ParserQueryElement[T]
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Intermediate parser state. Discarded when parsing is done.
|
* Intermediate parser state. Discarded when parsing is done.
|
||||||
*/
|
*/
|
||||||
|
@ -176,10 +182,11 @@ declare namespace rustdoc {
|
||||||
name: string,
|
name: string,
|
||||||
normalizedName: string,
|
normalizedName: string,
|
||||||
word: string,
|
word: string,
|
||||||
|
paramNames: string[],
|
||||||
parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined),
|
parent: ({ty: number, name: string, path: string, exactPath: string}|null|undefined),
|
||||||
path: string,
|
path: string,
|
||||||
ty: number,
|
ty: number,
|
||||||
type?: FunctionSearchType
|
type: FunctionSearchType | null,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -390,7 +397,7 @@ declare namespace rustdoc {
|
||||||
*/
|
*/
|
||||||
type RawSearchIndexCrate = {
|
type RawSearchIndexCrate = {
|
||||||
doc: string,
|
doc: string,
|
||||||
a: Object,
|
a: { [key: string]: number[] },
|
||||||
n: Array<string>,
|
n: Array<string>,
|
||||||
t: string,
|
t: string,
|
||||||
D: string,
|
D: string,
|
||||||
|
|
|
@ -638,7 +638,6 @@ function getNextElem(query, parserState, elems, isInGenerics) {
|
||||||
getFilteredNextElem(query, parserState, generics, isInGenerics);
|
getFilteredNextElem(query, parserState, generics, isInGenerics);
|
||||||
generics[generics.length - 1].bindingName = makePrimitiveElement("output");
|
generics[generics.length - 1].bindingName = makePrimitiveElement("output");
|
||||||
} else {
|
} else {
|
||||||
// @ts-expect-error
|
|
||||||
generics.push(makePrimitiveElement(null, {
|
generics.push(makePrimitiveElement(null, {
|
||||||
bindingName: makePrimitiveElement("output"),
|
bindingName: makePrimitiveElement("output"),
|
||||||
typeFilter: null,
|
typeFilter: null,
|
||||||
|
@ -791,7 +790,7 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) {
|
||||||
generics: generics.filter(gen => {
|
generics: generics.filter(gen => {
|
||||||
// Syntactically, bindings are parsed as generics,
|
// Syntactically, bindings are parsed as generics,
|
||||||
// but the query engine treats them differently.
|
// but the query engine treats them differently.
|
||||||
if (gen.bindingName !== null) {
|
if (gen.bindingName !== null && gen.bindingName.name !== null) {
|
||||||
if (gen.name !== null) {
|
if (gen.name !== null) {
|
||||||
gen.bindingName.generics.unshift(gen);
|
gen.bindingName.generics.unshift(gen);
|
||||||
}
|
}
|
||||||
|
@ -811,8 +810,8 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} name
|
* @param {string|null} name
|
||||||
* @param {Object=} extra
|
* @param {rustdoc.ParserQueryElementFields=} extra
|
||||||
* @returns {rustdoc.ParserQueryElement}
|
* @returns {rustdoc.ParserQueryElement}
|
||||||
*/
|
*/
|
||||||
function makePrimitiveElement(name, extra) {
|
function makePrimitiveElement(name, extra) {
|
||||||
|
@ -1478,73 +1477,61 @@ class DocSearch {
|
||||||
* Special type name IDs for searching by array.
|
* Special type name IDs for searching by array.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfArray = this.buildTypeMapIndex("array");
|
this.typeNameIdOfArray = this.buildTypeMapIndex("array");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by slice.
|
* Special type name IDs for searching by slice.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfSlice = this.buildTypeMapIndex("slice");
|
this.typeNameIdOfSlice = this.buildTypeMapIndex("slice");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by both array and slice (`[]` syntax).
|
* Special type name IDs for searching by both array and slice (`[]` syntax).
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfArrayOrSlice = this.buildTypeMapIndex("[]");
|
this.typeNameIdOfArrayOrSlice = this.buildTypeMapIndex("[]");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by tuple.
|
* Special type name IDs for searching by tuple.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfTuple = this.buildTypeMapIndex("tuple");
|
this.typeNameIdOfTuple = this.buildTypeMapIndex("tuple");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by unit.
|
* Special type name IDs for searching by unit.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfUnit = this.buildTypeMapIndex("unit");
|
this.typeNameIdOfUnit = this.buildTypeMapIndex("unit");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by both tuple and unit (`()` syntax).
|
* Special type name IDs for searching by both tuple and unit (`()` syntax).
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfTupleOrUnit = this.buildTypeMapIndex("()");
|
this.typeNameIdOfTupleOrUnit = this.buildTypeMapIndex("()");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching `fn`.
|
* Special type name IDs for searching `fn`.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfFn = this.buildTypeMapIndex("fn");
|
this.typeNameIdOfFn = this.buildTypeMapIndex("fn");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching `fnmut`.
|
* Special type name IDs for searching `fnmut`.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfFnMut = this.buildTypeMapIndex("fnmut");
|
this.typeNameIdOfFnMut = this.buildTypeMapIndex("fnmut");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching `fnonce`.
|
* Special type name IDs for searching `fnonce`.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfFnOnce = this.buildTypeMapIndex("fnonce");
|
this.typeNameIdOfFnOnce = this.buildTypeMapIndex("fnonce");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching higher order functions (`->` syntax).
|
* Special type name IDs for searching higher order functions (`->` syntax).
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfHof = this.buildTypeMapIndex("->");
|
this.typeNameIdOfHof = this.buildTypeMapIndex("->");
|
||||||
/**
|
/**
|
||||||
* Special type name IDs the output assoc type.
|
* Special type name IDs the output assoc type.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfOutput = this.buildTypeMapIndex("output", true);
|
this.typeNameIdOfOutput = this.buildTypeMapIndex("output", true);
|
||||||
/**
|
/**
|
||||||
* Special type name IDs for searching by reference.
|
* Special type name IDs for searching by reference.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.typeNameIdOfReference = this.buildTypeMapIndex("reference");
|
this.typeNameIdOfReference = this.buildTypeMapIndex("reference");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1586,7 +1573,6 @@ class DocSearch {
|
||||||
/**
|
/**
|
||||||
* @type {Array<rustdoc.Row>}
|
* @type {Array<rustdoc.Row>}
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
this.searchIndex = this.buildIndex(rawSearchIndex);
|
this.searchIndex = this.buildIndex(rawSearchIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1598,10 +1584,16 @@ class DocSearch {
|
||||||
* done more quickly. Two types with the same name but different item kinds
|
* done more quickly. Two types with the same name but different item kinds
|
||||||
* get the same ID.
|
* get the same ID.
|
||||||
*
|
*
|
||||||
* @param {string} name
|
* @template T extends string
|
||||||
|
* @overload
|
||||||
|
* @param {T} name
|
||||||
* @param {boolean=} isAssocType - True if this is an assoc type
|
* @param {boolean=} isAssocType - True if this is an assoc type
|
||||||
|
* @returns {T extends "" ? null : number}
|
||||||
|
*
|
||||||
|
* @param {string} name
|
||||||
|
* @param {boolean=} isAssocType
|
||||||
|
* @returns {number | null}
|
||||||
*
|
*
|
||||||
* @returns {number?}
|
|
||||||
*/
|
*/
|
||||||
buildTypeMapIndex(name, isAssocType) {
|
buildTypeMapIndex(name, isAssocType) {
|
||||||
if (name === "" || name === null) {
|
if (name === "" || name === null) {
|
||||||
|
@ -1909,6 +1901,7 @@ class DocSearch {
|
||||||
* Convert raw search index into in-memory search index.
|
* Convert raw search index into in-memory search index.
|
||||||
*
|
*
|
||||||
* @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex
|
* @param {Map<string, rustdoc.RawSearchIndexCrate>} rawSearchIndex
|
||||||
|
* @returns {rustdoc.Row[]}
|
||||||
*/
|
*/
|
||||||
buildIndex(rawSearchIndex) {
|
buildIndex(rawSearchIndex) {
|
||||||
/**
|
/**
|
||||||
|
@ -2008,6 +2001,7 @@ class DocSearch {
|
||||||
return cb;
|
return cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @type {rustdoc.Row[]} */
|
||||||
const searchIndex = [];
|
const searchIndex = [];
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
@ -2108,8 +2102,6 @@ class DocSearch {
|
||||||
// an array of [(Number) item type,
|
// an array of [(Number) item type,
|
||||||
// (String) name]
|
// (String) name]
|
||||||
const rawPaths = crateCorpus.p;
|
const rawPaths = crateCorpus.p;
|
||||||
// an array of [(String) alias name
|
|
||||||
// [Number] index to items]
|
|
||||||
const aliases = crateCorpus.a;
|
const aliases = crateCorpus.a;
|
||||||
// an array of [(Number) item index,
|
// an array of [(Number) item index,
|
||||||
// (String) comma-separated list of function generic param names]
|
// (String) comma-separated list of function generic param names]
|
||||||
|
@ -2232,6 +2224,7 @@ class DocSearch {
|
||||||
// object defined above.
|
// object defined above.
|
||||||
const itemParentIdx = itemParentIdxDecoder.next();
|
const itemParentIdx = itemParentIdxDecoder.next();
|
||||||
normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, "");
|
normalizedName = word.indexOf("_") === -1 ? word : word.replace(/_/g, "");
|
||||||
|
/** @type {rustdoc.Row} */
|
||||||
const row = {
|
const row = {
|
||||||
crate,
|
crate,
|
||||||
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"
|
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"
|
||||||
|
@ -2274,16 +2267,14 @@ class DocSearch {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error
|
/** @type{number[]} */
|
||||||
let currentNameAliases;
|
let currentNameAliases;
|
||||||
if (currentCrateAliases.has(alias_name)) {
|
if (currentCrateAliases.has(alias_name)) {
|
||||||
currentNameAliases = currentCrateAliases.get(alias_name);
|
currentNameAliases = currentCrateAliases.get(alias_name);
|
||||||
} else {
|
} else {
|
||||||
currentNameAliases = [];
|
currentNameAliases = [];
|
||||||
// @ts-expect-error
|
|
||||||
currentCrateAliases.set(alias_name, currentNameAliases);
|
currentCrateAliases.set(alias_name, currentNameAliases);
|
||||||
}
|
}
|
||||||
// @ts-expect-error
|
|
||||||
for (const local_alias of aliases[alias_name]) {
|
for (const local_alias of aliases[alias_name]) {
|
||||||
currentNameAliases.push(local_alias + currentIndex);
|
currentNameAliases.push(local_alias + currentIndex);
|
||||||
}
|
}
|
||||||
|
@ -2326,15 +2317,13 @@ class DocSearch {
|
||||||
* @param {rustdoc.ParserQueryElement} elem
|
* @param {rustdoc.ParserQueryElement} elem
|
||||||
*/
|
*/
|
||||||
function convertTypeFilterOnElem(elem) {
|
function convertTypeFilterOnElem(elem) {
|
||||||
if (elem.typeFilter !== null) {
|
if (typeof elem.typeFilter === "string") {
|
||||||
let typeFilter = elem.typeFilter;
|
let typeFilter = elem.typeFilter;
|
||||||
if (typeFilter === "const") {
|
if (typeFilter === "const") {
|
||||||
typeFilter = "constant";
|
typeFilter = "constant";
|
||||||
}
|
}
|
||||||
// @ts-expect-error
|
|
||||||
elem.typeFilter = itemTypeFromName(typeFilter);
|
elem.typeFilter = itemTypeFromName(typeFilter);
|
||||||
} else {
|
} else {
|
||||||
// @ts-expect-error
|
|
||||||
elem.typeFilter = NO_TYPE_FILTER;
|
elem.typeFilter = NO_TYPE_FILTER;
|
||||||
}
|
}
|
||||||
for (const elem2 of elem.generics) {
|
for (const elem2 of elem.generics) {
|
||||||
|
@ -2407,9 +2396,9 @@ class DocSearch {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!foundStopChar) {
|
if (!foundStopChar) {
|
||||||
let extra = "";
|
/** @type String[] */
|
||||||
|
let extra = [];
|
||||||
if (isLastElemGeneric(query.elems, parserState)) {
|
if (isLastElemGeneric(query.elems, parserState)) {
|
||||||
// @ts-expect-error
|
|
||||||
extra = [" after ", ">"];
|
extra = [" after ", ">"];
|
||||||
} else if (prevIs(parserState, "\"")) {
|
} else if (prevIs(parserState, "\"")) {
|
||||||
throw ["Cannot have more than one element if you use quotes"];
|
throw ["Cannot have more than one element if you use quotes"];
|
||||||
|
@ -2547,7 +2536,7 @@ class DocSearch {
|
||||||
* See `buildTypeMapIndex` for more information.
|
* See `buildTypeMapIndex` for more information.
|
||||||
*
|
*
|
||||||
* @param {rustdoc.QueryElement} elem
|
* @param {rustdoc.QueryElement} elem
|
||||||
* @param {boolean} isAssocType
|
* @param {boolean=} isAssocType
|
||||||
*/
|
*/
|
||||||
const convertNameToId = (elem, isAssocType) => {
|
const convertNameToId = (elem, isAssocType) => {
|
||||||
const loweredName = elem.pathLast.toLowerCase();
|
const loweredName = elem.pathLast.toLowerCase();
|
||||||
|
@ -2627,7 +2616,6 @@ class DocSearch {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
for (const elem2 of elem.generics) {
|
for (const elem2 of elem.generics) {
|
||||||
// @ts-expect-error
|
|
||||||
convertNameToId(elem2);
|
convertNameToId(elem2);
|
||||||
}
|
}
|
||||||
elem.bindings = new Map(Array.from(elem.bindings.entries())
|
elem.bindings = new Map(Array.from(elem.bindings.entries())
|
||||||
|
@ -2750,7 +2738,11 @@ class DocSearch {
|
||||||
return [displayPath, href, `${exactPath}::${name}`];
|
return [displayPath, href, `${exactPath}::${name}`];
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} path
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
function pathSplitter(path) {
|
function pathSplitter(path) {
|
||||||
const tmp = "<span>" + path.replace(/::/g, "::</span><span>");
|
const tmp = "<span>" + path.replace(/::/g, "::</span><span>");
|
||||||
if (tmp.endsWith("<span>")) {
|
if (tmp.endsWith("<span>")) {
|
||||||
|
@ -2763,9 +2755,9 @@ class DocSearch {
|
||||||
* Add extra data to result objects, and filter items that have been
|
* Add extra data to result objects, and filter items that have been
|
||||||
* marked for removal.
|
* marked for removal.
|
||||||
*
|
*
|
||||||
* @param {[rustdoc.ResultObject]} results
|
* @param {rustdoc.ResultObject[]} results
|
||||||
* @param {"sig"|"elems"|"returned"|null} typeInfo
|
* @param {"sig"|"elems"|"returned"|null} typeInfo
|
||||||
* @returns {[rustdoc.ResultObject]}
|
* @returns {rustdoc.ResultObject[]}
|
||||||
*/
|
*/
|
||||||
const transformResults = (results, typeInfo) => {
|
const transformResults = (results, typeInfo) => {
|
||||||
const duplicates = new Set();
|
const duplicates = new Set();
|
||||||
|
@ -2840,7 +2832,7 @@ class DocSearch {
|
||||||
}
|
}
|
||||||
let fnInputs = null;
|
let fnInputs = null;
|
||||||
let fnOutput = null;
|
let fnOutput = null;
|
||||||
// @ts-expect-error
|
/** @type {Map<number, number> | null} */
|
||||||
let mgens = null;
|
let mgens = null;
|
||||||
if (typeInfo !== "elems" && typeInfo !== "returned") {
|
if (typeInfo !== "elems" && typeInfo !== "returned") {
|
||||||
fnInputs = unifyFunctionTypes(
|
fnInputs = unifyFunctionTypes(
|
||||||
|
@ -3053,7 +3045,6 @@ class DocSearch {
|
||||||
writeFn(nested, result);
|
writeFn(nested, result);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
// @ts-expect-error
|
|
||||||
} else if (mgens) {
|
} else if (mgens) {
|
||||||
for (const [queryId, fnId] of mgens) {
|
for (const [queryId, fnId] of mgens) {
|
||||||
if (fnId === fnType.id) {
|
if (fnId === fnType.id) {
|
||||||
|
@ -3069,7 +3060,7 @@ class DocSearch {
|
||||||
name: fnParamNames[-1 - fnType.id],
|
name: fnParamNames[-1 - fnType.id],
|
||||||
highlighted: !!fnType.highlighted,
|
highlighted: !!fnType.highlighted,
|
||||||
}, result);
|
}, result);
|
||||||
// @ts-expect-error
|
/** @type{string[]} */
|
||||||
const where = [];
|
const where = [];
|
||||||
onEachBtwn(
|
onEachBtwn(
|
||||||
fnType.generics,
|
fnType.generics,
|
||||||
|
@ -3079,7 +3070,6 @@ class DocSearch {
|
||||||
() => pushText({ name: " + ", highlighted: false }, where),
|
() => pushText({ name: " + ", highlighted: false }, where),
|
||||||
);
|
);
|
||||||
if (where.length > 0) {
|
if (where.length > 0) {
|
||||||
// @ts-expect-error
|
|
||||||
whereClause.set(fnParamNames[-1 - fnType.id], where);
|
whereClause.set(fnParamNames[-1 - fnType.id], where);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3181,7 +3171,7 @@ class DocSearch {
|
||||||
* @param {rustdoc.Results} results
|
* @param {rustdoc.Results} results
|
||||||
* @param {"sig"|"elems"|"returned"|null} typeInfo
|
* @param {"sig"|"elems"|"returned"|null} typeInfo
|
||||||
* @param {string} preferredCrate
|
* @param {string} preferredCrate
|
||||||
* @returns {Promise<[rustdoc.ResultObject]>}
|
* @returns {Promise<rustdoc.ResultObject[]>}
|
||||||
*/
|
*/
|
||||||
const sortResults = async(results, typeInfo, preferredCrate) => {
|
const sortResults = async(results, typeInfo, preferredCrate) => {
|
||||||
const userQuery = parsedQuery.userQuery;
|
const userQuery = parsedQuery.userQuery;
|
||||||
|
@ -3337,7 +3327,6 @@ class DocSearch {
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
return transformResults(result_list, typeInfo);
|
return transformResults(result_list, typeInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,11 @@ extern crate rustc_interface;
|
||||||
extern crate stable_mir;
|
extern crate stable_mir;
|
||||||
|
|
||||||
use rustc_smir::rustc_internal;
|
use rustc_smir::rustc_internal;
|
||||||
use stable_mir::ty::{RigidTy, TyKind, Ty, };
|
use stable_mir::mir::{
|
||||||
use stable_mir::mir::{Body, MirVisitor, FieldIdx, Place, ProjectionElem, visit::{Location,
|
Body, FieldIdx, MirVisitor, Place, ProjectionElem,
|
||||||
PlaceContext}};
|
visit::{Location, PlaceContext},
|
||||||
|
};
|
||||||
|
use stable_mir::ty::{RigidTy, Ty, TyKind};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
|
@ -29,8 +31,8 @@ const CRATE_NAME: &str = "input";
|
||||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||||
fn test_stable_mir() -> ControlFlow<()> {
|
fn test_stable_mir() -> ControlFlow<()> {
|
||||||
let main_fn = stable_mir::entry_fn();
|
let main_fn = stable_mir::entry_fn();
|
||||||
let body = main_fn.unwrap().body();
|
let body = main_fn.unwrap().expect_body();
|
||||||
let mut visitor = PlaceVisitor{ body: &body, tested: false};
|
let mut visitor = PlaceVisitor { body: &body, tested: false };
|
||||||
visitor.visit_body(&body);
|
visitor.visit_body(&body);
|
||||||
assert!(visitor.tested);
|
assert!(visitor.tested);
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
assert!(stable_mir::find_crates("std").len() == 1);
|
assert!(stable_mir::find_crates("std").len() == 1);
|
||||||
|
|
||||||
let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap();
|
let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap();
|
||||||
let body = bar.body();
|
let body = bar.expect_body();
|
||||||
assert_eq!(body.locals().len(), 2);
|
assert_eq!(body.locals().len(), 2);
|
||||||
assert_eq!(body.blocks.len(), 1);
|
assert_eq!(body.blocks.len(), 1);
|
||||||
let block = &body.blocks[0];
|
let block = &body.blocks[0];
|
||||||
|
@ -60,7 +60,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap();
|
let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap();
|
||||||
let body = foo_bar.body();
|
let body = foo_bar.expect_body();
|
||||||
assert_eq!(body.locals().len(), 5);
|
assert_eq!(body.locals().len(), 5);
|
||||||
assert_eq!(body.blocks.len(), 4);
|
assert_eq!(body.blocks.len(), 4);
|
||||||
let block = &body.blocks[0];
|
let block = &body.blocks[0];
|
||||||
|
@ -70,7 +70,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let types = get_item(&items, (DefKind::Fn, "types")).unwrap();
|
let types = get_item(&items, (DefKind::Fn, "types")).unwrap();
|
||||||
let body = types.body();
|
let body = types.expect_body();
|
||||||
assert_eq!(body.locals().len(), 6);
|
assert_eq!(body.locals().len(), 6);
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
body.locals()[0].ty.kind(),
|
body.locals()[0].ty.kind(),
|
||||||
|
@ -100,7 +100,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let drop = get_item(&items, (DefKind::Fn, "drop")).unwrap();
|
let drop = get_item(&items, (DefKind::Fn, "drop")).unwrap();
|
||||||
let body = drop.body();
|
let body = drop.expect_body();
|
||||||
assert_eq!(body.blocks.len(), 2);
|
assert_eq!(body.blocks.len(), 2);
|
||||||
let block = &body.blocks[0];
|
let block = &body.blocks[0];
|
||||||
match &block.terminator.kind {
|
match &block.terminator.kind {
|
||||||
|
@ -109,7 +109,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let assert = get_item(&items, (DefKind::Fn, "assert")).unwrap();
|
let assert = get_item(&items, (DefKind::Fn, "assert")).unwrap();
|
||||||
let body = assert.body();
|
let body = assert.expect_body();
|
||||||
assert_eq!(body.blocks.len(), 2);
|
assert_eq!(body.blocks.len(), 2);
|
||||||
let block = &body.blocks[0];
|
let block = &body.blocks[0];
|
||||||
match &block.terminator.kind {
|
match &block.terminator.kind {
|
||||||
|
@ -123,7 +123,8 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
match &block.terminator.kind {
|
match &block.terminator.kind {
|
||||||
stable_mir::mir::TerminatorKind::Call { func, .. } => {
|
stable_mir::mir::TerminatorKind::Call { func, .. } => {
|
||||||
let TyKind::RigidTy(ty) = func.ty(&body.locals()).unwrap().kind() else {
|
let TyKind::RigidTy(ty) = func.ty(&body.locals()).unwrap().kind() else {
|
||||||
unreachable!() };
|
unreachable!()
|
||||||
|
};
|
||||||
let RigidTy::FnDef(def, args) = ty else { unreachable!() };
|
let RigidTy::FnDef(def, args) = ty else { unreachable!() };
|
||||||
let next_func = Instance::resolve(def, &args).unwrap();
|
let next_func = Instance::resolve(def, &args).unwrap();
|
||||||
match next_func.body().unwrap().locals()[1].ty.kind() {
|
match next_func.body().unwrap().locals()[1].ty.kind() {
|
||||||
|
@ -138,10 +139,10 @@ fn test_stable_mir() -> ControlFlow<()> {
|
||||||
|
|
||||||
let foo_const = get_item(&items, (DefKind::Const, "FOO")).unwrap();
|
let foo_const = get_item(&items, (DefKind::Const, "FOO")).unwrap();
|
||||||
// Ensure we don't panic trying to get the body of a constant.
|
// Ensure we don't panic trying to get the body of a constant.
|
||||||
foo_const.body();
|
foo_const.expect_body();
|
||||||
|
|
||||||
let locals_fn = get_item(&items, (DefKind::Fn, "locals")).unwrap();
|
let locals_fn = get_item(&items, (DefKind::Fn, "locals")).unwrap();
|
||||||
let body = locals_fn.body();
|
let body = locals_fn.expect_body();
|
||||||
assert_eq!(body.locals().len(), 4);
|
assert_eq!(body.locals().len(), 4);
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
body.ret_local().ty.kind(),
|
body.ret_local().ty.kind(),
|
||||||
|
@ -172,8 +173,10 @@ fn get_item<'a>(
|
||||||
item: (DefKind, &str),
|
item: (DefKind, &str),
|
||||||
) -> Option<&'a stable_mir::CrateItem> {
|
) -> Option<&'a stable_mir::CrateItem> {
|
||||||
items.iter().find(|crate_item| {
|
items.iter().find(|crate_item| {
|
||||||
matches!((item.0, crate_item.kind()), (DefKind::Fn, ItemKind::Fn) | (DefKind::Const,
|
matches!(
|
||||||
ItemKind::Const)) && crate_item.name() == item.1
|
(item.0, crate_item.kind()),
|
||||||
|
(DefKind::Fn, ItemKind::Fn) | (DefKind::Const, ItemKind::Const)
|
||||||
|
) && crate_item.name() == item.1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ extern crate rustc_interface;
|
||||||
extern crate stable_mir;
|
extern crate stable_mir;
|
||||||
|
|
||||||
use rustc_smir::rustc_internal;
|
use rustc_smir::rustc_internal;
|
||||||
|
use stable_mir::ItemKind;
|
||||||
use stable_mir::crate_def::CrateDef;
|
use stable_mir::crate_def::CrateDef;
|
||||||
use stable_mir::mir::{ProjectionElem, Rvalue, StatementKind};
|
use stable_mir::mir::{ProjectionElem, Rvalue, StatementKind};
|
||||||
use stable_mir::ty::{RigidTy, TyKind, UintTy};
|
use stable_mir::ty::{RigidTy, TyKind, UintTy};
|
||||||
use stable_mir::ItemKind;
|
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
@ -31,7 +31,7 @@ const CRATE_NAME: &str = "input";
|
||||||
/// Tests projections within Place objects
|
/// Tests projections within Place objects
|
||||||
fn test_place_projections() -> ControlFlow<()> {
|
fn test_place_projections() -> ControlFlow<()> {
|
||||||
let items = stable_mir::all_local_items();
|
let items = stable_mir::all_local_items();
|
||||||
let body = get_item(&items, (ItemKind::Fn, "projections")).unwrap().body();
|
let body = get_item(&items, (ItemKind::Fn, "projections")).unwrap().expect_body();
|
||||||
assert_eq!(body.blocks.len(), 4);
|
assert_eq!(body.blocks.len(), 4);
|
||||||
// The first statement assigns `&s.c` to a local. The projections include a deref for `s`, since
|
// The first statement assigns `&s.c` to a local. The projections include a deref for `s`, since
|
||||||
// `s` is passed as a reference argument, and a field access for field `c`.
|
// `s` is passed as a reference argument, and a field access for field `c`.
|
||||||
|
@ -53,7 +53,7 @@ fn test_place_projections() -> ControlFlow<()> {
|
||||||
);
|
);
|
||||||
let ty = place.ty(body.locals()).unwrap();
|
let ty = place.ty(body.locals()).unwrap();
|
||||||
assert_matches!(ty.kind().rigid(), Some(RigidTy::Ref(..)));
|
assert_matches!(ty.kind().rigid(), Some(RigidTy::Ref(..)));
|
||||||
},
|
}
|
||||||
other => panic!(
|
other => panic!(
|
||||||
"Unable to match against expected rvalue projection. Expected the projection \
|
"Unable to match against expected rvalue projection. Expected the projection \
|
||||||
for `s.c`, which is a Deref and u8 Field. Got: {:?}",
|
for `s.c`, which is a Deref and u8 Field. Got: {:?}",
|
||||||
|
@ -137,9 +137,7 @@ fn get_item<'a>(
|
||||||
items: &'a stable_mir::CrateItems,
|
items: &'a stable_mir::CrateItems,
|
||||||
item: (ItemKind, &str),
|
item: (ItemKind, &str),
|
||||||
) -> Option<&'a stable_mir::CrateItem> {
|
) -> Option<&'a stable_mir::CrateItem> {
|
||||||
items.iter().find(|crate_item| {
|
items.iter().find(|crate_item| crate_item.kind() == item.0 && crate_item.name() == item.1)
|
||||||
crate_item.kind() == item.0 && crate_item.name() == item.1
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This test will generate and analyze a dummy crate using the stable mir.
|
/// This test will generate and analyze a dummy crate using the stable mir.
|
||||||
|
|
|
@ -26,7 +26,7 @@ const CRATE_NAME: &str = "input";
|
||||||
|
|
||||||
fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||||
let main_fn = stable_mir::entry_fn().unwrap();
|
let main_fn = stable_mir::entry_fn().unwrap();
|
||||||
let body = main_fn.body();
|
let body = main_fn.expect_body();
|
||||||
let orig_ty = body.locals()[0].ty;
|
let orig_ty = body.locals()[0].ty;
|
||||||
let rustc_ty = rustc_internal::internal(tcx, &orig_ty);
|
let rustc_ty = rustc_internal::internal(tcx, &orig_ty);
|
||||||
assert!(rustc_ty.is_unit());
|
assert!(rustc_ty.is_unit());
|
||||||
|
|
|
@ -14,33 +14,29 @@ extern crate rustc_smir;
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
extern crate rustc_interface;
|
extern crate rustc_interface;
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate stable_mir;
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
extern crate stable_mir;
|
||||||
|
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_smir::rustc_internal;
|
use rustc_smir::rustc_internal;
|
||||||
use stable_mir::mir::Body;
|
|
||||||
use std::io::{Write, BufWriter};
|
|
||||||
use std::ops::ControlFlow;
|
|
||||||
use serde_json::to_string;
|
use serde_json::to_string;
|
||||||
|
use stable_mir::mir::Body;
|
||||||
|
use std::io::{BufWriter, Write};
|
||||||
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
const CRATE_NAME: &str = "input";
|
const CRATE_NAME: &str = "input";
|
||||||
|
|
||||||
fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||||
let path = "output.json";
|
let path = "output.json";
|
||||||
let mut writer = BufWriter::new(std::fs::File::create(path)
|
let mut writer = BufWriter::new(std::fs::File::create(path).expect("Failed to create path"));
|
||||||
.expect("Failed to create path"));
|
|
||||||
let local_crate = stable_mir::local_crate();
|
let local_crate = stable_mir::local_crate();
|
||||||
let items: Vec<Body> = stable_mir::all_local_items()
|
let items: Vec<Body> =
|
||||||
.iter()
|
stable_mir::all_local_items().iter().map(|item| item.expect_body()).collect();
|
||||||
.map(|item| { item.body() })
|
let crate_data = (local_crate.name, items);
|
||||||
.collect();
|
writer
|
||||||
let crate_data = ( local_crate.name, items );
|
.write_all(to_string(&crate_data).expect("serde_json failed").as_bytes())
|
||||||
writer.write_all(to_string(&crate_data)
|
.expect("JSON serialization failed");
|
||||||
.expect("serde_json failed")
|
|
||||||
.as_bytes()).expect("JSON serialization failed");
|
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ extern crate rustc_driver;
|
||||||
extern crate rustc_interface;
|
extern crate rustc_interface;
|
||||||
extern crate stable_mir;
|
extern crate stable_mir;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use rustc_smir::rustc_internal;
|
use rustc_smir::rustc_internal;
|
||||||
use stable_mir::*;
|
|
||||||
use stable_mir::mir::MirVisitor;
|
use stable_mir::mir::MirVisitor;
|
||||||
|
use stable_mir::*;
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ const CRATE_NAME: &str = "input";
|
||||||
|
|
||||||
fn test_visitor() -> ControlFlow<()> {
|
fn test_visitor() -> ControlFlow<()> {
|
||||||
let main_fn = stable_mir::entry_fn();
|
let main_fn = stable_mir::entry_fn();
|
||||||
let main_body = main_fn.unwrap().body();
|
let main_body = main_fn.unwrap().expect_body();
|
||||||
let main_visitor = TestVisitor::collect(&main_body);
|
let main_visitor = TestVisitor::collect(&main_body);
|
||||||
assert!(main_visitor.ret_val.is_some());
|
assert!(main_visitor.ret_val.is_some());
|
||||||
assert!(main_visitor.args.is_empty());
|
assert!(main_visitor.args.is_empty());
|
||||||
|
@ -51,7 +51,7 @@ struct TestVisitor<'a> {
|
||||||
pub tys: HashSet<ty::Ty>,
|
pub tys: HashSet<ty::Ty>,
|
||||||
pub ret_val: Option<mir::LocalDecl>,
|
pub ret_val: Option<mir::LocalDecl>,
|
||||||
pub args: Vec<mir::LocalDecl>,
|
pub args: Vec<mir::LocalDecl>,
|
||||||
pub calls: Vec<mir::mono::Instance>
|
pub calls: Vec<mir::mono::Instance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestVisitor<'a> {
|
impl<'a> TestVisitor<'a> {
|
||||||
|
@ -90,8 +90,8 @@ impl<'a> mir::MirVisitor for TestVisitor<'a> {
|
||||||
fn visit_terminator(&mut self, term: &mir::Terminator, location: mir::visit::Location) {
|
fn visit_terminator(&mut self, term: &mir::Terminator, location: mir::visit::Location) {
|
||||||
if let mir::TerminatorKind::Call { func, .. } = &term.kind {
|
if let mir::TerminatorKind::Call { func, .. } = &term.kind {
|
||||||
let ty::TyKind::RigidTy(ty) = func.ty(self.body.locals()).unwrap().kind() else {
|
let ty::TyKind::RigidTy(ty) = func.ty(self.body.locals()).unwrap().kind() else {
|
||||||
unreachable!
|
unreachable!()
|
||||||
() };
|
};
|
||||||
let ty::RigidTy::FnDef(def, args) = ty else { unreachable!() };
|
let ty::RigidTy::FnDef(def, args) = ty else { unreachable!() };
|
||||||
self.calls.push(mir::mono::Instance::resolve(def, &args).unwrap());
|
self.calls.push(mir::mono::Instance::resolve(def, &args).unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ impl Xyz {
|
||||||
) -> &dyn Foo //~ ERROR missing lifetime specifier
|
) -> &dyn Foo //~ ERROR missing lifetime specifier
|
||||||
{
|
{
|
||||||
foo
|
foo
|
||||||
//~^ ERROR explicit lifetime required in the type of `foo` [E0621]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,6 @@ help: consider using the `'a` lifetime
|
||||||
LL | ) -> &'a dyn Foo
|
LL | ) -> &'a dyn Foo
|
||||||
| ++
|
| ++
|
||||||
|
|
||||||
error[E0621]: explicit lifetime required in the type of `foo`
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/issue-63388-2.rs:14:9
|
|
||||||
|
|
|
||||||
LL | foo: &dyn Foo, bar: &'a dyn Foo
|
|
||||||
| -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)`
|
|
||||||
...
|
|
||||||
LL | foo
|
|
||||||
| ^^^ lifetime `'a` required
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0106`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0621.
|
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ trait Foo {
|
||||||
|
|
||||||
impl Foo for () {
|
impl Foo for () {
|
||||||
fn bar() -> i32 {
|
fn bar() -> i32 {
|
||||||
//~^ ERROR method `bar` has an incompatible type for trait
|
|
||||||
//~| ERROR method `bar` has an incompatible return type for trait
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ LL | fn bar() -> Wrapper<'static, impl Sized>;
|
||||||
| ++++++++
|
| ++++++++
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:18:24
|
--> $DIR/opaque-and-lifetime-mismatch.rs:16:24
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Wrapper<impl Sized>;
|
LL | fn foo() -> Wrapper<impl Sized>;
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -23,7 +23,7 @@ LL | fn foo() -> Wrapper<'static, impl Sized>;
|
||||||
| ++++++++
|
| ++++++++
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:24:24
|
--> $DIR/opaque-and-lifetime-mismatch.rs:22:24
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Wrapper<impl Sized> {
|
LL | fn foo() -> Wrapper<impl Sized> {
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -49,7 +49,7 @@ LL | struct Wrapper<'rom>(&'rom ());
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:18:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:16:17
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Wrapper<impl Sized>;
|
LL | fn foo() -> Wrapper<impl Sized>;
|
||||||
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
|
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
|
||||||
|
@ -62,36 +62,8 @@ note: struct defined here, with 0 generic parameters
|
||||||
LL | struct Wrapper<'rom>(&'rom ());
|
LL | struct Wrapper<'rom>(&'rom ());
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error[E0053]: method `bar` has an incompatible return type for trait
|
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
|
|
||||||
|
|
|
||||||
LL | fn bar() -> i32 {
|
|
||||||
| ^^^
|
|
||||||
| |
|
|
||||||
| expected `Wrapper<'static>`, found `i32`
|
|
||||||
| return type in trait
|
|
||||||
|
|
||||||
error[E0053]: method `bar` has an incompatible type for trait
|
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
|
|
||||||
|
|
|
||||||
LL | fn bar() -> i32 {
|
|
||||||
| ^^^ expected `Wrapper<'static>`, found `i32`
|
|
||||||
|
|
|
||||||
note: type in trait
|
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
|
|
||||||
|
|
|
||||||
LL | fn bar() -> Wrapper<impl Sized>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
= note: expected signature `fn() -> Wrapper<'static>`
|
|
||||||
found signature `fn() -> i32`
|
|
||||||
help: change the output type to match the trait
|
|
||||||
|
|
|
||||||
LL - fn bar() -> i32 {
|
|
||||||
LL + fn bar() -> Wrapper<'static> {
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:24:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:22:17
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Wrapper<impl Sized> {
|
LL | fn foo() -> Wrapper<impl Sized> {
|
||||||
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
|
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
|
||||||
|
@ -104,7 +76,7 @@ note: struct defined here, with 0 generic parameters
|
||||||
LL | struct Wrapper<'rom>(&'rom ());
|
LL | struct Wrapper<'rom>(&'rom ());
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0053, E0106, E0107.
|
Some errors have detailed explanations: E0106, E0107.
|
||||||
For more information about an error, try `rustc --explain E0053`.
|
For more information about an error, try `rustc --explain E0106`.
|
||||||
|
|
|
@ -75,7 +75,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
|
||||||
--> $DIR/opaque-used-in-extraneous-argument.rs:20:5
|
--> $DIR/opaque-used-in-extraneous-argument.rs:20:5
|
||||||
|
|
|
|
||||||
LL | open_parent(&old_path)
|
LL | open_parent(&old_path)
|
||||||
| ^^^^^^^^^^^ --------- unexpected argument of type `&impl Fn<{type error}> + FnOnce<{type error}, Output = {type error}> + 'static`
|
| ^^^^^^^^^^^ --------- unexpected argument of type `&impl Fn<{type error}> + FnOnce<{type error}, Output = {type error}> + '_`
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> $DIR/opaque-used-in-extraneous-argument.rs:12:4
|
--> $DIR/opaque-used-in-extraneous-argument.rs:12:4
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
fn no_elided_lt() -> impl Sized + use<'_> {}
|
fn no_elided_lt() -> impl Sized + use<'_> {}
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
//~| ERROR expected lifetime parameter in `use<...>` precise captures list, found `'_`
|
|
||||||
|
|
||||||
fn static_lt() -> impl Sized + use<'static> {}
|
fn static_lt() -> impl Sized + use<'static> {}
|
||||||
//~^ ERROR expected lifetime parameter in `use<...>` precise captures list, found `'static`
|
//~^ ERROR expected lifetime parameter in `use<...>` precise captures list, found `'static`
|
||||||
|
|
|
@ -12,26 +12,20 @@ LL + fn no_elided_lt() -> impl Sized + use<'static> {}
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0261]: use of undeclared lifetime name `'missing`
|
error[E0261]: use of undeclared lifetime name `'missing`
|
||||||
--> $DIR/bad-lifetimes.rs:8:37
|
--> $DIR/bad-lifetimes.rs:7:37
|
||||||
|
|
|
|
||||||
LL | fn missing_lt() -> impl Sized + use<'missing> {}
|
LL | fn missing_lt() -> impl Sized + use<'missing> {}
|
||||||
| - ^^^^^^^^ undeclared lifetime
|
| - ^^^^^^^^ undeclared lifetime
|
||||||
| |
|
| |
|
||||||
| help: consider introducing lifetime `'missing` here: `<'missing>`
|
| help: consider introducing lifetime `'missing` here: `<'missing>`
|
||||||
|
|
||||||
error: expected lifetime parameter in `use<...>` precise captures list, found `'_`
|
|
||||||
--> $DIR/bad-lifetimes.rs:1:39
|
|
||||||
|
|
|
||||||
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
|
|
||||||
| ^^
|
|
||||||
|
|
||||||
error: expected lifetime parameter in `use<...>` precise captures list, found `'static`
|
error: expected lifetime parameter in `use<...>` precise captures list, found `'static`
|
||||||
--> $DIR/bad-lifetimes.rs:5:36
|
--> $DIR/bad-lifetimes.rs:4:36
|
||||||
|
|
|
|
||||||
LL | fn static_lt() -> impl Sized + use<'static> {}
|
LL | fn static_lt() -> impl Sized + use<'static> {}
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0261.
|
Some errors have detailed explanations: E0106, E0261.
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
For more information about an error, try `rustc --explain E0106`.
|
||||||
|
|
|
@ -3,7 +3,6 @@ fn read_lines_borrowed1() -> Vec<
|
||||||
> {
|
> {
|
||||||
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
|
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
|
||||||
rawLines.iter().map(|l| l.trim()).collect()
|
rawLines.iter().map(|l| l.trim()).collect()
|
||||||
//~^ ERROR: cannot return value referencing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -15,16 +15,6 @@ LL - &str
|
||||||
LL + String
|
LL + String
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0515]: cannot return value referencing local variable `rawLines`
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/issue-13497.rs:5:5
|
|
||||||
|
|
|
||||||
LL | rawLines.iter().map(|l| l.trim()).collect()
|
|
||||||
| --------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
| |
|
|
||||||
| returns a value referencing data owned by the current function
|
|
||||||
| `rawLines` is borrowed here
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0106`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0515.
|
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next()
|
||||||
|
|
||||||
fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
||||||
//~^ ERROR missing lifetime specifier [E0106]
|
//~^ ERROR missing lifetime specifier [E0106]
|
||||||
//~| ERROR mismatched types
|
|
||||||
//~| ERROR function takes 1 argument but 0 arguments were supplied
|
//~| ERROR function takes 1 argument but 0 arguments were supplied
|
||||||
|
|
||||||
fn parse_type_3() -> &str { unimplemented!() }
|
fn parse_type_3() -> &str { unimplemented!() }
|
||||||
|
|
|
@ -32,7 +32,7 @@ LL + fn parse_type_2(iter: fn(&u8)->&u8) -> String { iter() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/issue-26638.rs:9:22
|
--> $DIR/issue-26638.rs:8:22
|
||||||
|
|
|
|
||||||
LL | fn parse_type_3() -> &str { unimplemented!() }
|
LL | fn parse_type_3() -> &str { unimplemented!() }
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -59,18 +59,7 @@ help: provide the argument
|
||||||
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) }
|
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) }
|
||||||
| +++++++++
|
| +++++++++
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 4 previous errors
|
||||||
--> $DIR/issue-26638.rs:4:47
|
|
||||||
|
|
|
||||||
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
|
|
||||||
| ---- ^^^^^^ expected `&str`, found `&u8`
|
|
||||||
| |
|
|
||||||
| expected `&'static str` because of return type
|
|
||||||
|
|
|
||||||
= note: expected reference `&'static str`
|
|
||||||
found reference `&u8`
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
Some errors have detailed explanations: E0061, E0106.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0061, E0106, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0061`.
|
For more information about an error, try `rustc --explain E0061`.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#![feature(default_field_values)]
|
#![feature(default_field_values)]
|
||||||
struct A<'a> { //~ ERROR lifetime parameter `'a` is never used
|
struct A<'a> {
|
||||||
x: Vec<A> = Vec::new(), //~ ERROR missing lifetime specifier
|
x: Vec<A> = Vec::new(), //~ ERROR missing lifetime specifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,6 @@ help: consider using the `'a` lifetime
|
||||||
LL | x: Vec<A<'a>> = Vec::new(),
|
LL | x: Vec<A<'a>> = Vec::new(),
|
||||||
| ++++
|
| ++++
|
||||||
|
|
||||||
error[E0392]: lifetime parameter `'a` is never used
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/do-not-ice-on-invalid-lifetime.rs:2:10
|
|
||||||
|
|
|
||||||
LL | struct A<'a> {
|
|
||||||
| ^^ unused lifetime parameter
|
|
||||||
|
|
|
||||||
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0106`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0392.
|
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ pub struct Bar {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Qux<const C: i32> {
|
pub struct Qux<const C: i32> {
|
||||||
bar: S = Self::S, //~ ERROR generic `Self` types are currently not permitted in anonymous constants
|
bar: S = Self::S,
|
||||||
baz: i32 = foo(),
|
baz: i32 = foo(),
|
||||||
bat: i32 = <Qux<{ C }> as T>::K, //~ ERROR generic parameters may not be used in const operations
|
bat: i32 = <Qux<{ C }> as T>::K,
|
||||||
bay: i32 = C,
|
bay: i32 = C,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,27 +6,12 @@ LL | Variant {}
|
||||||
|
|
|
|
||||||
= help: consider a manual implementation of `Default`
|
= help: consider a manual implementation of `Default`
|
||||||
|
|
||||||
error: generic parameters may not be used in const operations
|
|
||||||
--> $DIR/failures.rs:22:23
|
|
||||||
|
|
|
||||||
LL | bat: i32 = <Qux<{ C }> as T>::K,
|
|
||||||
| ^ cannot perform const operation using `C`
|
|
||||||
|
|
|
||||||
= help: const parameters may only be used as standalone arguments, i.e. `C`
|
|
||||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
|
||||||
|
|
||||||
error: default fields are not supported in tuple structs
|
error: default fields are not supported in tuple structs
|
||||||
--> $DIR/failures.rs:26:22
|
--> $DIR/failures.rs:26:22
|
||||||
|
|
|
|
||||||
LL | pub struct Rak(i32 = 42);
|
LL | pub struct Rak(i32 = 42);
|
||||||
| ^^ default fields are only supported on structs
|
| ^^ default fields are only supported on structs
|
||||||
|
|
||||||
error: generic `Self` types are currently not permitted in anonymous constants
|
|
||||||
--> $DIR/failures.rs:20:14
|
|
||||||
|
|
|
||||||
LL | bar: S = Self::S,
|
|
||||||
| ^^^^
|
|
||||||
|
|
||||||
error[E0277]: the trait bound `S: Default` is not satisfied
|
error[E0277]: the trait bound `S: Default` is not satisfied
|
||||||
--> $DIR/failures.rs:14:5
|
--> $DIR/failures.rs:14:5
|
||||||
|
|
|
|
||||||
|
@ -112,7 +97,7 @@ LL - let _ = Rak(.., 0);
|
||||||
LL + let _ = Rak(0);
|
LL + let _ = Rak(0);
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0061, E0277, E0308.
|
Some errors have detailed explanations: E0061, E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0061`.
|
For more information about an error, try `rustc --explain E0061`.
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
//@ build-pass
|
||||||
|
|
||||||
|
#![feature(default_field_values)]
|
||||||
|
|
||||||
|
struct W<const X: usize>;
|
||||||
|
|
||||||
|
impl<const X: usize> W<X> {
|
||||||
|
const fn new() -> Self { W }
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Z<const X: usize> {
|
||||||
|
// No inference.
|
||||||
|
one: W<X> = W::<X>::new(),
|
||||||
|
|
||||||
|
// Inference works too.
|
||||||
|
two: W<X> = W::new(),
|
||||||
|
|
||||||
|
// An anon const that is too generic before substitution.
|
||||||
|
too_generic: usize = X + 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn use_generically<const X: usize>() {
|
||||||
|
let x: Z<X> = Z { .. };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: Z<0> = Z { .. };
|
||||||
|
use_generically::<0>();
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed
|
||||||
|
--> $DIR/post-mono.rs:7:24
|
||||||
|
|
|
||||||
|
LL | post_mono: usize = X / 0,
|
||||||
|
| ^^^^^ attempt to divide `1_usize` by zero
|
||||||
|
|
||||||
|
note: erroneous constant encountered
|
||||||
|
--> $DIR/post-mono.rs:17:19
|
||||||
|
|
|
||||||
|
LL | let x: Z<1> = Z { .. };
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant encountered
|
||||||
|
--> $DIR/post-mono.rs:17:19
|
||||||
|
|
|
||||||
|
LL | let x: Z<1> = Z { .. };
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0080`.
|
|
@ -0,0 +1,29 @@
|
||||||
|
error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed
|
||||||
|
--> $DIR/post-mono.rs:7:24
|
||||||
|
|
|
||||||
|
LL | post_mono: usize = X / 0,
|
||||||
|
| ^^^^^ attempt to divide `1_usize` by zero
|
||||||
|
|
||||||
|
note: erroneous constant encountered
|
||||||
|
--> $DIR/post-mono.rs:12:19
|
||||||
|
|
|
||||||
|
LL | let x: Z<X> = Z { .. };
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant encountered
|
||||||
|
--> $DIR/post-mono.rs:12:19
|
||||||
|
|
|
||||||
|
LL | let x: Z<X> = Z { .. };
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
note: the above error was encountered while instantiating `fn indirect::<1>`
|
||||||
|
--> $DIR/post-mono.rs:22:5
|
||||||
|
|
|
||||||
|
LL | indirect::<1>();
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0080`.
|
23
tests/ui/structs/default-field-values/post-mono.rs
Normal file
23
tests/ui/structs/default-field-values/post-mono.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
//@ build-fail
|
||||||
|
//@ revisions: direct indirect
|
||||||
|
|
||||||
|
#![feature(default_field_values)]
|
||||||
|
|
||||||
|
struct Z<const X: usize> {
|
||||||
|
post_mono: usize = X / 0,
|
||||||
|
//~^ ERROR evaluation of `Z::<1>::post_mono::{constant#0}` failed
|
||||||
|
}
|
||||||
|
|
||||||
|
fn indirect<const X: usize>() {
|
||||||
|
let x: Z<X> = Z { .. };
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(direct)]
|
||||||
|
fn main() {
|
||||||
|
let x: Z<1> = Z { .. };
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(indirect)]
|
||||||
|
fn main() {
|
||||||
|
indirect::<1>();
|
||||||
|
}
|
|
@ -18,7 +18,6 @@ mod elided {
|
||||||
// But that lifetime does not participate in resolution.
|
// But that lifetime does not participate in resolution.
|
||||||
async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
|
async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
//~| ERROR lifetime may not live long enough
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod underscore {
|
mod underscore {
|
||||||
|
@ -37,7 +36,6 @@ mod underscore {
|
||||||
// But that lifetime does not participate in resolution.
|
// But that lifetime does not participate in resolution.
|
||||||
async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
//~| ERROR lifetime may not live long enough
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mod alone_in_path {
|
mod alone_in_path {
|
||||||
|
|
|
@ -41,7 +41,7 @@ LL + async fn i(mut x: impl Iterator<Item = &()>) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:28:58
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:27:58
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
| ^^ expected named lifetime parameter
|
| ^^ expected named lifetime parameter
|
||||||
|
@ -64,7 +64,7 @@ LL + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:38:64
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:37:64
|
||||||
|
|
|
|
||||||
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
| ^^ expected named lifetime parameter
|
| ^^ expected named lifetime parameter
|
||||||
|
@ -87,7 +87,7 @@ LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next(
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:49:37
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:47:37
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
|
LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -108,7 +108,7 @@ LL + fn g(mut x: impl Foo) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:60:41
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:58:41
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
|
LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -129,7 +129,7 @@ LL + fn g(mut x: impl Foo<()>) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
warning: elided lifetime has a name
|
warning: elided lifetime has a name
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:66:57
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:64:57
|
||||||
|
|
|
|
||||||
LL | fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &T) {
|
LL | fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &T) {
|
||||||
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
||||||
|
@ -162,16 +162,8 @@ help: consider introducing a named lifetime parameter
|
||||||
LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&()> { x.next() }
|
LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&()> { x.next() }
|
||||||
| ++++ ++
|
| ++++ ++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:19:67
|
|
||||||
|
|
|
||||||
LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() }
|
|
||||||
| ----------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
|
||||||
| |
|
|
||||||
| return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1`
|
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:25:35
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:24:35
|
||||||
|
|
|
|
||||||
LL | fn f(_: impl Iterator<Item = &'_ ()>) {}
|
LL | fn f(_: impl Iterator<Item = &'_ ()>) {}
|
||||||
| ^^ expected named lifetime parameter
|
| ^^ expected named lifetime parameter
|
||||||
|
@ -185,7 +177,7 @@ LL + fn f<'a>(_: impl Iterator<Item = &'a ()>) {}
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:28:39
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:27:39
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
| ^^ expected named lifetime parameter
|
| ^^ expected named lifetime parameter
|
||||||
|
@ -198,16 +190,8 @@ LL - fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next()
|
||||||
LL + fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'_ ()> { x.next() }
|
LL + fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'_ ()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:38:73
|
|
||||||
|
|
|
||||||
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
|
||||||
| ----------------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
|
||||||
| |
|
|
||||||
| return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1`
|
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:46:18
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:44:18
|
||||||
|
|
|
|
||||||
LL | fn f(_: impl Foo) {}
|
LL | fn f(_: impl Foo) {}
|
||||||
| ^^^ expected named lifetime parameter
|
| ^^^ expected named lifetime parameter
|
||||||
|
@ -220,7 +204,7 @@ LL | fn f<'a>(_: impl Foo<'a>) {}
|
||||||
| ++++ ++++
|
| ++++ ++++
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:49:22
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:47:22
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
|
LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() }
|
||||||
| ^^^ expected named lifetime parameter
|
| ^^^ expected named lifetime parameter
|
||||||
|
@ -233,7 +217,7 @@ LL | fn g<'a>(mut x: impl Foo<'a>) -> Option<&()> { x.next() }
|
||||||
| ++++ ++++
|
| ++++ ++++
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:57:22
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:55:22
|
||||||
|
|
|
|
||||||
LL | fn f(_: impl Foo<()>) {}
|
LL | fn f(_: impl Foo<()>) {}
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -246,7 +230,7 @@ LL | fn f<'a>(_: impl Foo<'a, ()>) {}
|
||||||
| ++++ +++
|
| ++++ +++
|
||||||
|
|
||||||
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
error[E0658]: anonymous lifetimes in `impl Trait` are unstable
|
||||||
--> $DIR/impl-trait-missing-lifetime-gated.rs:60:26
|
--> $DIR/impl-trait-missing-lifetime-gated.rs:58:26
|
||||||
|
|
|
|
||||||
LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
|
LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() }
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -258,7 +242,7 @@ help: consider introducing a named lifetime parameter
|
||||||
LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() }
|
LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() }
|
||||||
| ++++ +++
|
| ++++ +++
|
||||||
|
|
||||||
error: aborting due to 16 previous errors; 1 warning emitted
|
error: aborting due to 14 previous errors; 1 warning emitted
|
||||||
|
|
||||||
Some errors have detailed explanations: E0106, E0658.
|
Some errors have detailed explanations: E0106, E0658.
|
||||||
For more information about an error, try `rustc --explain E0106`.
|
For more information about an error, try `rustc --explain E0106`.
|
||||||
|
|
|
@ -8,7 +8,6 @@ fn f(_: impl Iterator<Item = &'_ ()>) {}
|
||||||
// But that lifetime does not participate in resolution.
|
// But that lifetime does not participate in resolution.
|
||||||
fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
//~| ERROR lifetime may not live long enough
|
|
||||||
|
|
||||||
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
|
// This is understood as `fn foo<'_1>(_: impl Iterator<Item = &'_1 ()>) {}`.
|
||||||
async fn h(_: impl Iterator<Item = &'_ ()>) {}
|
async fn h(_: impl Iterator<Item = &'_ ()>) {}
|
||||||
|
@ -16,6 +15,5 @@ async fn h(_: impl Iterator<Item = &'_ ()>) {}
|
||||||
// But that lifetime does not participate in resolution.
|
// But that lifetime does not participate in resolution.
|
||||||
async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
//~^ ERROR missing lifetime specifier
|
//~^ ERROR missing lifetime specifier
|
||||||
//~| ERROR lifetime may not live long enough
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -22,7 +22,7 @@ LL + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/impl-trait-missing-lifetime.rs:17:60
|
--> $DIR/impl-trait-missing-lifetime.rs:16:60
|
||||||
|
|
|
|
||||||
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
||||||
| ^^ expected named lifetime parameter
|
| ^^ expected named lifetime parameter
|
||||||
|
@ -44,20 +44,6 @@ LL - async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next(
|
||||||
LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|
LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() }
|
||||||
|
|
|
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/impl-trait-missing-lifetime.rs:17:69
|
|
||||||
|
|
|
||||||
LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
|
||||||
| ----------------------------------------------------------------- ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
|
||||||
| |
|
|
||||||
| return type `impl Future<Output = Option<&'static ()>>` contains a lifetime `'1`
|
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
|
||||||
--> $DIR/impl-trait-missing-lifetime.rs:9:63
|
|
||||||
|
|
|
||||||
LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() }
|
|
||||||
| ----- has type `x` ^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0106`.
|
For more information about this error, try `rustc --explain E0106`.
|
||||||
|
|
|
@ -8,8 +8,6 @@ fn main() {
|
||||||
let x = S(&|x| {
|
let x = S(&|x| {
|
||||||
println!("hi");
|
println!("hi");
|
||||||
x
|
x
|
||||||
//~^ ERROR lifetime may not live long enough
|
|
||||||
//~| ERROR lifetime may not live long enough
|
|
||||||
});
|
});
|
||||||
x.0(&X(&()));
|
x.0(&X(&()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,28 +31,6 @@ help: consider using one of the available lifetimes here
|
||||||
LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &'lifetime X<'lifetime>);
|
LL | struct V<'a>(&'a dyn for<'b> Fn(&X) -> &'lifetime X<'lifetime>);
|
||||||
| +++++++++ +++++++++++
|
| +++++++++ +++++++++++
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/missing-lt-for-hrtb.rs:10:9
|
|
||||||
|
|
|
||||||
LL | let x = S(&|x| {
|
|
||||||
| -- return type of closure is &'2 X<'_>
|
|
||||||
| |
|
|
||||||
| has type `&'1 X<'_>`
|
|
||||||
LL | println!("hi");
|
|
||||||
LL | x
|
|
||||||
| ^ returning this value requires that `'1` must outlive `'2`
|
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
|
||||||
--> $DIR/missing-lt-for-hrtb.rs:10:9
|
|
||||||
|
|
|
||||||
LL | let x = S(&|x| {
|
|
||||||
| -- return type of closure is &X<'4>
|
|
||||||
| |
|
|
||||||
| has type `&X<'3>`
|
|
||||||
LL | println!("hi");
|
|
||||||
LL | x
|
|
||||||
| ^ returning this value requires that `'3` must outlive `'4`
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0106`.
|
For more information about this error, try `rustc --explain E0106`.
|
||||||
|
|
17
tests/ui/unpretty/deprecated-attr.rs
Normal file
17
tests/ui/unpretty/deprecated-attr.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
pub struct PlainDeprecated;
|
||||||
|
|
||||||
|
#[deprecated = "here's why this is deprecated"]
|
||||||
|
pub struct DirectNote;
|
||||||
|
|
||||||
|
#[deprecated(note = "here's why this is deprecated")]
|
||||||
|
pub struct ExplicitNote;
|
||||||
|
|
||||||
|
#[deprecated(since = "1.2.3", note = "here's why this is deprecated")]
|
||||||
|
pub struct SinceAndNote;
|
||||||
|
|
||||||
|
#[deprecated(note = "here's why this is deprecated", since = "1.2.3")]
|
||||||
|
pub struct FlippedOrder;
|
21
tests/ui/unpretty/deprecated-attr.stdout
Normal file
21
tests/ui/unpretty/deprecated-attr.stdout
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#[prelude_import]
|
||||||
|
use ::std::prelude::rust_2015::*;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate std;
|
||||||
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
struct PlainDeprecated;
|
||||||
|
|
||||||
|
#[deprecated = "here's why this is deprecated"]
|
||||||
|
struct DirectNote;
|
||||||
|
|
||||||
|
#[deprecated = "here's why this is deprecated"]
|
||||||
|
struct ExplicitNote;
|
||||||
|
|
||||||
|
#[deprecated(since = "1.2.3", note = "here's why this is deprecated"]
|
||||||
|
struct SinceAndNote;
|
||||||
|
|
||||||
|
#[deprecated(since = "1.2.3", note = "here's why this is deprecated"]
|
||||||
|
struct FlippedOrder;
|
13
tests/ui/unpretty/diagnostic-attr.rs
Normal file
13
tests/ui/unpretty/diagnostic-attr.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#[diagnostic::on_unimplemented(
|
||||||
|
message = "My Message for `ImportantTrait<{A}>` implemented for `{Self}`",
|
||||||
|
label = "My Label",
|
||||||
|
note = "Note 1",
|
||||||
|
note = "Note 2"
|
||||||
|
)]
|
||||||
|
pub trait ImportantTrait<A> {}
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
|
impl<T> ImportantTrait<T> for T where T: Clone {}
|
16
tests/ui/unpretty/diagnostic-attr.stdout
Normal file
16
tests/ui/unpretty/diagnostic-attr.stdout
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#[prelude_import]
|
||||||
|
use ::std::prelude::rust_2015::*;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate std;
|
||||||
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#[diagnostic::on_unimplemented(message =
|
||||||
|
"My Message for `ImportantTrait<{A}>` implemented for `{Self}`", label =
|
||||||
|
"My Label", note = "Note 1", note = "Note 2")]
|
||||||
|
trait ImportantTrait<A> { }
|
||||||
|
|
||||||
|
#[diagnostic::do_not_recommend]
|
||||||
|
impl <T> ImportantTrait<T> for T where T: Clone
|
||||||
|
{#![diagnostic::do_not_recommend]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue