Can't use AccessControl anymore after release of 5.0?

Hi, currently working on an ERC20 contract, I've been using AccessControl for a bit of time and suddenly today I'm experiencing a interesting issue when compiling.

contract Token is
    IERC20,
    Ownable,
    ReentrancyGuard,
    AccessControl
{
...
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
...
constructor() VRFConsumerBaseV2(_vrfCoordinator) {
        router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Uniswap
        pair = IUniswapV2Factory(router.factory()).createPair(
            router.WETH(),
            address(this)
        );
        _allowances[address(this)][address(router)] = type(uint256).max;

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(ADMIN_ROLE, msg.sender);
}}

So here in the constructor I get,

DeclarationError: Undeclared identifier.
--> contracts/Token.sol:505:9:
|
505 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);

Same for ADMIN_ROLE.

It is the first time seeing this error, last week this contract was perfectly compiling and deploying. So I'm wondering if it is because of V5.0 of OZ contracts? They added an AccessManager so maybe there's some conflict idk tbh. If anyone has any idea, that would be great, thank you!

You can use the _grantRole function instead. _setupRole was removed in 5.0 and was previously already marked as deprecated.

Note that 5.0 contains a number of breaking changes. Please see the release notes at https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.0 if you encounter other similar errors.

The current recommended best practice is also to not use msg.sender for the role assignment, but to pass in addresses for the roles in the constructor arguments. See https://wizard.openzeppelin.com/ for an example.

Thank you very much! Missed the deprecation part and didn't know for the msg.sender practice. Very helpful.