Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. If you cannot produce a minimal reproduction case (something that would work in isolation), please provide the steps or even link to a repository that causes the problematic output to occur. --Given the following code: The current output is: Ideally the output should look like: In cases where intrinsics have been stabilised in | it would be useful to suggest these to users first. Especially as using intrinsics generates another error that tells you to prefer stabilized functions in . This would hopefully make handling this error easier for new rust users coming from languages like C/C++ and looking for the equivalent of <!-- If dramatically different output is caused by small changes, consider also adding them here. If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. The output might also be different depending on the Edition. --The output is the same on stable, beta and nightly
I'd be satisfied if we filtered out intrinsics altogether except for when the feature was enabled.
I also get quite annoyed when stable rustc recommends I use unstable features (maybe that should be fixed in an RFC)
Checking the DefId of each suggested path to see if they are annotated with should be doable.
This seems to be harder than I initially thought... so since we emit this "consider importing" suggestion in , we do not have access to it seems. And I have no idea how to extract the attributes from each without ... :thinking:
We might want to consider adding yet another dumping ground field in the itself or in ... But at that point it seems like too much mem consumption for little gain. The other option is to delay the emitting of these errors until later, but that also seems... like a lot of additional complexity :-/
For now, I guess it wouldn't hurt just to filter suggesting paths that are literally (and ) instead of going thru all of the work of adding more info to the . I can put up a PR that does that later.

Discussion:
// Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; <del> let candidates = self </del> <ins> let mut candidates = self </ins> .r .lookup_import_candidates(ident, ns, &self.parent_scope, is_expected) .into_iter()

}) .collect::<Vec<_>>(); let crate_def_id = CRATE_DEF_ID.to_def_id(); <ins> // Try to filter out intrinsics candidates, as long as we have // some other candidates to suggest. let intrinsic_candidates: Vec<_> = candidates .drain_filter(|sugg| { let path = path_names_to_string(&sugg.path); path.starts_with("core::intrinsics::") || path.starts_with("std::intrinsics::") }) .collect(); if candidates.is_empty() { // Put them back if we have no more candidates to suggest... candidates.extend(intrinsic_candidates); } </ins> if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) { let mut enum_candidates: Vec<_> = self .r

<ins> fn main() { // Should suggest only `std::mem::size_of` let _ = size_of::<usize>(); //~^ ERROR cannot find // Should suggest `std::intrinsics::fabsf64`, // since there is no non-intrinsic to suggest. let _ = fabsf64(1.0); //~^ ERROR cannot find } </ins>

<ins> error[E0425]: cannot find function `size_of` in this scope --> $DIR/filter-intrinsics.rs:3:13 | LL |     let _ = size_of::<usize>(); |             ^^^^^^^ not found in this scope | help: consider importing this function | LL | use std::mem::size_of; | error[E0425]: cannot find function `fabsf64` in this scope --> $DIR/filter-intrinsics.rs:8:13 | LL |     let _ = fabsf64(1.0); |             ^^^^^^^ not found in this scope | help: consider importing this function | LL | use std::intrinsics::fabsf64; | error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`. </ins>