While most incumbents generally talk about how horrible their opponents are, lawmakers in tough races also like to have something to show voters for their time in Washington. This is especially vital for Republicans who, in many races, find that their party’s presumptive presidential nominee, Donald J. Trump, may be more of an anvil than a rocket booster to their own fortunes.

Some of the legislation has been bipartisan, some purely partisan, but all of it stems from promises that Republicans have made — and found themselves often struggling to keep — to create a functional Congress and mollify voters who consistently say they are sick of a Washington that does not work.

“When Senator McConnell became leader, he chose a dramatically different approach than his predecessor,” Don Stewart, a spokesman for Senator Mitch McConnell of Kentucky, the majority leader, said in an email. “He opened the Senate, returned to a more functioning Senate, and allowed senators to participate in the legislative process,” Mr. Stewart continued, claiming that when Senator Harry Reid, Democrat of Nevada, was the majority leader, thorny issues often were not voted on. “While this isn’t the easy way, it allowed members to have more than dysfunction to show for their time in the Senate.”

Many of the measures are partisan “message bills” that flop like so much hair in the July humidity. The bill that would have prevented certain federal grants from going to sanctuary cities, where law enforcement officials are banned from cooperating with federal immigration authorities on detention requests, was popular in Mr. Toomey’s home state.

The measure failed, 53-44, along party lines, but Mr. Toomey, who has formulated his reputation on a mix of law and order and modest gun safety advocacy, can still boast that the bill came to the Senate floor.