Donald Trump thinks immigrants are trash, metaphorically speaking.

Not just unauthorized immigrants. Legal immigrants — specifically, those who come to the US on “diversity visas,” after being selected in a lottery for residents of countries that are underrepresented in the US immigration system as a whole.

It’s not surprising that Trump is wrong on the facts — people selected in the visa lottery go through exactly as much screening as any other would-be immigrant to the United States, and the governments of their countries are not deliberately “picking” them to immigrate.

The fact that he spent part of a speech to graduates of the FBI Academy denigrating people who have followed US law is, for better or worse, only slightly more so. Trump’s speeches to law enforcement are often his most unguarded and rip-roaring. They’re the speeches in his official capacity that feel closest to the speeches he delivers at rallies — as if he sees law enforcement officers as part of his base, as close to him as his staunchest supporters.

That frees him to return to his favorite theme, the one he returns to whenever things are looking bad for his administration or agenda: that immigrants are not to be trusted.

Not just unauthorized immigrants. Immigrants, period.

Trump distinguished himself by not distinguishing among immigrants

Donald Trump likes to say that no one was talking about immigration until he entered the presidential race in 2015. That’s not at all true — Trump’s insistence on more enforcement to crack down on unauthorized immigration was shared by most of his rivals for the Republican nomination.

Trump used immigration to win the loyalty of a swath of the Republican base — the people he has been playing to, in one form or another, ever since. But he did that by rejecting what had become the traditional Republican way to talk about immigration: welcoming legal immigrants with one hand, while disparaging unauthorized immigration with the other.

Republicans, I wrote at the time, had “found messages that were acceptable to their conservative base, but struggled to find messages that excite them. Trump has succeeded where they’ve failed: He's found a message that gets to the core of why so many conservatives are ambivalent or hostile toward immigrants.”

Part of Trump’s innovation was that, unlike his Republican colleagues, he didn’t champion legal immigration — and, in fact, he was perfectly happy to cast suspicions on legal immigrants.

Sure, Trump would occasionally throw a line into speeches about how “we love legal immigrants,” or promise to put a big beautiful door in his big beautiful wall. But when it came down to specifics, it turned out Trump had very little to say in the way of praise for any group of legal immigrants — and something disparaging to say about pretty much all of them.

Refugees and asylum-seekers were a potential invading force, a “Trojan horse” who were taking government resources away from helping Americans. Immigrant families were refusing to assimilate. People on work visas — even the “high-skilled” immigrants other Republicans praised — were taking jobs from Americans thanks to the rapacity of tech billionaires.

In fact, the only group of immigrants that Trump has praised most consistently has been a group of unauthorized immigrants — the “DREAMers,” or unauthorized immigrants who grew up in the United States, who the president has called “terrific people” and promised to treat with “heart” even while winding down the program that allowed them to stay and work in the US without fear of deportation.

The Trump administration has targeted legal immigration in pretty much every respect

Trump’s hostility toward legal immigration showed up in his policies. His immigration platform — the first policy his campaign released, in 2015 — called for reductions in legal immigration, particularly of refugees and guest workers. In the first week of his administration, he signed an executive order temporarily banning legal immigration from several majority-Muslim countries and putting a moratorium on all legal admissions of refugees; while the country-specific ban went through several iterations before being allowed to go into effect in November, Trump has succeeded in radically restricting the number of refugees admitted to the United States.

Other executive orders that would crack down on legal immigrants — by admitting fewer guest workers, and making it easier to deport legal immigrants for using social services — haven’t yet been signed, though the administration appears to be looking for ways to accomplish the same things through regulation.

And while Trump has pushed for deals to be made in Congress on Obamacare repeal and tax reform, the piece of legislation that he’s worked hardest to push is the RAISE Act — a bill sponsored by Sen. Tom Cotton (R-AR) and Sen. David Perdue (R-GA), and reportedly co-drafted by Trump policy adviser Stephen Miller, that would slash legal immigration in certain categories without expanding it anywhere else.

That’s an unpopular position even within the Republican Party, where many politicians support expanding “high-skilled” immigration or allowing more “low-skilled” guest workers for industries in their home states.

Trump himself is hardly a policy maven, and it’s pretty clear that Miller and company are driving the policy agenda. But Trump’s own instincts and worldview lead him time and time again to bashing immigrants. After a terrorist attack in November, Trump immediately blamed the diversity visa; after an attempted attack in New York on Monday, he blamed “chain migration.” In both cases, the perpetrators of the attack were legal immigrants. But Trump used the attacks to complain that immigration itself was a national security threat — a message he simply generalized on Friday, with his comments about the “worst of the worst.”

The Trump administration knows that it’s more anti-immigrant than the average American — so they’re working to change America’s mind

Messages like this are guaranteed to resonate with Trump’s base. Many of them are likely among the 12 percent or so of Americans who are opposed to all immigration, legal and unauthorized. (Former Trump chief strategist Steve Bannon is almost certainly in this category — after all, he looks at immigrant tech entrepreneurs and CEOs and sees people who are insufficiently loyal to America.)

Others are probably in the large swath of Americans whose primary concern about immigration is about preserving “American” culture as they see it. Their judgment of whether immigrants should be allowed to stay in the US is based less on those immigrants’ legal status than on other factors like their education, fluency in English, and ethnicity; they’re less concerned about immigrants taking jobs than about immigrants disrespecting the flag.

Attacks on the “diversity visa” and “chain migration” hit these Americans’ concerns squarely: They evoke the idea that immigration is a form of social engineering, perpetrated by elites to transform America into something fundamentally different and alien.

But here’s the problem with evaluating immigrants based on assimilability: When people actually meet immigrants who have integrated into their communities, they’re likely to see them as “good immigrants” who should be allowed to come to and stay in the US.

Trump voters have been shocked when long-resident unauthorized immigrants in their communities have been arrested and deported. They’re not any more likely to support policies that would make it harder for their neighbors to stay in the United States, or bring their family members here. (Indeed, for many people — and in US law — having “family ties” in the US is a sign of intent to stay here.)

The Trump administration knows that it’s fighting an uphill battle when it comes to legal immigration, or at least “chain” (family-based) migration. According to the AP, it’s working on a public-relations campaign to turn public opinion against “chain migration,” to help the administration push bills like the RAISE Act on Congress.

Usually, when a president is out of step with the public on an issue, his administration either tries to downplay the discrepancy or pushes the president to change his position. The Trump administration is more interested in pushing the public to align with the president. That’s a sign of their — and his — deep ideological commitment to the idea that immigration itself is the problem.