Sanders did better in primaries that allowed people outside the Democratic Party to vote and was throughout the election seasons (and remains, as of the last pollI saw earlier this year) the single most popular national political figure in the country. Every objective indication is that he would have done better than Clinton in “the states that mattered”.
In any case, much as one might prefer policy ideas to be decisive, elections are less about policy ideas and more about soft personal factors than people like to think.
Plus, Bernie wasn't attacked because of his policies because HRC's were similar. He would have been in the general election.
Yes he was, from the right, by Clinton—that was a key part of Clinton's primary campaign—and, no, they weren't that similar. But I agree that there would have been more focus on policy in a general election campaign with Sanders as the nominee, which would have been bad for Trump.