self.owners.ensure_contains_elem(CRATE_DEF_ID, || None);
self.owners[CRATE_DEF_ID] = Some(hir::OwnerNode::Crate(module));
- let body_ids = body_ids(&self.bodies);
let proc_macros =
c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect();
let krate = hir::Crate {
owners: self.owners,
bodies: self.bodies,
- body_ids,
trait_impls: self.trait_impls,
modules: self.modules,
proc_macros,
}
}
-fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'_>>) -> Vec<hir::BodyId> {
- // Sorting by span ensures that we get things in order within a
- // file, and also puts the files in a sensible order.
- let mut body_ids: Vec<_> = bodies.keys().cloned().collect();
- body_ids.sort_by_key(|b| bodies[b].value.span);
- body_ids
-}
-
/// Helper struct for delayed construction of GenericArgs.
struct GenericArgsCtor<'hir> {
args: SmallVec<[hir::GenericArg<'hir>; 4]>,
pub bodies: BTreeMap<BodyId, Body<'hir>>,
pub trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
- /// A list of the body ids written out in the order in which they
- /// appear in the crate. If you're going to process all the bodies
- /// in the crate, you should iterate over this list rather than the keys
- /// of bodies.
- pub body_ids: Vec<BodyId>,
-
/// A list of modules written out in the order in which they
/// appear in the crate. This includes the main crate module.
pub modules: BTreeMap<LocalDefId, ModuleItems>,
/// crate. If you would prefer to iterate over the bodies
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
pub fn body_owners(self) -> impl Iterator<Item = LocalDefId> + Captures<'tcx> + 'tcx {
- self.hir()
- .krate()
- .body_ids
- .iter()
- .map(move |&body_id| self.hir().body_owner_def_id(body_id))
+ self.hir().krate().bodies.keys().map(move |&body_id| self.hir().body_owner_def_id(body_id))
}
pub fn par_body_owners<F: Fn(LocalDefId) + sync::Sync + sync::Send>(self, f: F) {
- par_iter(&self.hir().krate().body_ids)
- .for_each(|&body_id| f(self.hir().body_owner_def_id(body_id)));
+ par_iter(&self.hir().krate().bodies)
+ .for_each(|(&body_id, _)| f(self.hir().body_owner_def_id(body_id)));
}
pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
pub fn check_crate(tcx: TyCtxt<'_>) {
let mut used_trait_imports = FxHashSet::default();
- for &body_id in tcx.hir().krate().bodies.keys() {
- let item_def_id = tcx.hir().body_owner_def_id(body_id);
+ for item_def_id in tcx.body_owners() {
let imports = tcx.used_trait_imports(item_def_id);
debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports);
used_trait_imports.extend(imports.iter());
LL | asm!("{}", const const_bar(x));
| ^ non-constant value
+error[E0308]: mismatched types
+ --> $DIR/type-check-1.rs:48:26
+ |
+LL | asm!("{}", const 0f32);
+ | ^^^^ expected integer, found `f32`
+
+error[E0308]: mismatched types
+ --> $DIR/type-check-1.rs:50:26
+ |
+LL | asm!("{}", const 0 as *mut u8);
+ | ^^^^^^^^^^^^ expected integer, found *-ptr
+ |
+ = note: expected type `{integer}`
+ found raw pointer `*mut u8`
+
error: invalid asm output
--> $DIR/type-check-1.rs:10:29
|
= help: the trait `Sized` is not implemented for `[u64]`
= note: all inline asm arguments must have a statically known size
-error[E0308]: mismatched types
- --> $DIR/type-check-1.rs:48:26
- |
-LL | asm!("{}", const 0f32);
- | ^^^^ expected integer, found `f32`
-
-error[E0308]: mismatched types
- --> $DIR/type-check-1.rs:50:26
- |
-LL | asm!("{}", const 0 as *mut u8);
- | ^^^^^^^^^^^^ expected integer, found *-ptr
- |
- = note: expected type `{integer}`
- found raw pointer `*mut u8`
-
error[E0308]: mismatched types
--> $DIR/type-check-1.rs:60:25
|
-error[E0507]: cannot move out of static item `settings_dir`
- --> $DIR/issue-64453.rs:14:37
- |
-LL | let settings_data = from_string(settings_dir);
- | ^^^^^^^^^^^^ move occurs because `settings_dir` has type `String`, which does not implement the `Copy` trait
-
error: `Arguments::<'a>::new_v1` is not yet stable as a const fn
--> $DIR/issue-64453.rs:4:31
|
|
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
+error[E0507]: cannot move out of static item `settings_dir`
+ --> $DIR/issue-64453.rs:14:37
+ |
+LL | let settings_data = from_string(settings_dir);
+ | ^^^^^^^^^^^^ move occurs because `settings_dir` has type `String`, which does not implement the `Copy` trait
+
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0507.
LL | bar::<N>()
| ^ expected `u8`, found `usize`
-error[E0308]: mismatched types
- --> $DIR/type_mismatch.rs:5:31
- |
-LL | fn bar<const N: u8>() -> [u8; N] {}
- | ^ expected `usize`, found `u8`
-
error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:5:26
|
| |
| implicitly returns `()` as its body has no tail or `return` expression
+error[E0308]: mismatched types
+ --> $DIR/type_mismatch.rs:5:31
+ |
+LL | fn bar<const N: u8>() -> [u8; N] {}
+ | ^ expected `usize`, found `u8`
+
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
- --> $DIR/const-extern-fn-requires-unsafe.rs:11:5
+ --> $DIR/const-extern-fn-requires-unsafe.rs:9:17
|
-LL | foo();
- | ^^^^^ call to unsafe function
+LL | let a: [u8; foo()];
+ | ^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
- --> $DIR/const-extern-fn-requires-unsafe.rs:9:17
+ --> $DIR/const-extern-fn-requires-unsafe.rs:11:5
|
-LL | let a: [u8; foo()];
- | ^^^^^ call to unsafe function
+LL | foo();
+ | ^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
-error: argument to `panic!()` in a const context must have type `&str`
- --> $DIR/issue-66693.rs:13:5
- |
-LL | panic!(&1);
- | ^^^^^^^^^^^
- |
- = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693.rs:6:15
|
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+error: argument to `panic!()` in a const context must have type `&str`
+ --> $DIR/issue-66693.rs:13:5
+ |
+LL | panic!(&1);
+ | ^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: aborting due to 3 previous errors
+error[E0282]: type annotations needed
+ --> $DIR/issue-47486.rs:3:31
+ |
+LL | [0u8; std::mem::size_of::<_>()];
+ | ^ cannot infer type
+
error[E0308]: mismatched types
--> $DIR/issue-47486.rs:2:10
|
LL | () < std::mem::size_of::<_>();
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `usize`
-error[E0282]: type annotations needed
- --> $DIR/issue-47486.rs:3:11
- |
-LL | [0u8; std::mem::size_of::<_>()];
- | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
-
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0282, E0308.
-error[E0308]: mismatched types
- --> $DIR/liveness-return-last-stmt-semi.rs:4:41
- |
-LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
- | --- ^^^ - help: consider removing this semicolon
- | | |
- | | expected `i32`, found `()`
- | implicitly returns `()` as its body has no tail or `return` expression
-...
-LL | test!();
- | -------- in this macro invocation
- |
- = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0308]: mismatched types
--> $DIR/liveness-return-last-stmt-semi.rs:7:19
|
| |
| implicitly returns `()` as its body has no tail or `return` expression
+error[E0308]: mismatched types
+ --> $DIR/liveness-return-last-stmt-semi.rs:4:41
+ |
+LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
+ | --- ^^^ - help: consider removing this semicolon
+ | | |
+ | | expected `i32`, found `()`
+ | implicitly returns `()` as its body has no tail or `return` expression
+...
+LL | test!();
+ | -------- in this macro invocation
+ |
+ = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.
+error[E0308]: mismatched types
+ --> $DIR/attribute-with-error.rs:25:22
+ |
+LL | let a: i32 = "foo";
+ | --- ^^^^^ expected `i32`, found `&str`
+ | |
+ | expected due to this
+
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:10:18
|
| |
| expected due to this
-error[E0308]: mismatched types
- --> $DIR/attribute-with-error.rs:25:22
- |
-LL | let a: i32 = "foo";
- | --- ^^^^^ expected `i32`, found `&str`
- | |
- | expected due to this
-
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:35:22
|
LL | let e = [0; "foo"];
| ^^^^^ expected `usize`, found `&str`
-error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:31:17
- |
-LL | let g = [0; G { g: () }];
- | ^^^^^^^^^^^ expected `usize`, found struct `G`
-
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:19:17
|
LL | let f = [0; 4usize];
| ~~~~~~
+error[E0308]: mismatched types
+ --> $DIR/repeat_count.rs:31:17
+ |
+LL | let g = [0; G { g: () }];
+ | ^^^^^^^^^^^ expected `usize`, found struct `G`
+
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0308, E0435.
-error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug`
- --> $DIR/impl-trait-with-missing-bounds.rs:6:13
- |
-LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
-note: required by a bound in `qux`
- --> $DIR/impl-trait-with-missing-bounds.rs:50:16
- |
-LL | fn qux(_: impl std::fmt::Debug) {}
- | ^^^^^^^^^^^^^^^ required by this bound in `qux`
-help: introduce a type parameter with a trait bound instead of using `impl Trait`
- |
-LL | fn foo<I: Iterator>(constraints: I) where <I as Iterator>::Item: Debug {
- | +++++++++++++ ~ ++++++++++++++++++++++++++++++++++
-
error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug`
--> $DIR/impl-trait-with-missing-bounds.rs:14:13
|
LL | fn bak<I: Iterator + std::fmt::Debug>(constraints: I) where <I as Iterator>::Item: Debug {
| +++++++++++++++++++++++++++++++ ~ ++++++++++++++++++++++++++++++++++
+error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug`
+ --> $DIR/impl-trait-with-missing-bounds.rs:6:13
+ |
+LL | qux(constraint);
+ | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ |
+ = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
+note: required by a bound in `qux`
+ --> $DIR/impl-trait-with-missing-bounds.rs:50:16
+ |
+LL | fn qux(_: impl std::fmt::Debug) {}
+ | ^^^^^^^^^^^^^^^ required by this bound in `qux`
+help: introduce a type parameter with a trait bound instead of using `impl Trait`
+ |
+LL | fn foo<I: Iterator>(constraints: I) where <I as Iterator>::Item: Debug {
+ | +++++++++++++ ~ ++++++++++++++++++++++++++++++++++
+
error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug`
--> $DIR/impl-trait-with-missing-bounds.rs:45:13
|
-error[E0308]: mismatched types
- --> $DIR/suggest-ref-macro.rs:8:1
- |
-LL | #[hello]
- | ^^^^^^^^ expected `&mut i32`, found integer
- |
- = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0308]: mismatched types
--> $DIR/suggest-ref-macro.rs:15:11
|
| expected `&mut i32`, found integer
| help: consider mutably borrowing here: `&mut 456`
+error[E0308]: mismatched types
+ --> $DIR/suggest-ref-macro.rs:8:1
+ |
+LL | #[hello]
+ | ^^^^^^^^ expected `&mut i32`, found integer
+ |
+ = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.
-error[E0277]: the trait bound `U1: Copy` is not satisfied
- --> $DIR/union-derive-clone.rs:6:10
- |
-LL | #[derive(Clone)]
- | ^^^^^ the trait `Copy` is not implemented for `U1`
- |
-note: required by a bound in `AssertParamIsCopy`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> {
- | ^^^^ required by this bound in `AssertParamIsCopy`
- = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its trait bounds were not satisfied
--> $DIR/union-derive-clone.rs:38:15
|
`CloneNoCopy: Copy`
which is required by `U5<CloneNoCopy>: Clone`
+error[E0277]: the trait bound `U1: Copy` is not satisfied
+ --> $DIR/union-derive-clone.rs:6:10
+ |
+LL | #[derive(Clone)]
+ | ^^^^^ the trait `Copy` is not implemented for `U1`
+ |
+note: required by a bound in `AssertParamIsCopy`
+ --> $SRC_DIR/core/src/clone.rs:LL:COL
+ |
+LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> {
+ | ^^^^ required by this bound in `AssertParamIsCopy`
+ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0599.
-error[E0277]: the trait bound `U1: Copy` is not satisfied
- --> $DIR/union-derive-clone.rs:6:10
- |
-LL | #[derive(Clone)]
- | ^^^^^ the trait `Copy` is not implemented for `U1`
- |
-note: required by a bound in `AssertParamIsCopy`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> {
- | ^^^^ required by this bound in `AssertParamIsCopy`
- = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its trait bounds were not satisfied
--> $DIR/union-derive-clone.rs:38:15
|
`CloneNoCopy: Copy`
which is required by `U5<CloneNoCopy>: Clone`
+error[E0277]: the trait bound `U1: Copy` is not satisfied
+ --> $DIR/union-derive-clone.rs:6:10
+ |
+LL | #[derive(Clone)]
+ | ^^^^^ the trait `Copy` is not implemented for `U1`
+ |
+note: required by a bound in `AssertParamIsCopy`
+ --> $SRC_DIR/core/src/clone.rs:LL:COL
+ |
+LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> {
+ | ^^^^ required by this bound in `AssertParamIsCopy`
+ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0599.